示例#1
0
        public FbxNode(IntPtr ptr) : base(ptr)
        {
            var nodeCount      = FbxNodeGetChildCount(NativePtr);
            var materialsCount = FbxNodeGetMaterialCount(NativePtr);

            Name      = FbxNodeGetName(NativePtr).PtrToString();
            Materials = new FbxMaterial[materialsCount];
            for (int i = 0; i < materialsCount; i++)
            {
                Materials[i] = new FbxMaterial(FbxNodeGetMaterial(NativePtr, i));
            }

            Attribute = FbxNodeAttribute.GetFromNode(NativePtr);

            for (int i = 0; i < nodeCount; i++)
            {
                Children.Add(new FbxNode(FbxNodeGetChildNode(NativePtr, i)));
            }

            LocalTranform = FbxNodeGetLocalTransform(NativePtr).ToStruct <Mat4x4>().ToLime();
        }
示例#2
0
        public CommonMaterial GetOrCreateLimeMaterial(FbxMaterial material)
        {
            if (MaterialPool.ContainsKey(material.MaterialDescriptor))
            {
                return(MaterialPool[material.MaterialDescriptor]);
            }
            var commonMaterial = new CommonMaterial {
                Id = material.MaterialDescriptor.Name
            };

            if (!string.IsNullOrEmpty(material.MaterialDescriptor.Path))
            {
                var tex = CreateSerializableTexture(options.Path, material.MaterialDescriptor.Path);
                commonMaterial.DiffuseTexture = tex;
                var rulesPath = tex.SerializationPath + ".png";

                // TODO: implement U and V wrapping modes separately for cooking rules.
                // Set "Repeat" wrpap mode if wrap mode of any of the components is set as "Repeat".
                var mode = material.MaterialDescriptor.WrapModeU == TextureWrapMode.Repeat || material.MaterialDescriptor.WrapModeV == TextureWrapMode.Repeat ?
                           TextureWrapMode.Repeat : TextureWrapMode.Clamp;
                if (options.CookingRulesMap.ContainsKey(rulesPath))
                {
                    var cookingRules = options.CookingRulesMap[rulesPath] = options.CookingRulesMap[rulesPath].InheritClone();
                    if (cookingRules.CommonRules.WrapMode != mode)
                    {
                        cookingRules.CommonRules.WrapMode = mode;
                        cookingRules.SourceFilename       = rulesPath + ".txt";
                        cookingRules.CommonRules.Override(nameof(ParticularCookingRules.WrapMode));
                        cookingRules.DeduceEffectiveRules(options.Target);
                        cookingRules.Save();
                    }
                }
            }
            commonMaterial.DiffuseColor = material.MaterialDescriptor.DiffuseColor;
            MaterialPool[material.MaterialDescriptor] = commonMaterial;
            return(commonMaterial);
        }