แปลงจาก MEL ไปเป็น Python ใน Maya

Sunday, November 15, 2009 ที่ 9:41 PM
ผมจะสาธิตการแปลงโค๊ดจาก MEL ที่เราคุ้นเคยกันดี ไปเป็น Python ซึ่งตัวอย่างนี้ผมไม่ได้ใช้ PyMEL นะ
คนที่ไม่ได้ลง PyMEL ก็จะได้เข้าใจด้วย แต่ถ้าใช้ PyMEL จะสั้นกว่านี้เยอะใครที่ลง PyMEL แล้วก็ไปลองทำกันเองได้ ไม่ยาก

ดู VDO กันเลย


code MEL ที่ใช้ทำ Spiral Sphere

//Create new scene in MEL

file -f -new;


//Create spiral function in MEL

for ($i=0;

$i<100;

$i+=1)

{

float $sine=sin($i)*($i*0.25);

float $cosine=cos($i)*($i*0.25);

sphere -p $cosine 1 $sine;

}


code Python ที่ใช้ทำ Spiral Sphere

import maya.cmds as mc


#Create new scene in Python

mc.f=newFile(f=1)


#Create spiral function in Python

i=0

for i in range(100):

mysin = sin(i)*(i*.25)

mycosine = cos(i)*(i*0.25)

mysphere = mc.polySphere()

move(mysin,mycosine,0)

ก็จะเห็นว่า จาก MEL ที่ดู อ่านยากๆงงๆ พอมาเป็น Python ก็อ่านง่ายดูง่ายกว่า MEL [หรือเปล่า ? บางคนอาจจะบอกว่า มันอ่านง่ายกว่าตรงไหนฟระ 555]
แต่จริงๆแล้ว Python มันอ่านง่ายกว่า MEL จริงๆอ่ะแหละ ถ้าเราลองคุ้นเคยกะมัน มันก็ไม่ยากหรอกครับ

ตอนแรกมันจะเหมือนยาขมครับ แต่ต่อไปมันจะเหมือนน้ำหวานไปเอง ไม่ว่าจะ MEL หรือ Python

1 Responses to แปลงจาก MEL ไปเป็น Python ใน Maya

  1. artslan Says:

    ผมเพื่งเห็น MEL ผมใช้ Nurbs sphere แต่ที่ Python ผมใช้ PolySphere แต่ก็ไม่น่างงนะ เพราะมันก็ Sphere

    follow me on Twitter

    Thaiafterfx | Entries (RSS) | Comments (RSS) | Designed by MB Web Design | XML Coded By Cahayabiru.com | Distributed by Deluxe Templates | My Flickr Artslan Flickr