Forum: Poser Python Scripting


Subject: Adv Object Import Utility (proposal)

Inception8 opened this issue on Jul 04, 2012 · 10 posts


bagginsbill posted Wed, 04 July 2012 at 12:34 PM

Note: Thread editor trashes my indentation and formatting - you should be able to make sense of this even though the Python engine may not.

Note: My Vector/Vertex class (not shown here) has x, y, z, u, v, and uvd (uv direction used in various obscure transformations) arguments.

 

UP = Vector(0, 1, 0)

DOWN = Vector(0, -1, 0)

WEST = Vector(-1, 0, 0)

EAST = Vector(1, 0, 0)

NORTH = Vector(0, 0, -1)

SOUTH = Vector(0, 0, 1)

ZEROVEC = Vector(0, 0, 0)

 

class Transform(object):

  def init(self, x = EAST, y = UP, z = SOUTH, w = ZEROVEC):

   self.x = x

   self.y = y

   self.z = z

   self.w = w

  def applyTo(self, v):

   w = self.w

   return Vertex(v.dot(self.x) + w.x, v.dot(self.y) + w.y, v.dot(self.z) + w.z, v.u + w.u, v.v + w.v, v.uvd)

def dsc(angle):

  angle = radians(angle)

  return sin(angle), cos(angle)

def XRot(angle):  s, c = dsc(angle)  return Transform(EAST, Vector(0, c, -s), Vector(0, s, c))

def YRot(angle):  s, c = dsc(angle)  return Transform(Vector(c, 0, s), UP, Vector(-s, 0, c))

def ZRot(angle):  s, c = dsc(angle)  return Transform(Vector(c, -s, 0), Vector(s, c, 0), SOUTH)

 

In my vector/vertex class the method dot does dot product.

 

 def dot(self, that):   return self.x * that.x + self.y * that.y + self.z * that.z


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)