Wednesday, April 2, 2014

Placing a follicle - the smart way.

He shows a very interesting technic about re-positioning a joint after it was bound to a mesh without effecting the mesh deformation and still maintaining skin weight painted.

But, that's not what I wanna talk about here.

Placing follicle on a mesh is kinda hard to get it at the exact point(of course, the mesh must not have overlap UVs). You have to tweak the U and V values around until it goes where you want, still, not the 'exact' point that you had in mind. In the tutorial he talked about his script(his comment) that place a follicle at exactly the point specified on the mesh or the closest possible. I wasn't be able to use it, because it was written using Maya python API 2.0. So, I dig into his code and modify some part of it to use the old python API and to better suite my needs. Take a look at my code. I commented on almost every line of it for you.

To run it just execute the whole function once select a vertex or 2 transforms(1.the mesh 2.any locator) and type:
    createFollicleFromPosition()

PS. the script requires PyMel.

ไปเจอ tutorial นี้ ของคุณ .
ในคลิปเขาแนะนำเทคนิคน่าสนใจมากเกี่ยวกับการย้ายตำแหน่ง joint หลังจากที่ bind skin ไปแล้ว โดยที่ไม่ต้องเพ้นเวทใหม่(ย้ายเอาดื้อๆเลย) น่าสนใจมาก

แต่..นั่นไม่ใช่ที่จะพูดถึงวันนี้

การแปะ follice บนโพลิกอนนั้นค่อนข้างยากที่จะวางในตำแน่งที่เราต้องการเป๊ะๆ(โพลีก้อนต้องไม่มี UV ซ้อนนะ) เราต้องนั่งปรับค่า U กับ V ไปทีละเล็กละน้อย เรื่อยๆ จนมันไปอยู่ในที่ๆเราต้องการ แต่ก็ยังไม่ "เป๊ะ" ในคลิปเขาพูดถึงสคริปของเขา(ในcomment) ที่เป็นสคริปสำหรับวาง follice บนจุดที่กำหนดบนผิวของโพลีก้อน(หรือถ้าไม่ใช่ก็ใกล้เคียงที่สุด) ผมเอาสคริปมาโมนิดหน่อย เนื่องจากเขาเขียนใช้ Maya Python API 2.0 ผมเลยโมให้มันใช้ API ตัวเก่า(เผื่อไว้) และก็โมส่วนอื่นๆให้มันใช้ง่ายขึ้นสำหรับผม
ลองอ่านสคริปดูครับ ผมคอมเมนต์ไว้เกือบทุกบรรทัดแล้ว

วิธีใช้ก็ execute ทั้งฟังก์ชั่นก่อนทีนึง แล้ว เลือก vertex หรือ เลือก transform 2 อัน(อันแรกคือ mesh อันสองคือ locator หรือกรุ๊ปอะไรก็ได้) แล้วพิม
     createFollicleFromPosition()


ปล. จะใช้สคริปต้องมี PyMel นะเออ


THE LINK TO THE SCRIPT

No comments:

Post a Comment