Exemple #1
0
def CameraFacingMatrix(objtransform):
    viewMat = trinity.GetViewTransform()
    objInv = geo2.MatrixInverse(objtransform)
    viewInv = geo2.MatrixInverse(viewMat)
    viewInv = geo2.MatrixMultiply(viewInv, objInv)
    rmat = geo2.MatrixRotationX(math.pi * 0.5)
    rmat = geo2.MatrixMultiply(rmat, viewInv)
    rmat = (rmat[0], rmat[1], rmat[2], (0.0, 0.0, 0.0, rmat[3][3]))
    return rmat
 def GenGeometry(self):
     rotateMat = geo2.MatrixRotationZ(-math.pi / 2.0)
     transform = geo2.MatrixTranslation(0.0, 1.0, 0.0)
     transform = geo2.MatrixMultiply(transform, rotateMat)
     c_tris = geo2.Vec3TransformCoordArray(dungeonEditorToolGeometry.CONE_TRIS, transform)
     xTransAreaCone = dungeonEditorToolGeometry.area('x', dungeonEditorToolGeometry.RED)
     xTransAreaCone.AddToSolidSet(c_tris)
     xTransAreaAxis = dungeonEditorToolGeometry.area('x', dungeonEditorToolGeometry.RED)
     xTransAreaAxis.AddToLineSet([(0.0, 0.0, 0.0), (1.0, 0.0, 0.0)])
     t = dungeonEditorToolGeometry.GetSolidAroundLine([(0.3, 0.0, 0.0), (1.0, 0.0, 0.0)], 0.08)
     xTransAreaAxis.AddToPickingSet(t)
     transform = geo2.MatrixTranslation(0.0, 1.0, 0.0)
     c_tris = geo2.Vec3TransformCoordArray(dungeonEditorToolGeometry.CONE_TRIS, transform)
     yTransAreaCone = dungeonEditorToolGeometry.area('y', dungeonEditorToolGeometry.GREEN)
     yTransAreaCone.AddToSolidSet(c_tris)
     yTransAreaAxis = dungeonEditorToolGeometry.area('y', dungeonEditorToolGeometry.GREEN)
     yTransAreaAxis.AddToLineSet([(0.0, 0.0, 0.0), (0.0, 1.0, 0.0)])
     t = dungeonEditorToolGeometry.GetSolidAroundLine([(0.0, 0.3, 0.0), (0.0, 1.0, 0.0)], 0.08)
     yTransAreaAxis.AddToPickingSet(t)
     transform = geo2.MatrixTranslation(0.0, 1.0, 0.0)
     rotateMat = geo2.MatrixRotationX(math.pi / 2.0)
     transform = geo2.MatrixMultiply(transform, rotateMat)
     c_tris = geo2.Vec3TransformCoordArray(dungeonEditorToolGeometry.CONE_TRIS, transform)
     zTransAreaCone = dungeonEditorToolGeometry.area('z', dungeonEditorToolGeometry.BLUE)
     zTransAreaCone.AddToSolidSet(c_tris)
     zTransAreaAxis = dungeonEditorToolGeometry.area('z', dungeonEditorToolGeometry.BLUE)
     zTransAreaAxis.AddToLineSet([(0.0, 0.0, 0.0), (0.0, 0.0, 1.0)])
     t = dungeonEditorToolGeometry.GetSolidAroundLine([(0.0, 0.0, 0.3), (0.0, 0.0, 1.0)], 0.08)
     zTransAreaAxis.AddToPickingSet(t)
     wTransAreaPlane = dungeonEditorToolGeometry.area('w', dungeonEditorToolGeometry.CYAN)
     wTransAreaPlane.AddToLineSet(dungeonEditorToolGeometry.CIRCLE_POINTS_QUART)
     wTransAreaPlane._lineset.viewOriented = True
     picking_tris = dungeonEditorToolGeometry.GenCircleTriangles(0.25)
     if not trinity.IsRightHanded():
         picking_tris.reverse()
     wTransAreaPlane.AddToPickingSet(picking_tris)
     translationGeo = dungeonEditorToolGeometry.geometry(self.primitiveScene)
     translationGeo.AppendArea(wTransAreaPlane)
     translationGeo.AppendArea(xTransAreaCone)
     translationGeo.AppendArea(xTransAreaAxis)
     translationGeo.AppendArea(yTransAreaCone)
     translationGeo.AppendArea(yTransAreaAxis)
     translationGeo.AppendArea(zTransAreaCone)
     translationGeo.AppendArea(zTransAreaAxis)
     self.cones.append(xTransAreaCone)
     self.cones.append(yTransAreaCone)
     self.cones.append(zTransAreaCone)
     self.axes.append(xTransAreaAxis)
     self.axes.append(yTransAreaAxis)
     self.axes.append(zTransAreaAxis)
     return translationGeo
