Ejemplo n.º 1
0
 def PickObject(self, x, y):
     if self.sceneManager.GetActiveScene() != self.renderScene:
         return
     rescale = 1.0 / 10000.0
     projection = trinity.TriProjection()
     projection.PerspectiveFov(trinity.GetFieldOfView(),
                               trinity.GetAspectRatio(),
                               trinity.GetFrontClip(),
                               trinity.GetBackClip())
     view = trinity.TriView()
     view.transform = trinity.GetViewTransform()
     scaling, rotation, translation = geo2.MatrixDecompose(
         self.transform.worldTransform)
     pZ = geo2.Vec3Transform((0, 0, 1), self.transform.worldTransform)
     surfaceNormal = geo2.Subtract(pZ, translation)
     cameraZ = geo2.Vector(view.transform[0][2], view.transform[1][2],
                           view.transform[2][2])
     if geo2.Vec3Dot(surfaceNormal, cameraZ) < 0:
         return
     self.renderObject.translation = geo2.Vec3Scale(translation, rescale)
     self.renderObject.rotation = rotation
     self.renderObject.scaling = geo2.Vec3Scale(scaling, rescale)
     scaling, rotation, translation = geo2.MatrixDecompose(view.transform)
     translation = geo2.Vec3Scale(translation, rescale)
     view.transform = geo2.MatrixTransformation(None, None, scaling, None,
                                                rotation, translation)
     return self.renderObject.PickObject(x, y, projection, view,
                                         trinity.device.viewport)
Ejemplo n.º 2
0
def GetEntityTrajectoryPosition(modelReference, animationNetwork):
    mat = geo2.MatrixTransformation((0, 0, 0), (0, 0, 0, 1), (modelReference.scaling[0], modelReference.scaling[1], modelReference.scaling[2]), (0, 0, 0), (modelReference.rotation[0],
     modelReference.rotation[1],
     modelReference.rotation[2],
     modelReference.rotation[3]), (modelReference.translation[0], modelReference.translation[1], modelReference.translation[2]))
    matTuple = mat[0] + mat[1] + mat[2] + mat[3]
    accumulated = animationNetwork.GetAccumulatedTrajectory(matTuple)[0]
    return accumulated
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 def SetupFakeAudioTransformLocation(self, shipPosition):
     self.fakeAudioTransform.translationCurve = trinity.TriVectorCurve()
     viewTransformOffset = geo2.MatrixTransformation(
         (0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0),
         (0.0, 0.0, 0.0), self.sceneRotation, self.sceneTranslation)
     viewTransformInverse = geo2.MatrixInverse(viewTransformOffset)
     newAudioEmitterPosition = geo2.Vec3TransformCoord(
         shipPosition, viewTransformInverse)
     self.fakeAudioTransform.translationCurve.value = newAudioEmitterPosition
     distance = geo2.Vec3Distance((0, 0, 0), newAudioEmitterPosition)
     gallenteHangarBaseline = 561.28692627
     audioScaleFactor = distance / gallenteHangarBaseline
     self.generalAudioEntity.SetAttenuationScalingFactor(audioScaleFactor)
Ejemplo n.º 5
0
 def SetupComponent(self, entity, component):
     positionComponent = entity.GetComponent('position')
     if positionComponent:
         component.renderObject.position = positionComponent.position
         if hasattr(component.renderObject, 'SetRotationYawPitchRoll'):
             component.renderObject.SetRotationYawPitchRoll(
                 geo2.QuaternionRotationGetYawPitchRoll(
                     positionComponent.rotation))
     if component.useBoundingBox:
         rotQuat = geo2.QuaternionRotationSetYawPitchRoll(
             component.bbRot[1], component.bbRot[0], component.bbRot[2])
         mat = geo2.MatrixTransformation(None, None, component.bbScale,
                                         None, rotQuat, component.bbPos)
         component.renderObject.boundingBox.transform = mat
     self.ApplyShadowCasterType(entity)
     self.ApplyPerformanceLevelLightDisable(entity)
