示例#1
0
        void LoadModel(MyModel model, Matrix modelWorld, float modelScale)
        {
            Matrix world = modelWorld * Matrix.CreateScale(modelScale);

            m_minCoord = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            m_maxCoord = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            MyTriangleVertexIndices[] triangles = model.Triangles;
            m_triangles = new List<MyImportTriangle>(triangles.Length);

            for (int i = 0; i < triangles.Length; i++)
            {
                Vector3 vertex0 = Vector3.Transform(model.GetVertex(triangles[i].I0), world);
                Vector3 vertex1 = Vector3.Transform(model.GetVertex(triangles[i].I1), world);
                Vector3 vertex2 = Vector3.Transform(model.GetVertex(triangles[i].I2), world);

                MyImportTriangle triangle = new MyImportTriangle(vertex0, vertex1, vertex2);
                //  Ignore triangles that lie in XZ plane
                if (triangle.Normal.Y != 0)
                {
                    m_triangles.Add(triangle);
                    CheckMinMaxCoords(vertex0);
                    CheckMinMaxCoords(vertex1);
                    CheckMinMaxCoords(vertex2);
                }
            }
        }
示例#2
0
        void LoadModel(MyModelObj model)
        {
            m_minCoord = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            m_maxCoord = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            Vector3[] vertices = model.Vertexes.ToArray();
            MyTriangleVertexIndices[] triangles = model.Triangles.ToArray();
            m_triangles = new List<MyImportTriangle>(triangles.Length);

            for (int i = 0; i < triangles.Length; i++)
            {
                Vector3 vertex0 = vertices[triangles[i].I0];
                Vector3 vertex1 = vertices[triangles[i].I1];
                Vector3 vertex2 = vertices[triangles[i].I2];

                MyImportTriangle triangle = new MyImportTriangle(vertex0, vertex1, vertex2);
                //  Ignore triangles that lie in XZ plane
                if (triangle.Normal.Y != 0)
                {
                    m_triangles.Add(triangle);
                    CheckMinMaxCoords(vertex0);
                    CheckMinMaxCoords(vertex1);
                    CheckMinMaxCoords(vertex2);
                }
            }
        }
示例#3
0
        void LoadModel(Vector3[] vertexes, MyTriangleVertexIndices[] triangles, Matrix world)
        {
            m_minCoord = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            m_maxCoord = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            m_triangles = new List<MyImportTriangle>(triangles.Length);

            for (int i = 0; i < triangles.Length; i++)
            {
                Vector3 vertex0 = Vector3.Transform(vertexes[triangles[i].I0], world);
                Vector3 vertex1 = Vector3.Transform(vertexes[triangles[i].I1], world);
                Vector3 vertex2 = Vector3.Transform(vertexes[triangles[i].I2], world);

                MyImportTriangle triangle = new MyImportTriangle(vertex0, vertex1, vertex2);
                //  Ignore triangles that lie in XZ plane
                if (triangle.Normal.Y != 0)
                {
                    m_triangles.Add(triangle);
                    CheckMinMaxCoords(vertex0);
                    CheckMinMaxCoords(vertex1);
                    CheckMinMaxCoords(vertex2);
                }
            }
        }