private void AddMeshTriangles(MyIsoMesh mesh, Vector3 offset, Matrix rotation, Matrix ownRotation)
        {
            for (int i = 0; i < mesh.TrianglesCount; i++)
            {
                ushort a = mesh.Triangles[i].VertexIndex0;
                ushort b = mesh.Triangles[i].VertexIndex1;
                ushort c = mesh.Triangles[i].VertexIndex2;
                m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + c);
                m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + b);
                m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + a);
            }

            for (int i = 0; i < mesh.VerticesCount; i++)
            {
                Vector3 vert;
                mesh.GetUnpackedPosition(i, out vert);
                Vector3.Transform(ref vert, ref ownRotation, out vert);
                vert -= offset;
                Vector3.Transform(ref vert, ref rotation, out vert);

                m_worldVertices.Vertices.Add(vert);
            }

            m_worldVertices.VerticesMaxValue += mesh.VerticesCount;
        }
Exemplo n.º 2
0
        private unsafe void AddMeshTriangles(MyIsoMesh mesh, Vector3 offset, Matrix rotation, Matrix ownRotation)
        {
            for (int i = 0; i < mesh.TrianglesCount; i++)
            {
                ushort num2 = mesh.Triangles[i].V0;
                ushort num3 = mesh.Triangles[i].V1;
                ushort num4 = mesh.Triangles[i].V2;
                m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + num4);
                m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + num3);
                m_worldVertices.Triangles.Add(m_worldVertices.VerticesMaxValue + num2);
            }
            for (int j = 0; j < mesh.VerticesCount; j++)
            {
                Vector3 vector;
                mesh.GetUnpackedPosition(j, out vector);
                Vector3 *vectorPtr1 = (Vector3 *)ref vector;
                Vector3.Transform(ref (Vector3) ref vectorPtr1, ref ownRotation, out vector);
                vector -= offset;
                Vector3 *vectorPtr2 = (Vector3 *)ref vector;
                Vector3.Transform(ref (Vector3) ref vectorPtr2, ref rotation, out vector);
                m_worldVertices.Vertices.Add(vector);
            }
            WorldVerticesInfo worldVertices = m_worldVertices;

            worldVertices.VerticesMaxValue += mesh.VerticesCount;
        }
Exemplo n.º 3
0
 private void PreprocessTriangles(MyIsoMesh generatedMesh, Vector3 centerDisplacement)
 {
     for (int i = 0; i < generatedMesh.TrianglesCount; i++)
     {
         Vector3 vector3;
         ushort  idx  = generatedMesh.Triangles[i].V0;
         ushort  num3 = generatedMesh.Triangles[i].V1;
         ushort  num4 = generatedMesh.Triangles[i].V2;
         generatedMesh.GetUnpackedPosition(idx, out vector3);
         Vector3 vector = vector3 - centerDisplacement;
         generatedMesh.GetUnpackedPosition(num3, out vector3);
         Vector3 vector2 = vector3 - centerDisplacement;
         generatedMesh.GetUnpackedPosition(num4, out vector3);
         bool flag = false;
         if ((vector2 - vector).LengthSquared() <= MyVoxelConnectionHelper.OUTER_EDGE_EPSILON_SQ)
         {
             m_vertexMapping.Union(idx, num3);
             flag = true;
         }
         Vector3 vector1 = vector3 - centerDisplacement;
         if (((vector3 - centerDisplacement) - vector).LengthSquared() <= MyVoxelConnectionHelper.OUTER_EDGE_EPSILON_SQ)
         {
             m_vertexMapping.Union(idx, num4);
             flag = true;
         }
         Vector3 vector4 = (vector3 - centerDisplacement) - vector2;
         if (vector4.LengthSquared() <= MyVoxelConnectionHelper.OUTER_EDGE_EPSILON_SQ)
         {
             m_vertexMapping.Union(num3, num4);
             flag = true;
         }
         if (!flag)
         {
             this.m_connectionHelper.PreprocessInnerEdge(idx, num3);
             this.m_connectionHelper.PreprocessInnerEdge(num3, num4);
             this.m_connectionHelper.PreprocessInnerEdge(num4, idx);
         }
     }
 }