Ejemplo n.º 6
0
    def SetUpChildExplosion(explosionModel, explosionLocatorSets):
        explosionChildren = explosionModel.Find('trinity.EveChildExplosion', 2)
        if explosionLocatorSets is not None:
            transforms = []
            locators = [(each[0], each[1]) for each in (
                explosionLocatorSets.locators if explosionLocatorSets else [])]
            random.shuffle(locators)
            for position, direction in locators:
                rotation = geo2.QuaternionRotationArc((0, 1, 0), direction)
                transform = geo2.MatrixTransformation(
                    (0, 0, 0), (0, 0, 0, 1), (1, 1, 1), (0, 0, 0), rotation,
                    position)
                transforms.append(transform)

            for each in explosionChildren:
                each.SetLocalExplosionTransforms(transforms)

        for each in explosionChildren:
            each.Play()
Ejemplo n.º 7
0
 def SetupComponent(self, entity, component):
     """
     Gets called once all components have been prepared.
     Use this to setup stuff which references other components
     """
     positionComponent = entity.GetComponent('position')
     if positionComponent:
         component.renderObject.position = positionComponent.position
         if hasattr(component.renderObject, 'SetRotationYawPitchRoll'):
             component.renderObject.SetRotationYawPitchRoll(
                 geo2.QuaternionRotationGetYawPitchRoll(
                     positionComponent.rotation))
     if component.useBoundingBox:
         rotQuat = geo2.QuaternionRotationSetYawPitchRoll(
             component.bbRot[1], component.bbRot[0], component.bbRot[2])
         mat = geo2.MatrixTransformation(None, None, component.bbScale,
                                         None, rotQuat, component.bbPos)
         component.renderObject.boundingBox.transform = mat
     self.ApplyShadowCasterType(entity)
     self.ApplyPerformanceLevelLightDisable(entity)
    def SetUpChildExplosion(explosionModel,
                            spaceObjectModel=None,
                            explosionSorting='random',
                            initialLocatorIdx=-1):
        explosionChildren = explosionModel.Find('trinity.EveChildExplosion', 2)
        if spaceObjectModel is not None:
            explosionLocatorSets = None
            if hasattr(spaceObjectModel, 'locatorSets'):
                explosionLocatorSets = spaceObjectModel.locatorSets.FindByName(
                    'explosions')
            explosionLocators = explosionLocatorSets.locators if explosionLocatorSets else spaceObjectModel.damageLocators
            locators = [(each[0], each[1]) for each in explosionLocators]
            transforms = []
            if explosionSorting == FROM_CENTER_SORTING:
                point = spaceObjectModel.GetBoundingSphereCenter()
                radius = spaceObjectModel.GetBoundingSphereRadius() * 0.2
                locators.sort(key=lambda explosion: geo2.Vec3Distance(
                    point, explosion[0]) +
                              (random.random() - random.random()) * radius)
            elif explosionSorting == FROM_LOCATOR_SORTING:
                if initialLocatorIdx < 0 or initialLocatorIdx > len(locators):
                    initialLocatorIdx = random.randint(0, len(locators) - 1)
                point = locators[initialLocatorIdx][0]
                locators.sort(key=lambda explosion: geo2.Vec3Distance(
                    point, explosion[0]))
            else:
                random.shuffle(locators)
            for position, direction in locators:
                rotation = direction
                transform = geo2.MatrixTransformation(
                    (0, 0, 0), (0, 0, 0, 1), (1, 1, 1), (0, 0, 0), rotation,
                    position)
                transforms.append(transform)

            for each in explosionChildren:
                each.SetLocalExplosionTransforms(transforms)
Ejemplo n.º 9
0
def ComposeMatrix(pos, rot, scale):
    return geo2.MatrixTransformation(None, None, scale, None, rot, pos)