コード例 #1
1
ファイル: frmMain.cs プロジェクト: zulis/Sandbox
        private void SaveX(TVMesh tvm, string fileName)
        {
            ExtendedMaterial[] exMaterials = new ExtendedMaterial[tvm.GetGroupCount()];
            Material dxMaterial;
            int idx = 0;

            for (int group = 0; group < tvm.GetGroupCount(); group++)
            {
                idx = tvm.GetMaterial(group);
                dxMaterial = new Material();
                dxMaterial.AmbientColor = ToDx(core.MaterialFactory.GetAmbient(idx));
                dxMaterial.DiffuseColor = ToDx(core.MaterialFactory.GetDiffuse(idx));
                dxMaterial.EmissiveColor = ToDx(core.MaterialFactory.GetEmissive(idx));
                dxMaterial.SpecularColor = ToDx(core.MaterialFactory.GetSpecular(idx));
                dxMaterial.SpecularSharpness = core.MaterialFactory.GetPower(idx);
                exMaterials[group].Material3D = dxMaterial;
                // Get the Texture Filename.
                idx = tvm.GetTexture(group);
                // Add em to the array.
                exMaterials[group].TextureFilename = core.TextureFactory.GetTextureInfo(idx).Name;
            }

            // Save the Mesh.
            Microsoft.DirectX.Direct3D.Mesh dxMesh = new Microsoft.DirectX.Direct3D.Mesh(core.InternalObjects.GetD3DMesh(tvm.GetIndex()));
            int[] adjacency = new int[dxMesh.NumberFaces * 3];
            dxMesh.GenerateAdjacency(0f, adjacency);
            dxMesh.Save(fileName, adjacency, exMaterials, XFileFormat.Text);
        }