Example #1
0
        /// <summary>
        /// DrawSelectedBounding
        /// </summary>
        private void DrawSelectedBounding()
        {
            if (MyConfig.EditorDisplayUnselectedBounding)
            {
                Vector4 color = new Vector4(0.6f, 0.6f, 0.6f, 0.2f);
                foreach (MyEntity entity in MyEntities.GetEntities())
                {
                    entity.DebugDrawBox(color, false);
                }

                foreach (MyVoxelMap voxelMap in MyVoxelMaps.GetVoxelMaps())
                {
                    MyDebugDraw.DrawHiresBoxWireframe(Matrix.CreateScale(voxelMap.GetSize()) * voxelMap.WorldMatrix, new Vector3(0, 0.4f, 0), 0.3f);
                }
            }

            if (IsEditingPrefabContainer())
            {
                m_activePrefabContainer.DebugDrawBox(new Vector4(1, 1, 0, 0.4f));
            }

            foreach (MyEntity entity in MyEditorGizmo.SelectedEntities)
            {
                if (entity is MyPrefabContainer)
                {
                    MyPrefabContainer container = (MyPrefabContainer)entity;
                    container.DebugDrawBox(new Vector4(0, 1, 0, 0.4f));
                }
            }
        }
Example #2
0
        public virtual void DebugDrawOBB()
        {
            var boundingBoxSize = m_localAABB.Size;

            const float alpha = 1.0f;

            MyDebugDraw.DrawHiresBoxWireframe(MatrixD.CreateScale(boundingBoxSize) * MatrixD.CreateTranslation(m_localVolumeOffset) * WorldMatrix, Color.DarkRed.ToVector3(), alpha, false);
        }
Example #3
0
        public override void DebugDrawDeactivated()
        {
            if (Activated || !Visible)
            {
                return;
            }

            Vector3 colorToDraw = MinerWarsMath.Color.Green.ToVector3();
            float   alpha       = 1f;

            if (Type == MyDummyPointType.Box)
            {
                MyDebugDraw.DrawHiresBoxWireframe(Matrix.CreateScale(LocalAABB.Size()) * WorldMatrix, colorToDraw, alpha);
            }
            else
            {
                MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(Radius) * WorldMatrix, colorToDraw, alpha);
            }
        }
Example #4
0
        /// <summary>
        /// Debug draw of this physics object.
        /// </summary>
        public void DebugDraw()
        {
            const float alpha = 0.3f;

            if (!Enabled)
            {
                return;
            }

            foreach (var primitive in this.rigidBody.GetRBElementList())
            {
                MyRBElementType type = primitive.GetElementType();

                switch (type)
                {
                case MyRBElementType.ET_BOX:
                {
                    var box = (MyRBBoxElement)primitive;

                    MyDebugDraw.DrawHiresBoxWireframe(
                        Matrix.CreateScale(box.Size) * box.GetGlobalTransformation(),
                        Color.Green.ToVector3(), alpha);
                }
                break;

                case MyRBElementType.ET_SPHERE:
                {
                    var sphere = (MyRBSphereElement)primitive;

                    MyDebugDraw.DrawSphereWireframe(
                        Matrix.CreateScale(sphere.Radius) * sphere.GetGlobalTransformation(),
                        Color.Green.ToVector3(), alpha);
                }
                break;

                case MyRBElementType.ET_TRIANGLEMESH:
                {
                    var triMesh = (MyRBTriangleMeshElement)primitive;
                    var model   = triMesh.Model;

                    Matrix transformMatrix = this.rigidBody.Matrix;

                    MyDebugDrawCachedLines.Clear();

                    //  This is just a reserve
                    const int numberOfAddTrianglesInLoop = 3;

                    int triangleIndex = 0;
                    while (true)
                    {
                        //bool finished = triangleIndex >= mesh.GetNumTriangles();
                        bool finished = triangleIndex >= model.GetTrianglesCount();

                        if ((MyDebugDrawCachedLines.IsFull(-numberOfAddTrianglesInLoop)) || (finished))
                        {
                            MyDebugDrawCachedLines.DrawLines();
                            MyDebugDrawCachedLines.Clear();
                        }

                        if (finished)
                        {
                            break;
                        }

                        MyTriangleVertexIndices triangle = model.Triangles[triangleIndex];

                        //  We now transform the triangleVertexes into world space (we could keep leave the mesh alone
                        //  but at this point 3 vector transforms is probably not a major slow down)
                        Vector3 triVec0 = model.GetVertex(triangle.I0);
                        Vector3 triVec1 = model.GetVertex(triangle.I2);
                        Vector3 triVec2 = model.GetVertex(triangle.I1);

                        // Move triangle into world space
                        Vector3.Transform(ref triVec0, ref transformMatrix, out triVec0);
                        Vector3.Transform(ref triVec1, ref transformMatrix, out triVec1);
                        Vector3.Transform(ref triVec2, ref transformMatrix, out triVec2);

                        MyDebugDrawCachedLines.AddLine(triVec0, triVec1, Color.Green, Color.Green);
                        MyDebugDrawCachedLines.AddLine(triVec1, triVec2, Color.Green, Color.Green);
                        MyDebugDrawCachedLines.AddLine(triVec2, triVec0, Color.Green, Color.Green);

                        /*
                         * MyTriangle_Vertexes tv = new MyTriangle_Vertexes();
                         * tv.Vertex0 = triVec0;
                         * tv.Vertex1 = triVec1;
                         * tv.Vertex2 = triVec2;
                         * Vector3 calculatedTriangleNormal = MyUtils.GetNormalVectorFromTriangle(ref tv);
                         * Vector3 center = (triVec0 + triVec1 + triVec2)/3.0f;
                         * MyDebugDrawCachedLines.AddLine(center, center + calculatedTriangleNormal * 5, Color.Red, Color.Red);
                         */

                        //MyDebugDraw.AddDrawTriangle(triVec0, triVec1, triVec2, new Color(0,0.8f, 0, 0.1f));

                        triangleIndex++;
                    }
                }
                break;
                }
            }
        }