본문 바로가기
College Study/Maya (KR,ENG)

[Maya] 파이썬으로 모델링하기 (크리스마스 트리 1/4) Modeling with Python (Quarter of a Christmas Tree)

by 2den 2020. 11. 7.
728x90

2019. 3. 11. 22:08

 

지금까지 배운 것을 복습하기 위해 크리스마스 트리를 만들어보기로 했다. 빨강-초록 계열의 랜덤한 값을 가진 색상의 잎과, 맨 위에 노란 별을 가진 트리를 만들어보았다.

I decided to make a Christmas tree which has green-red randomized-colored leaves and a yellow star on it.

 

 

 

import pymel.core as pm
import random

myPyramids = []

#make pyramids
for n in range (386):
    myPyramids.append(pm.polyPyramid())

count = 0
for x in range (10):
    yran = 10 - x
    for y in range (yran):
        zran = 10 -y
        for z in range (zran):
            rg = int(random.random()*10)%2 #red or green?
            pm.select(myPyramids[count])
            pm.move(0.1*x*x, y, 0.1*z*z) #curve
            pm.scale(1, 1, 1)
            if (rg): #green
                pm.polyColorPerVertex(colorRGB=[0, 1-random.random(), 0], colorDisplayOption=True)
            else: #red
                pm.polyColorPerVertex(colorRGB=[1-random.random(), 0, 0], colorDisplayOption=True)
            pm.rotate(x*10.0, y*10.0, z*10.0)
            count = count + 1

#a star
pm.select(myPyramids[count])
print(count)
pm.move(0, 10.1, 0)
pm.scale(1, 1, 1)
pm.rotate(0, 90, 0)
pm.polyColorPerVertex(colorRGB=[1, 1, 0], colorDisplayOption=True)

 

이제 이것을 나머지 사분면에 미러링하기만 하면 된다.

Now, I want to figure out how to mirror this to other quadrants.

 


* The completed codes are in my github: github.com/shinerd/Maya

 

shinerd/Maya

maya with python. Contribute to shinerd/Maya development by creating an account on GitHub.

github.com

 

728x90

댓글