Esempio n. 1
0
        public long[] GetLayerIndices(long geometryId, FbxLayerElementType layerElementType)
        {
            var layerElementTypeString = LayerElementTypeToString(layerElementType);

            var result       = new List <long>();
            var geometryNode = GetGeometry(geometryId);
            var layerNodes   = geometryNode?.GetChildren("Layer");

            if (layerNodes != null)
            {
                foreach (var layerNode in layerNodes)
                {
                    var elementNodes = layerNode?.GetChildren("LayerElement");
                    if (elementNodes != null)
                    {
                        foreach (var elementNode in elementNodes)
                        {
                            var elementTypeToken = elementNode["Type"].FirstOrDefault()?.Value as StringToken;
                            if (elementTypeToken.TryGetAsString(out var elementType) && string.Equals(elementType, layerElementTypeString))
                            {
                                var indexToken = elementNode["TypedIndex"].FirstOrDefault()?.Value as IntegerToken;
                                if (indexToken.TryGetAsLong(out var index))
                                {
                                    result.Add(index);
                                }
                            }
                        }
                    }
                }
            }
            return(result.ToArray());
        }
Esempio n. 2
0
        private string LayerElementTypeToString(FbxLayerElementType layerElementType)
        {
            switch (layerElementType)
            {
            case FbxLayerElementType.Normal:
                return("LayerElementNormal");

            case FbxLayerElementType.Tangent:
                return("LayerElementTangent");

            case FbxLayerElementType.Binormal:
                return("LayerElementBinormal");

            case FbxLayerElementType.TexCoord:
                return("LayerElementUV");

            case FbxLayerElementType.Material:
                return("LayerElementMaterial");

            default:
                throw new NotSupportedException($"Conversion from '{layerElementType}' not supported.");
            }
        }