TransformVect() 공개 메소드

public TransformVect ( IrrlichtNETCP.Vector3D &vect ) : IrrlichtNETCP.Vector3D
vect IrrlichtNETCP.Vector3D
리턴 IrrlichtNETCP.Vector3D
예제 #1
0
파일: Util.cs 프로젝트: yooyke/work
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
       }