TransformVect() public method

public TransformVect ( IrrlichtNETCP.Vector3D &vect ) : IrrlichtNETCP.Vector3D
vect IrrlichtNETCP.Vector3D
return IrrlichtNETCP.Vector3D
Beispiel #1
0
        public static void CreateBox3DFromNode(SceneNode node, out Box3D box)
        {
            float minX = float.MaxValue;
            float minY = float.MaxValue;
            float minZ = float.MaxValue;
            float maxX = float.MinValue;
            float maxY = float.MinValue;
            float maxZ = float.MinValue;

            Vector3D[] edges;
            node.BoundingBox.GetEdges(out edges);
            Matrix4 m = new Matrix4();
            m.RotationDegrees = node.Rotation;
            m.Translation = node.Position;
            for (int i = 0; i < edges.Length; i++)
            {
                Vector3D v = edges[i] * node.Scale;
                v = m.TransformVect(ref v);

                if (v.X < minX)
                    minX = v.X;

                if (v.Y < minY)
                    minY = v.Y;

                if (v.Z < minZ)
                    minZ = v.Z;

                if (v.X > maxX)
                    maxX = v.X;

                if (v.Y > maxY)
                    maxY = v.Y;

                if (v.Z > maxZ)
                    maxZ = v.Z;
            }

            box = new Box3D(minX, minY, minZ, maxX, maxY, maxZ);
        }
        public override void Render()
        {
            driver.SetTransform(TransformationState.World, AbsoluteTransformation);
            // Figure out quads based on start/end points.
            Matrix4 m = new Matrix4();
            m.RotationDegrees = getTargetAngle(vStart, vEnd);
            Vector3D vUp = new Vector3D(0, 1, 0);
            Vector3D vRight = new Vector3D(-1, 0, 0);
            m.TransformVect(ref vRight);
            m.TransformVect(ref vUp);

            // Draw the first cross
            IrrQuad beam = new IrrQuad();
            beam.verts[0] = new Vertex3D(vStart + vUp * flScale, new Vector3D(1, 1, 0), beamColor, new Vector2D(0, 1));
            beam.verts[1] = new Vertex3D(vStart + vUp * -flScale, new Vector3D(1, 0, 0), beamColor, new Vector2D(1, 1));
            beam.verts[2] = new Vertex3D(vEnd + vUp * -flScale, new Vector3D(0, 1, 1), beamColor, new Vector2D(1, 0));
            beam.verts[3] = new Vertex3D(vEnd + vUp * flScale, new Vector3D(0, 0, 1), beamColor, new Vector2D(0, 0));
            DrawQuad(beam);

            // Draw the second cross.
            beam.verts[0] = new Vertex3D(vStart + vRight * flScale, new Vector3D(1, 1, 0), beamColor, new Vector2D(0, 1));
            beam.verts[1] = new Vertex3D(vStart + vRight * -flScale, new Vector3D(1, 0, 0), beamColor, new Vector2D(1, 1));
            beam.verts[2] = new Vertex3D(vEnd + vRight * -flScale, new Vector3D(0, 1, 1), beamColor, new Vector2D(1, 0));
            beam.verts[3] = new Vertex3D(vEnd + vRight * flScale, new Vector3D(0, 0, 1), beamColor, new Vector2D(0, 0));
            DrawQuad(beam);

            if (DebugDataVisible == DebugSceneType.BoundingBox)
                driver.Draw3DBox(BoundingBox, Color.White);
        }
        public void RecalculateBoundingBox()
        {
            Matrix4 m = new Matrix4();
            m.RotationDegrees = getTargetAngle(vStart, vEnd);
            Vector3D vUp = new Vector3D(0, 1, 0);
            Vector3D vRight = new Vector3D(-1, 0, 0);
            m.TransformVect(ref vRight);
            m.TransformVect(ref vUp);
            Box.MinEdge = (vStart + vUp * flScale);
            Box.MaxEdge = (vEnd + vRight * -flScale);
            Box.AddInternalPoint(vStart + vUp * flScale);
            Box.AddInternalPoint(vStart + vUp * -flScale);
            Box.AddInternalPoint(vEnd + vUp * -flScale);
            Box.AddInternalPoint(vEnd + vUp * flScale);

            Box.AddInternalPoint(vStart + vRight * flScale);
            Box.AddInternalPoint(vStart + vRight * -flScale);
            Box.AddInternalPoint(vEnd + vRight * -flScale);
            Box.AddInternalPoint(vEnd + vRight * flScale);
       }