def testP(self): K, RT = Calibrate.decomposeKRT(self.P()) print ('K', K, self.K()) print ('RT', RT, self.RT()) print (self.cameraFovX,self.cameraKox,self.cameraKoy,self.cameraKsquare,self.cameraKskew) print ((self.cameraPan, self.cameraTilt, self.cameraRoll), self.cameraT, self.cameraInterest) print ('cf') print (Calibrate.decomposeK(K)) print (Calibrate.decomposeRT(RT, self.cameraInterest, False))
def setRT(self, RT, setInterest = True): '''Set the view to match the given extrinsic matrix.''' (self.cameraPan, self.cameraTilt, self.cameraRoll), self.cameraT, self.cameraInterest = Calibrate.decomposeRT(RT, self.cameraInterest, setInterest) if self.cameraInterest == 0: self.cameraInterest = 1e-6
def generate_skeleton_lods(skelDict, Gs=None): # TODO: First iteration: Improve code and optimise # TODO: Contains hard coded values (generalise.. actually probably better to use a callback.. lodgenerator visitor) from GCore import Calibrate vs, tris, orientation, names = [], [], [], [] if 'jointWidth' not in skelDict: return jointWidth = skelDict['jointWidth'] jointHeightMultiplier = 1.3 if Gs is None: Gs = skelDict['Gs'] Bs = skelDict['Bs'] lodVerts = skelDict['verts'] lodTris = skelDict['tris'] for jointIdx, jointName in enumerate(skelDict['jointNames']): if 'Free' in jointName: continue jointGs = Gs[jointIdx] jointBs = Bs[jointIdx] whichAxis = np.where(jointBs == 0)[0] R, T, _ = Calibrate.decomposeRT(jointGs, 1, False) jointMeshScale = jointBs.copy() if jointName == 'root': jointMeshScale = jointMeshScale * 1.4 elif 'Spine' in jointName: jointMeshScale = jointMeshScale * 1.2 jointMeshScale[whichAxis] = jointWidth[jointName] if jointName == 'VSS_Chest': jointMeshScale[0] = jointWidth[jointName][0] jointMeshScale[1] = 120. jointMeshScale[2] = jointWidth[jointName][1] axisToggle = np.array([1, 1, 1], dtype=np.float32) axisToggle[whichAxis] = 0.0 translations = jointMeshScale / 2 if jointName == 'VSS_Chest': translations[0:1] = 0 offset = translations * axisToggle boneVerts = lodVerts.copy() for vi, v in enumerate(boneVerts): v = v * jointMeshScale if jointName in ['root']: v = v - offset v = np.dot( Calibrate.composeR( np.array([0, 0, 90], dtype=np.float32)), v.T) else: v = v + offset v = np.dot(jointGs, np.hstack((v, 1)).T) boneVerts[vi] = v[:3] tris.append(lodTris + len(vs) * 8) vs.append(boneVerts) boneLength = jointBs[np.where(jointBs != 0)[0]] orientation.append( 0 if boneLength.any() and boneLength[0] < 0 else 1) names.append(jointName) v = np.concatenate((vs)) t = np.concatenate((tris)).tolist() lodAttrs = { 'triangles': v[t], 'verts': v, 'tris': t, 'faces': tris, 'names': names } skelDict['visibilityLod'] = lodAttrs return v, t, vs, tris, orientation, names