示例#1
0
 void PolygonToPolygonIndex(FbxObjectGeometryPolygonMap map)
 {
     if (MappingInformationType == MappingInformationType.ByPolygon)
     {
         Array = MeshOperator.PolygonToPolygonIndex(Array, ArrayElemNum, map);
     }
 }
示例#2
0
    public static T[] TriangleDivision <T>(T[] array, int num, FbxObjectGeometryPolygonMap map)
    {
        var triangle      = new T[map.VertexNum * num];
        var vertexCount   = 0;
        var triangleCount = 0;

        foreach (var vertexNum in map.VertexNumArray)
        {
            var firstIndex = vertexCount;
            for (var i = 0; i < vertexNum - 2; i++)
            {
                var secondIndex = vertexCount + i + 1;
                var thirdIndex  = vertexCount + i + 2;
                for (var e = 0; e < num; e++)
                {
                    try
                    {
                        triangle[triangleCount * num + e]       = array[firstIndex * num + e];
                        triangle[(triangleCount + 1) * num + e] = array[secondIndex * num + e];
                        triangle[(triangleCount + 2) * num + e] = array[thirdIndex * num + e];
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                        throw;
                    }
                }
                triangleCount += 3;
            }

            vertexCount += vertexNum;
        }

        return(triangle);
    }
示例#3
0
    public FbxGeometry(FbxDocument fbxDocument, FbxNode node)
    {
        FbxDocument = fbxDocument;
        FbxDocument.ObjectCache.Add(this, Id);

        Id = new FbxObjectId {
            Id = (long)node.Properties[0]
        };
        foreach (var child in node.Childs)
        {
            switch (child.Name)
            {
            case "Vertices":
                ObjectGeometryVertices = new FbxObjectGeometryVertices(child);
                break;

            case "PolygonVertexIndex":
                FbxObjectGeometryPolygonMap      = new FbxObjectGeometryPolygonMap(child);
                ObjectGeometryPolygonVertexIndex = new FbxObjectGeometryPolygonVertexIndex(child, FbxObjectGeometryPolygonMap);
                break;

            case "LayerElementNormal":
                Normal = new FbxObjectGeometryLayerElementNormal(child, FbxObjectGeometryPolygonMap);
                break;

            case "LayerElementUV":
                UV = new FbxObjectGeometryLayerElementUv(child);
                break;

            case "LayerElementMaterial":
                MaterialIndex = new FbxObjectGeometryLayerElementMaterial(child);
                break;
            }
        }
    }
示例#4
0
    /// <summary>
    ///反転しているビットを戻す
    /// https://stackoverflow.com/questions/7736845/can-anyone-explain-the-fbx-format-for-me
    /// </summary>
    /// <param name="indexes"></param>
    /// <returns></returns>
    static void VertexIndexNegativeToPositive(int[] indexes, FbxObjectGeometryPolygonMap map)
    {
        int lastPolygonIndex = -1;

        foreach (var polygonNum in map.VertexNumArray)
        {
            lastPolygonIndex         += polygonNum;
            indexes[lastPolygonIndex] = ~indexes[lastPolygonIndex];
        }
    }
示例#5
0
 void TriangleDivision(FbxObjectGeometryPolygonMap map)
 {
     if (MappingInformationType == MappingInformationType.ByPolygon)
     {
         Array = MeshOperator.TriangleDivision(Array, ArrayElemNum, map);
     }
     else
     {
         if (ReferenceInformationType == ReferenceInformationType.IndexToDirect)
         {
             Index = MeshOperator.TriangleDivision(Index, 1, map);
         }
         else
         {
             Array = MeshOperator.TriangleDivision(Array, ArrayElemNum, map);
         }
     }
 }
示例#6
0
    public static T[] PolygonToPolygonIndex <T>(T[] array, int num, FbxObjectGeometryPolygonMap map)
    {
        var res = new T[map.VertexNum];

        var resIndex     = 0;
        var polygonIndex = 0;

        for (var i = 0; i < array.Length / num; i++)
        {
            for (var k = 0; k < map.VertexNumArray[polygonIndex]; k++)
            {
                for (var e = 0; e < num; e++)
                {
                    res[resIndex * num + e] = array[i * num + e];
                }
                resIndex++;
            }

            polygonIndex++;
        }

        return(res);
    }
示例#7
0
 public FbxObjectGeometryPolygonVertexIndex(FbxNode node, FbxObjectGeometryPolygonMap map)
 {
     Array = (int[])node.Properties[0];
     VertexIndexNegativeToPositive(Array, map);
 }
示例#8
0
 public void ToTrainable(FbxObjectGeometryPolygonMap map)
 {
     Array = MeshOperator.TriangleDivision(Array, 1, map);
 }
示例#9
0
 public void ToTriangleVertex(FbxObjectGeometryPolygonMap map)
 {
     PolygonToPolygonIndex(map);
     TriangleDivision(map);
     IndexToVertex();
 }
示例#10
0
 public FbxObjectGeometryLayerElementNormal(FbxNode node, FbxObjectGeometryPolygonMap map) : base(node, 3)
 {
     Array = node.GetChild("Normals").GetProperty <double[]>(0);
 }