Example #1
0
        public override void LoadContent()
        {
            MyRender.Log.WriteLine("MyDebugDraw.LoadContent() - START");
            MyRender.Log.IncreaseIndent();

            //  Line
            m_verticesLine = new MyVertexFormatPositionColor[2];
            m_verticesLine[0] = new MyVertexFormatPositionColor();
            m_verticesLine[1] = new MyVertexFormatPositionColor();

            //  Triangle
            m_triangleVertices = new MyVertexFormatPositionColor[3];
            m_triangleVertices[0] = new MyVertexFormatPositionColor();
            m_triangleVertices[1] = new MyVertexFormatPositionColor();
            m_triangleVertices[2] = new MyVertexFormatPositionColor();

            m_lineBatch = new MyLineBatch(Matrix.Identity, Matrix.Identity, 1024);

            m_frustumCorners = new Vector3D[8];
            m_vertices = new List<Vector3>(32);
            m_indices = new List<short>(128);

            m_modelBoxHiRes = MyRenderModels.GetModel("Models\\Debug\\BoxHiRes.mwm");
            m_modelBoxLowRes = MyRenderModels.GetModel("Models\\Debug\\BoxLowRes.mwm");

            //TODO: temporary replaced because Sphere is unable to load because of some XNA shit
            m_modelSphere = MyRenderModels.GetModel("Models\\Debug\\Sphere_low.mwm");
            //m_modelSphere = MyModels.GetModel("Models2\\Debug\\Sphere");
            m_modelLightSphere = MyRenderModels.GetModel("Models\\Debug\\Sphere_low.mwm");
            m_modelCone = MyRenderModels.GetModel("Models\\Debug\\Cone.mwm");
            m_modelHemisphere = MyRenderModels.GetModel("Models\\Debug\\Hemisphere.mwm");
            m_modelHemisphereLowRes = MyRenderModels.GetModel("Models\\Debug\\Hemisphere_low.mwm");
            m_modelCapsule = MyRenderModels.GetModel("Models\\Debug\\Capsule.mwm");
            m_modelCylinderLow = MyRenderModels.GetModel("Models\\Debug\\Cylinder_Low.mwm");


            MyRender.Log.DecreaseIndent();
            MyRender.Log.WriteLine("MyDebugDraw.LoadContent() - END");
        }
Example #2
0
        public static void DrawTriangle(Vector3D vertex1, Vector3D vertex2, Vector3D vertex3, Color color1, Color color2, Color color3, bool smooth, bool depthRead)
        {
            if (!smooth)
            {
                MyDebugDraw.DrawLine3D(ref vertex1, ref vertex2, ref color1, ref color2, depthRead);
                MyDebugDraw.DrawLine3D(ref vertex2, ref vertex3, ref color2, ref color3, depthRead);
                MyDebugDraw.DrawLine3D(ref vertex3, ref vertex1, ref color3, ref color1, depthRead);
            }
            else
            {
                Device graphicsDevice = MyRender.GraphicsDevice;

                if (depthRead)
                    DepthStencilState.DepthRead.Apply();
                else
                    DepthStencilState.None.Apply();

                BlendState.NonPremultiplied.Apply();
                MyStateObjects.BiasedRasterizerCullNone_DebugDraw.Apply();

                //  Create triangleVertexes vertices
                m_triangleVertices[0] = new MyVertexFormatPositionColor((Vector3)vertex1, color1.ToVector4());
                m_triangleVertices[1] = new MyVertexFormatPositionColor((Vector3)vertex2, color2.ToVector4());
                m_triangleVertices[2] = new MyVertexFormatPositionColor((Vector3)vertex3, color3.ToVector4());

                var effect = (MyEffectModelsDiffuse)MyRender.GetEffect(MyEffects.ModelDiffuse);

                // Initialise the effect
                effect.SetWorldMatrix(Matrix.Identity);
                effect.SetProjectionMatrix(MyRenderCamera.ProjectionMatrix);
                effect.SetViewMatrix((Matrix)MyRenderCamera.ViewMatrix);
                effect.SetDiffuseColor(Vector3.One);
                effect.SetTechnique(MyEffectModelsDiffuse.Technique.PositionColor);
                graphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration;

                // Draw the line
                effect.Begin();
                graphicsDevice.VertexDeclaration = MyVertexFormatPositionColor.VertexDeclaration;
                graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 1, m_triangleVertices);
                effect.End();
            }
        }