Example #1
0
    def calcTransform(self, recursive=True):

        if self.parent:
            self.transform = self.parent.transform[:]
        else:
            self.transform = makeUnit()

        m = makeTranslation(*self.offset)
        self.transform = mmul(self.transform, m)

        m = euler2matrix(self.rotation, "syxz")
        self.transform = mmul(self.transform, m)

        self.normalTransform = _transpose(invTransform(self.transform), 4, 4)

        if recursive:
            for child in self.children:
                child.calcTransform(recursive)
Example #2
0
 def calcTransform(self, recursive=True):
   
     if self.parent:
         self.transform = self.parent.transform[:]
     else:
         self.transform = makeUnit()
         
     m = makeTranslation(*self.offset)
     self.transform = mmul(self.transform, m)
     
     m = euler2matrix(self.rotation, "syxz")
     self.transform = mmul(self.transform, m)
     
     self.normalTransform = _transpose(invTransform(self.transform), 4, 4)
     
     if recursive:
         for child in self.children:
             child.calcTransform(recursive)
 def updateFrame(self, frame, scale=0.10):
     
   if self.parent:
       self.transform = self.parent.transform[:]
   else:
       self.transform = makeUnit() #makeScale(scale)
   
   m = makeTranslation(self.offset[0], self.offset[1], self.offset[2])
   self.transform = mmul(self.transform, m) #parent postmultiply with offset
   
   if frame >= 0 and frame < len(self.frames):
       index = 0
     
       Ryxz = [0.0, 0.0, 0.0]
       Txyz = [0.0, 0.0, 0.0]
       for index, channel in enumerate(self.channels):
           if channel == 'Xposition':
               Txyz[0] = scale*self.frames[frame][index]
           elif channel == 'Yposition':
               Txyz[1] = scale*self.frames[frame][index]
           elif channel == 'Zposition':
               Txyz[2] = scale*self.frames[frame][index]
             
           if channel == 'Xrotation':
               Ryxz[1] = self.frames[frame][index] * degree2rad
           elif channel == 'Yrotation':
               Ryxz[0] = self.frames[frame][index] * degree2rad
           elif channel == 'Zrotation':
               Ryxz[2] = self.frames[frame][index] * degree2rad
       #self.translation = Txyz[:]
       self.rotation = Ryxz[:]
       m = euler2matrix(Ryxz, "syxz")
       m[3], m[7], m[11] = Txyz[0], Txyz[1], Txyz[2] 
       self.transform = mmul(self.transform, m) # parent post multiply with transformations
   
   for child in self.children:
       child.updateFrame(frame)