def _RefreshTransformMatrix(self): wasNotified = False if hasattr(self, 'IsNotifyEnabled') and self.IsNotifyEnabled(): self.DisableNotify() wasNotified = True transform = mathCommon.ComposeMatrix(self.GetPosition(), self.GetRotation(), self.GetScale()) if type(self.transform) == tuple: self.transform = transform else: self.transform = util.ConvertTupleToTriMatrix(transform) if wasNotified: self.EnableNotify()
def SetupComponent(self, entity, component): positionComponent = entity.GetComponent('position') if positionComponent: scale = None if not entity.HasComponent('collisionMesh'): scale = component.scale component.renderObject.transform = util.ConvertTupleToTriMatrix( geo2.MatrixTransformation(None, None, scale, None, positionComponent.rotation, positionComponent.position)) scene = self.graphicClient.GetScene(entity.scene.sceneID) scene.AddDynamic(component.renderObject)
def GetRay(self, x, y): app = trinity.app aspect = float(app.width) / app.height fovTan = math.tan(self.fieldOfView * 0.5) dx = fovTan * (2.0 * x / app.width - 1.0) * aspect dy = fovTan * (1.0 - 2.0 * y / app.height) if trinity.IsRightHanded(): startPoint = trinity.TriVector(self.frontClip * dx, self.frontClip * dy, -self.frontClip) endPoint = trinity.TriVector(self.backClip * dx, self.backClip * dy, -self.backClip) else: startPoint = trinity.TriVector(self.frontClip * dx, self.frontClip * dy, self.frontClip) endPoint = trinity.TriVector(self.backClip * dx, self.backClip * dy, self.backClip) invViewMatrix = util.ConvertTupleToTriMatrix(self.viewMatrix.transform) invViewMatrix.Inverse() startPoint.TransformCoord(invViewMatrix) endPoint.TransformCoord(invViewMatrix) startPoint = (startPoint.x, startPoint.y, startPoint.z) endPoint = (endPoint.x, endPoint.y, endPoint.z) return (startPoint, endPoint)