示例#1
0
        public override void DebugDrawInvalidTriangles()
        {
            base.DebugDrawInvalidTriangles();

            MyRenderComponentCubeGrid gridRender = m_cubeGrid.Render;
            MyCubeGridRenderData      data       = gridRender.RenderData;

            foreach (var cell in data.Cells)
            {
                HashSet <MyCubePart> parts = cell.Value.CubeParts;
                foreach (var part in parts)
                {
                    MyModel model = part.Model;
                    if (model != null)
                    {
                        int triCount = model.GetTrianglesCount();
                        for (int i = 0; i < triCount; ++i)
                        {
                            var triangle = model.GetTriangle(i);
                            if (MyUtils.IsWrongTriangle(model.GetVertex(triangle.I0), model.GetVertex(triangle.I1), model.GetVertex(triangle.I2)))
                            {
                                Vector3 v0 = Vector3.Transform(model.GetVertex(triangle.I0), (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                                Vector3 v1 = Vector3.Transform(model.GetVertex(triangle.I1), (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                                Vector3 v2 = Vector3.Transform(model.GetVertex(triangle.I2), (Matrix)m_cubeGrid.PositionComp.WorldMatrix);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(v0, v1, Color.Purple, Color.Purple, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(v1, v2, Color.Purple, Color.Purple, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(v2, v0, Color.Purple, Color.Purple, false);
                                Vector3 center = (v0 + v1 + v2) / 3f;
                                VRageRender.MyRenderProxy.DebugDrawLine3D(center, center + Vector3.UnitX, Color.Yellow, Color.Yellow, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(center, center + Vector3.UnitY, Color.Yellow, Color.Yellow, false);
                                VRageRender.MyRenderProxy.DebugDrawLine3D(center, center + Vector3.UnitZ, Color.Yellow, Color.Yellow, false);
                            }
                        }
                    }
                }
            }
        }
 public MyRenderComponentCubeGrid()
 {
     m_renderData = new MyCubeGridRenderData(this);
 }