Esempio n. 1
0
 protected FbxObjectGeometryLayer(FbxNode node, int arrayElemNum)
 {
     Node = node;
     MappingInformationType   = GetMappingInfomationType(node);
     ReferenceInformationType = GetReferenceInformationType(node);
     ArrayElemNum             = arrayElemNum;
 }
Esempio n. 2
0
        public MeshGeometry(FbxNode geometryNode)
        {
            Debug.Assert(geometryNode.IsMeshGeometry());

            ID   = geometryNode.Properties[0].AsInt64();
            Name = geometryNode.Properties[1].AsString();

            _positions          = default;
            _indicesRaw         = default;
            _normals            = default;
            NormalReferenceType = default;
            NormalMappingType   = default;
            _normalIndices      = default;
            _uv             = default;
            UVReferenceType = default;
            UVMappingType   = default;
            _uvIndices      = default;
            Materials       = default;
            foreach (var node in geometryNode.Children)
            {
                var nodeName = node.Name;
                if (nodeName.SequenceEqual(FbxConstStrings.Vertices()))
                {
                    // "Vertices"

                    _positions = node.Properties[0].AsDoubleArray();
                }
                else if (nodeName.SequenceEqual(FbxConstStrings.PolygonVertexIndex()))
                {
                    // "PolygonVertexindex"

                    _indicesRaw = node.Properties[0].AsInt32Array();
                }
                else if (nodeName.SequenceEqual(FbxConstStrings.LayerElementNormal()))
                {
                    // "LayerElementNormal"

                    _normals = node.FindChild(FbxConstStrings.Normals()).Properties[0].AsDoubleArray();

                    var referenceType = node.FindChild(FbxConstStrings.ReferenceInformationType()).Properties[0].AsString();
                    var mappingType   = node.FindChild(FbxConstStrings.MappingInformationType()).Properties[0].AsString();

                    NormalReferenceType = referenceType.ToReferenceInformationType();
                    NormalMappingType   = mappingType.ToMappingInformationType();

                    if (NormalReferenceType == ReferenceInformationType.IndexToDirect)
                    {
                        _normalIndices = node.FindChild(FbxConstStrings.NormalIndex()).Properties[0].AsInt32Array();
                    }
                }
                else if (nodeName.SequenceEqual(FbxConstStrings.LayerElementUV()))
                {
                    // "LayerElementUV"

                    _uv = node.FindChild(FbxConstStrings.UV()).Properties[0].AsDoubleArray();
                    var referenceType = node.FindChild(FbxConstStrings.ReferenceInformationType()).Properties[0].AsString();
                    var mappingType   = node.FindChild(FbxConstStrings.MappingInformationType()).Properties[0].AsString();
                    UVReferenceType = referenceType.ToReferenceInformationType();
                    UVMappingType   = mappingType.ToMappingInformationType();

                    if (UVReferenceType == ReferenceInformationType.IndexToDirect)
                    {
                        _uvIndices = node.FindChild(FbxConstStrings.UVIndex()).Properties[0].AsInt32Array();
                    }
                }
                else if (nodeName.SequenceEqual(FbxConstStrings.LayerElementMaterial()))
                {
                    // "LayerElementMaterial"

                    Materials = node.FindChild(FbxConstStrings.Materials()).Properties[0].AsInt32Array();
                }
            }
        }