Esempio n. 1
0
        public BMDMaterialWrapper(Material mat, SuperBMDLib.Model model)
        {
            Material    = mat;
            ParentModel = model;

            Text = mat.Name;

            int textureUnit = 1;

            if (mat.TextureIndices[0] != -1)
            {
                int texIndex = mat.TextureIndices[0];

                BMDTextureMap matTexture = new BMDTextureMap(this);
                matTexture.TextureIndex = texIndex;
                matTexture.Name         = ParentModel.Textures[texIndex].Name;
                matTexture.Type         = STGenericMatTexture.TextureType.Diffuse;
                matTexture.textureUnit  = textureUnit++;

                matTexture.WrapModeS = ConvertWrapMode(ParentModel.Textures[texIndex].WrapS);
                matTexture.WrapModeT = ConvertWrapMode(ParentModel.Textures[texIndex].WrapT);
                matTexture.MinFilter = ConvertMinFilter(ParentModel.Textures[texIndex].MinFilter);
                matTexture.MagFilter = ConvertMagFilter(ParentModel.Textures[texIndex].MagFilter);

                TextureMaps.Add(matTexture);

                foreach (var textureIndex in mat.TextureIndices)
                {
                    if (textureIndex != -1)
                    {
                        Nodes.Add(ParentModel.Textures[textureIndex].Name);
                    }
                }
            }
        }
        static Stream ConvertBMD(Stream data)
        {
            SuperBMDLib.Model bmd = new SuperBMDLib.Model(data);
            bmd.littleEndian = true;
            var mem = new MemoryStream();

            bmd.Save(mem, true);
            return(new MemoryStream(mem.ToArray()));
        }
Esempio n. 3
0
        private void ExportVisualMesh(View.VisualMeshExportWindow exportWindow, string modelFilename)
        {
            List <string> superBMDArgs = new List <string>(new string[] {
                "-i", $"{ modelFilename }",
                "-o", $"{ exportWindow.FileName }",
            });

            SuperBMDLib.Arguments args = new SuperBMDLib.Arguments(superBMDArgs.ToArray());

            SuperBMDLib.Model newJ3D = SuperBMDLib.Model.Load(args);
            newJ3D.ExportAssImp(exportWindow.FileName, "dae", new SuperBMDLib.ExportSettings());
            // TODO: the daes exported by this have issues that prevents them from being read properly by blender
        }
Esempio n. 4
0
        private string ImportVisualMesh(View.VisualMeshImportWindow importWindow, bool isBDL)
        {
            string tempFileName = Path.GetFileNameWithoutExtension(Path.GetTempFileName());
            string loadFilename = Path.Combine(Path.GetTempPath(), "Winditor", tempFileName + (isBDL ? ".bdl" : ".bmd"));

            List <string> superBMDArgs = new List <string>(new string[] { "-i", $"{ importWindow.FileName }" });

            superBMDArgs.Add("--rotate");
            if (isBDL)
            {
                superBMDArgs.Add("-b");
            }
            if (importWindow.GenerateMaterials)
            {
                superBMDArgs.Add("-glm");
            }

            SuperBMDLib.Arguments args = new SuperBMDLib.Arguments(superBMDArgs.ToArray());

            SuperBMDLib.Model newJ3D = SuperBMDLib.Model.Load(args);
            newJ3D.ExportBMD(loadFilename, isBDL);

            return(loadFilename);
        }
Esempio n. 5
0
 public BMDShapeWrapper(Shape shape, SuperBMDLib.Model model, BMDMaterialWrapper mat)
 {
     BMDShape    = shape;
     ParentModel = model;
     material    = mat;
 }