Ejemplo n.º 1
0
 public Primitive(int vtxCount)
 {
     VertexCount = vtxCount;
     Matrices.AddRange(new int[vtxCount]);
     Positions.AddRange(new int[vtxCount]);
     Normals.AddRange(new int[vtxCount]);
     Colors.AddRange(new int[vtxCount]);
     TexCoords.AddRange(new int[vtxCount]);
 }
Ejemplo n.º 2
0
        public Primitive(Primitive original)
        {
            Type        = original.Type;
            VertexCount = original.VertexCount;
            Matrices.AddRange(original.Matrices);
            Positions.AddRange(original.Positions);
            Normals.AddRange(original.Normals);
            Colors.AddRange(original.Colors);
            TexCoords.AddRange(original.TexCoords);

            Processed          = original.Processed;
            NextCandidateCount = original.NextCandidateCount;
            NextCandidates[0]  = original.NextCandidates[0];
            NextCandidates[1]  = original.NextCandidates[1];
            NextCandidates[2]  = original.NextCandidates[2];
            NextCandidates[3]  = original.NextCandidates[3];
        }
Ejemplo n.º 3
0
        public void Append(Model m, Vector3 pivot)
        {
            if (m.Vertices.Count < 3)
            {
                return;
            }

            int oldFacesPos = Faces.Count;

            Faces.AddRange(m.Faces);

            for (int i = oldFacesPos; i < Faces.Count; ++i)
            {
                for (int j = 0; j < Faces[i].VertexIndices.Length; ++j)
                {
                    Faces[i].VertexIndices[j] += Vertices.Count;
                }

                for (int j = 0; j < Faces[i].NormalIndices.Length; ++j)
                {
                    Faces[i].NormalIndices[j] += Normals.Count;
                }

                for (int j = 0; j < Faces[i].TextureIndices.Length; ++j)
                {
                    Faces[i].TextureIndices[j] += TexCoords.Count;
                }
            }

            Vertices.AddRange(m.Vertices);
            Normals.AddRange(m.Normals);
            TexCoords.AddRange(m.TexCoords);

            for (int i = 0; i < Vertices.Count; ++i)
            {
                Vertices[i] += pivot;
            }
        }
Ejemplo n.º 4
0
        public bool TryMerge(SubMesh other)
        {
            //  return false;

            if (MaterialID != other.MaterialID)
            {
                return(false);
            }

            int offset = Positions.Count;

            Positions.AddRange(other.Positions);
            Normals.AddRange(other.Normals);
            Tangents.AddRange(other.Tangents);
            TexCoords.AddRange(other.TexCoords);
            VertexColors.AddRange(other.VertexColors);

            foreach (int index in other.Indices)
            {
                Indices.Add(index + offset);
            }

            return(true);
        }