private Dictionary <OBJMaterial, MeshCoreData.Material> convertMaterials(ObjImporter importer)
        {
            var materials = new Dictionary <OBJMaterial, MeshCoreData.Material>();

            for (int i = 0; i < importer.Materials.Count; i++)
            {
                var mat     = importer.Materials[i];
                var meshMat = new MeshCoreData.Material();
                if (mat.DiffuseMap != null)
                {
                    meshMat.DiffuseMap = CreateOrFindIdenticalTexture(mat.DiffuseMap);
                }
                if (mat.BumpMap != null)
                {
                    meshMat.NormalMap = CreateOrFindIdenticalTexture(mat.BumpMap);
                }
                if (mat.SpecularMap != null)
                {
                    meshMat.SpecularMap = CreateOrFindIdenticalTexture(mat.SpecularMap);
                }
                meshMat.ColoredMaterial = mat.DiffuseMap == null;
                meshMat.DiffuseColor    = mat.DiffuseColor;
                meshMat.Name            = mat.Name;
                materials[mat]          = meshMat;
            }
            return(materials);
        }
        public void Dispose()
        {
            Material       = null;
            DiffuseTexture = null;

            if (Shader != null)
            {
                Shader.Dispose();
            }
            Shader = null;

            if (PerObjectConstantBuffer != null)
            {
                PerObjectConstantBuffer.Dispose();
            }
            PerObjectConstantBuffer = null;

            if (Parts != null)
            {
                foreach (var p in Parts)
                {
                    p.Dispose();
                }
            }
            Parts = null;
        }
        public DeferredMaterial GetDeferredMaterial(MeshCoreData.Material material)
        {
            if (pool.ContainsKey(material))
            {
                return((DeferredMaterial)pool[material]);
            }

            var ret = new DeferredMaterial(game,
                                           material.DiffuseMap == null ? null : texturePool.LoadTexture(material.DiffuseMap),
                                           material.NormalMap == null ? null : texturePool.LoadTexture(material.NormalMap),
                                           material.SpecularMap == null ? null : texturePool.LoadTexture(material.SpecularMap));

            pool.Add(material, ret);

            return(ret);
        }
        public static IMesh CreateSimpleTestMesh()
        {
            IMesh mesh;

            mesh = new RAMMesh();

            var part = new MeshCoreData.Part();

            part.ObjectMatrix = Matrix.Identity;
            part.MeshPart     = new RAMMeshPart();
            ((RAMMeshPart)part.MeshPart).SetGeometryData(MeshPartGeometryData.CreateTestSquare());

            var mat = new MeshCoreData.Material();

            mat.DiffuseMap = GetTestTexture();

            part.MeshMaterial = mat;
            mesh.GetCoreData().Parts.Add(part);

            return(mesh);
        }
        private void createMaterials()
        {
            materials = new Dictionary <OBJMaterial, MeshCoreData.Material>();

            for (int i = 0; i < importer.Materials.Count; i++)
            {
                var mat     = importer.Materials[i];
                var meshMat = new MeshCoreData.Material();
                if (mat.DiffuseMap != null)
                {
                    meshMat.DiffuseMap = CreateOrFindIdenticalTexture(mat.DiffuseMap);
                }
                if (mat.BumpMap != null)
                {
                    meshMat.NormalMap = CreateOrFindIdenticalTexture(mat.BumpMap);
                }
                if (mat.SpecularMap != null)
                {
                    meshMat.SpecularMap = CreateOrFindIdenticalTexture(mat.SpecularMap);
                }
                meshMat.DiffuseColor = mat.DiffuseColor;
                materials[mat]       = meshMat;
            }
        }