コード例 #1
0
 public static void AppendObjTriangle(ObjItem objModel, ObjFaceVertex faceVertex,
                                      ref List <float> vertexPositions, ref List <float> vertexNormals, ref List <float> vertexTextureCoordinates, ref List <float> vertexBoneWeights, ref List <float> vertexBoneIndices, ref List <uint> indeces)
 {
     if (indeces != null)
     {
         indeces.Add((uint)(vertexPositions.Count / 3));
     }
     if (vertexPositions != null)
     {
         var vertexPosition = objModel.Vertices[faceVertex.VertexIndex - 1];
         vertexPositions.Add(vertexPosition.X);
         vertexPositions.Add(vertexPosition.Y);
         vertexPositions.Add(vertexPosition.Z);
     }
     if (vertexNormals != null)
     {
         if (objModel.Normals.Count == 0)
         {
             vertexNormals.AddRange(new[] { 0.0f, 0.0f, 0.0f });
         }
         else
         {
             var vertexNormal = objModel.Normals[faceVertex.NormalIndex - 1];
             vertexNormals.Add(vertexNormal.X);
             vertexNormals.Add(vertexNormal.Y);
             vertexNormals.Add(vertexNormal.Z);
         }
     }
     if (vertexTextureCoordinates != null)
     {
         var vertexTexture = objModel.TextureCoords[faceVertex.TextureIndex - 1];
         vertexTextureCoordinates.Add(vertexTexture.X);
         vertexTextureCoordinates.Add(vertexTexture.Y);
     }
     if (vertexBoneIndices != null)
     {
         vertexBoneIndices.AddRange(new[] { 0.0f, 0.0f, 0.0f, 0.0f });
     }
     if (vertexBoneWeights != null)
     {
         vertexBoneWeights.AddRange(new[] { 0.0f, 0.0f, 0.0f, 0.0f });
     }
 }
コード例 #2
0
        private static ObjFaceVertex ParseFaceVertex(string vertexString)
        {
            var fields = vertexString.Split(new[] { '/' }, StringSplitOptions.None);

            var vertexIndex = StringConverter.ToInt(fields[0]);
            var faceVertex  = new ObjFaceVertex(vertexIndex, 0, 0);

            if (fields.Length > 1)
            {
                var textureIndex = fields[1].Length == 0 ? 0 : StringConverter.ToInt(fields[1]);
                faceVertex.TextureIndex = textureIndex;
            }

            if (fields.Length > 2)
            {
                var normalIndex = fields.Length > 2 && fields[2].Length == 0 ? 0 : StringConverter.ToInt(fields[2]);
                faceVertex.NormalIndex = normalIndex;
            }

            return(faceVertex);
        }
コード例 #3
0
ファイル: ObjFace.cs プロジェクト: wiplug/HeadShop
 public void AddVertex(ObjFaceVertex vertex)
 {
     _vertices.Add(vertex);
 }