회원 로그인
|
Python for Maya - 10. polygon vertex random move
기반으로 복습하는 차원에서 재정리한 것입니다.
선택한 object의 vertex를 random으로 움직이는 스크립이다.
polygon sphere를 생성, 선택하여 아래 script를 실행하면 vertex가 무작위로 움직이게 된다.
import maya.cmds as cmds import random sel_obj = cmds.ls(sl=1) if len(sel_obj) == 1: if cmds.nodeType(cmds.listHistory(sel_obj[0], lv=1)[0]) == 'mesh': # listHistory mel 명령어로 선택된 object의 그전 shape node를 검색하여 nodeType이 'mesh'와 같은지 묻게 된다. poly_count = cmds.polyEvaluate(sel_obj[0], v=1) # polyEvaluate mel 명령어로 polygon의 정보를 poly_count에 치환한다. flag v는 vertex로 vetext의 갯수(int)를 poly_count 변수에 치환한다. range_ = (-1, 1) # 이동할 범위를 설정한다. 1 ~ -1 사이로 이동하게 된다. for no_ in range(poly_count): x_ = random.uniform(*range_) y_ = random.uniform(*range_) z_ = random.uniform(*range_) # random하게 range의 값이 x_, y_, z_ 변수로 치환한다. *는 함수나 명령에 값이 대입할 때, 자료의 인수 형태로 대입되게 도와주는 연활을 한단다. *를 쓰지 않는다면 range_의 값인 -1, 1이 그대로 들어가므로 에러가 발생된단다. cmds.move(x_, y_, z_, '%s.vtx[%s]' % (sel_obj[0], no_), r=1) # vertex들을 하나씩 이동하게 된다. poly_count (vertext 갯수) 조건이 맞을 때까지 for문을 계속 반복하여 range_변수에 random하게 수치를 변환하여 move mel 명령어로 vertex를 움직이게 된다.
─────────────────────────────────────────────────
source : http://cafe.naver.com/digitaldream/488
'Maya Python 시작하기' 10) polygon vertex random move (난리난 모양 만들기)
댓글 0개
| 엮인글 0개
466개(18/24페이지)
번호 | 제목 | 글쓴이 | 조회 | 날짜 |
---|---|---|---|---|
마야 뷰포트 네비게이션 팁 | 푸딩뱃살 | 44069 | 2020.04.06 17:22 | |
Maya 버전 별 Python 버전 | 푸딩뱃살 | 65185 | 2014.01.08 17:59 | |
124 | [FX] Lesson 1: Creating nCloth collisions Step 2 | artsOne | 2174 | 2008.04.13 17:28 |
123 | [FX] Lesson 1: Creating nCloth collisions Step 1 | artsOne | 2413 | 2008.04.13 16:23 |
122 | [참고] Expression Manual | artsOne | 2251 | 2008.04.13 02:44 |
121 | [Script] MEL 기초 #01 - 기초 (자료형) | artsOne | 3975 | 2008.04.10 00:28 |
120 | [Base] 선택 우선순위 | artsone | 2184 | 2008.04.09 02:47 |
>> | [Script] Python for Maya - 10. polygon vertex random move | artsOne | 4652 | 2008.04.06 23:44 |
118 | [Rigging] Deform > Edit Membership Tool | artsone | 2660 | 2008.04.05 02:28 |
117 | [Rigging] Deform > Wire 활용 | artsone | 2258 | 2008.04.05 02:01 |
116 | [Animation] Bake Simulation | artsone | 1889 | 2008.04.01 23:04 |
115 | [Rigging] 로프 Stretch Rigging | artsone | 2394 | 2008.03.31 21:40 |
114 | [Rigging] Bouncing Ball Rigging | artsone | 2380 | 2008.03.20 23:29 |
113 | [Rigging] bind 후 object가 2배로 움직이는 현상 막기 | artsone | 2136 | 2008.03.08 03:28 |
112 | [Rigging] Lattice와 Rigid bind를 이용한 skinning | artsone | 2657 | 2008.03.08 03:18 |
111 | [Script] Python for Maya - 9. polysmooth 자동 설정 (format 변환) | artsOne | 4451 | 2008.03.05 01:18 |
110 | [Script] Python for Maya - 8. random 응용 (if문) | artsOne | 4758 | 2008.02.27 02:22 |
109 | [Script] Python for Maya - 7. random (for문) | artsone | 4786 | 2008.02.26 01:37 |
108 | [Script] Python for Maya - 6. 리스트 자료 다루기 2 | artsOne | 3859 | 2008.02.23 17:17 |
107 | [Script] Python for Maya - 5. 리스트 자료 다루기 1 | artsOne | 3949 | 2008.02.22 20:27 |
106 | [Script] Python for Maya - 4. set (집합) | artsOne | 4865 | 2008.02.22 17:49 |
105 | [Script] Python for Maya - 3. pickle (지속 모듈-파일 관리) | artsOne | 4855 | 2008.02.21 01:57 |