Пример #1
0
 def CreateViewMatrix(self, location, rotation):
     cameraTranslation = trinity.TriMatrix()
     cameraRotation = trinity.TriMatrix()
     x, y, z = location
     cameraTranslation.Translation(x, y, z)
     cameraRotation.RotationYawPitchRoll(rotation[0], rotation[1], rotation[2])
     cameraFinal = cameraRotation
     cameraFinal.Multiply(cameraTranslation)
     cameraFinal.Inverse()
     return cameraFinal
Пример #2
0
 def CreateViewMatrix(self, location, rotation):
     """
         Creates a camera view matrix based on input.
         location-> trinity.TriVector(x, y, z) or (x, y, z)
         rotation=> tuple(yaw, pitch, roll)
     """
     cameraTranslation = trinity.TriMatrix()
     cameraRotation = trinity.TriMatrix()
     x, y, z = location
     cameraTranslation.Translation(x, y, z)
     cameraRotation.RotationYawPitchRoll(rotation[0], rotation[1],
                                         rotation[2])
     cameraFinal = cameraRotation
     cameraFinal.Multiply(cameraTranslation)
     cameraFinal.Inverse()
     return cameraFinal
Пример #3
0
def ConvertTupleToTriMatrix(tupleMatrix):
    return trinity.TriMatrix(tupleMatrix[0][0], tupleMatrix[0][1],
                             tupleMatrix[0][2], tupleMatrix[0][3],
                             tupleMatrix[1][0], tupleMatrix[1][1],
                             tupleMatrix[1][2], tupleMatrix[1][3],
                             tupleMatrix[2][0], tupleMatrix[2][1],
                             tupleMatrix[2][2], tupleMatrix[2][3],
                             tupleMatrix[3][0], tupleMatrix[3][1],
                             tupleMatrix[3][2], tupleMatrix[3][3])
Пример #4
0
def GeoToTri(obj):
    if len(obj) == 3:
        return trinity.TriVector(*obj)
    if len(obj) == 4:
        if isinstance(obj[0], tuple):
            tempTuple = obj[0] + obj[1] + obj[2] + obj[3]
            return trinity.TriMatrix(*tempTuple)
        else:
            return trinity.TriQuaternion(*obj)
    else:
        raise TypeError('Unsupported type')
Пример #5
0
    def FindHierarchicalBoundingBox(self,
                                    transform,
                                    printout,
                                    parentMat=trinity.TriMatrix(),
                                    indent='',
                                    minx=1e+100,
                                    maxx=-1e+100,
                                    miny=1e+100,
                                    maxy=-1e+100,
                                    minz=1e+100,
                                    maxz=-1e+100,
                                    parentScale=trinity.TriVector(
                                        1.0, 1.0, 1.0)):
        transform.Update(blue.os.GetSimTime())
        if hasattr(transform, 'translation') and transform.__typename__ in (
                'TriTransform', 'TriSplTransform', 'TriLODGroup'):
            if transform.__typename__ == 'TriTransform':
                if transform.transformBase != trinity.TRITB_OBJECT:
                    return (minx, maxx, miny, maxy, minz, maxz)
            if hasattr(transform, 'object') and hasattr(
                    transform.object,
                    'vertexRes') and transform.object.vertexRes is not None:
                damin = transform.object.vertexRes.meshBoxMin.CopyTo()
                damax = transform.object.vertexRes.meshBoxMax.CopyTo()
                damin.TransformCoord(transform.localTransform)
                damax.TransformCoord(transform.localTransform)
                damin.TransformCoord(parentMat)
                damax.TransformCoord(parentMat)
                minx = min(minx, min(damin.x, damax.x))
                maxx = max(maxx, max(damin.x, damax.x))
                miny = min(miny, min(damin.y, damax.y))
                maxy = max(maxy, max(damin.y, damax.y))
                minz = min(minz, min(damin.z, damax.z))
                maxz = max(maxz, max(damin.z, damax.z))
            newmat = transform.localTransform.CopyTo()
            newmat.Multiply(parentMat)
            for child in transform.children:
                indent = indent + '  '
                minx, maxx, miny, maxy, minz, maxz = self.FindHierarchicalBoundingBox(
                    child, printout, newmat, indent, minx, maxx, miny, maxy,
                    minz, maxz, parentScale)

        return (minx, maxx, miny, maxy, minz, maxz)