Exemple #1
0
        public static void DrawCone(Matrix4F xform, Color color)
        {
            Matrix4F transposeOfInverse = new Matrix4F(xform);

            transposeOfInverse.Transpose(transposeOfInverse);
            transposeOfInverse.Invert(transposeOfInverse);

            GameEngine.DrawIndexedPrimitive(PrimitiveType.TriangleList,
                                            s_coneVertId,
                                            s_coneIndexId,
                                            0,
                                            s_coneIndexCount,
                                            0,
                                            color,
                                            xform,
                                            RenderFlag);
        }
Exemple #2
0
        public void SetProjection(float fov, float aspect, float hither, float yon, int width, int height)
        {
            nearClip = hither;
            farClip  = yon;

            // compute projectionMatrix
            float s          = 1.0f / (float)System.Math.Tan(fov / 2.0f);
            float fracHeight = 1.0f - (float)height / (float)height;

            projection.M11 = s;
            projection.M22 = (1.0f - fracHeight) * s * (float)width / (float)height;
            projection.M31 = 0.0f;
            projection.M32 = -fracHeight;
            projection.M33 = -(yon + hither) / (yon - hither);
            projection.M34 = -1.0f;
            projection.M41 = 0.0f;
            projection.M43 = -2.0f * yon * hither / (yon - hither);
            projection.M44 = 0.0f;

            projection.Transpose();

            BuildFrustum();
        }
Exemple #3
0
        /// <summary>
        /// Transforms this frustum by the given matrix</summary>
        /// <param name="m">Transformation matrix. Can be a nearly-general transform and include non-uniform
        /// scaling and shearing.</param>
        public void Transform(Matrix4F m)
        {
            Matrix4F transposeOfInverse = new Matrix4F(m);
            transposeOfInverse.Invert(transposeOfInverse);
            transposeOfInverse.Transpose(transposeOfInverse);

            for (int i = 0; i < 6; i++)
            {
                m.Transform(m_planes[i], transposeOfInverse, out m_planes[i]);
            }
        }
        //public static void Convert( ref OgreMatrix4 mat, out Mat4 result )
        //{
        //   result = new Mat4( mat.mat0, mat.mat1, mat.mat2, mat.mat3 );
        //   result.Transpose();
        //}

        public static unsafe void Convert(OgreMatrix4 *mat, out Matrix4F result)
        {
            result = new Matrix4F(mat->mat0, mat->mat1, mat->mat2, mat->mat3);
            result.Transpose();
        }
Exemple #5
0
 public static void DrawCone(Matrix4F xform, Color color)
 {            
     Matrix4F transposeOfInverse = new Matrix4F(xform);
     transposeOfInverse.Transpose(transposeOfInverse);
     transposeOfInverse.Invert(transposeOfInverse);
     
     GameEngine.DrawIndexedPrimitive(PrimitiveType.TriangleList,
        s_coneVertId,
        s_coneIndexId,
        0,
        s_coneIndexCount,
        0,
        color,
        xform,
        RenderFlag);
 }