Previous Thread  Next Thread

chat icon How to Apply Size/Rotation using python

truenoeks

Posted: Wed May 14, 2003 8:29 pm
Joined: 16 Oct 2002
Posts: 8
How can one perform the Apply Size/Rotation function using Python?

Thanx

Truenoeks

Question Exclamation Exclamation Question
Reply with quote


Anthony

Posted: Sat Jun 28, 2003 9:36 pm
Joined: 25 Oct 2002
Posts: 16
I've done this for my LightWave IO script. Here's a function that should be called for each vertex with the object's matrix:

Code:
# =======================
# === Apply Transform ===
# =======================
def apply_transform(verts, matrix):
   x, y, z = verts
   xloc, yloc, zloc = matrix[3][0], matrix[3][1], matrix[3][2]
   xcomponent = x*matrix[0][0] + y*matrix[1][0] + z*matrix[2][0] + xloc
   ycomponent = x*matrix[0][1] + y*matrix[1][1] + z*matrix[2][1] + yloc
   zcomponent = x*matrix[0][2] + y*matrix[1][2] + z*matrix[2][2] + zloc
   verts = [xcomponent, ycomponent, zcomponent]
   return verts


Call it like so:
Code:
for i in range(len(mesh.verts)):
   x, y, z = apply_transform(mesh.verts[i].co, matrix)
Reply with quote


truenoeks

Posted: Tue Jul 01, 2003 8:21 pm
Joined: 16 Oct 2002
Posts: 8
Thanks. I really appreciate it!

Laughing
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group