Exemple #3
0
 def GenGeometry(self):
     """
     Generates the geometry for the rotation tool.
     """
     xCircleAreas = []
     yCircleAreas = []
     zCircleAreas = []
     if not trinity.IsRightHanded():
         effectPath = 'res:/Graphics/Effect/Managed/Utility/LinesRotationToolLH.fx'
     else:
         effectPath = 'res:/Graphics/Effect/Managed/Utility/LinesRotationTool.fx'
     unit_circle = dungeonEditorToolGeometry.GenCirclePoints(1.0, 60)
     mat = geo2.MatrixRotationY(math.pi / 2)
     x_circle = geo2.Vec3TransformCoordArray(unit_circle, mat)
     xRotationHandleCircle = dungeonEditorToolGeometry.area(
         'x', dungeonEditorToolGeometry.RED)
     xRotationHandleCircle.AddToLineSet(x_circle, True)
     xRotationHandleCircle._lineset.effect.effectFilePath = effectPath
     mat = geo2.MatrixRotationX(math.pi / 2)
     y_circle = geo2.Vec3TransformCoordArray(unit_circle, mat)
     yRotationHandleCircle = dungeonEditorToolGeometry.area(
         'y', dungeonEditorToolGeometry.GREEN)
     yRotationHandleCircle.AddToLineSet(y_circle, True)
     yRotationHandleCircle._lineset.effect.effectFilePath = effectPath
     zRotationHandleCircle = dungeonEditorToolGeometry.area(
         'z', dungeonEditorToolGeometry.BLUE)
     zRotationHandleCircle.AddToLineSet(unit_circle, True)
     zRotationHandleCircle._lineset.effect.effectFilePath = effectPath
     w_circle = dungeonEditorToolGeometry.GenCirclePoints(1.2, 60)
     wArea = dungeonEditorToolGeometry.area('w',
                                            dungeonEditorToolGeometry.CYAN)
     wArea.AddToLineSet(w_circle, True)
     wArea._lineset.viewOriented = True
     wwArea = dungeonEditorToolGeometry.area(
         'ww', dungeonEditorToolGeometry.LIGHT_GRAY)
     wwArea.AddToLineSet(dungeonEditorToolGeometry.GenCirclePoints(1.0, 60))
     wwArea._lineset.viewOriented = True
     picking_tris = dungeonEditorToolGeometry.GenCircleTriangles(1.0, 60)
     if not trinity.IsRightHanded():
         picking_tris.reverse()
     wwArea.AddToPickingSet(picking_tris)
     rotationGeo = dungeonEditorToolGeometry.geometry(self.primitiveScene)
     rotationGeo.AppendArea(xRotationHandleCircle)
     rotationGeo.AppendArea(yRotationHandleCircle)
     rotationGeo.AppendArea(zRotationHandleCircle)
     rotationGeo.AppendArea(wArea)
     rotationGeo.AppendArea(wwArea)
     return rotationGeo