Example #1
0
        /// <summary>
        /// Create a new Gcmf object from the given .OBJ / .MTL object.
        /// </summary>
        /// <param name="modelObject">The object from which to create the Gcmf object.</param>
        /// <param name="textureIndexMapping">Correspondence between the textures defined in the model materials and .TPL texture indices.</param>
        public Gcmf(ObjMtlObject modelObject, Dictionary <Bitmap, int> modelTextureMapping)
            : this()
        {
            Dictionary <ObjMtlMaterial, int> modelMaterialMapping = new Dictionary <ObjMtlMaterial, int>();

            foreach (ObjMtlMaterial mat in modelObject.Meshes.Select(m => m.Material))
            {
                modelMaterialMapping.Add(mat, Materials.Count);
                Materials.Add(new GcmfMaterial(mat, modelTextureMapping));
            }

            foreach (ObjMtlMesh mesh in modelObject.Meshes)
            {
                Meshes.Add(new GcmfMesh(mesh, modelMaterialMapping));
            }

            UpdateBoundingSphere();
        }
Example #2
0
        /// <summary>
        /// Create a new Gcmf object from the given .OBJ / .MTL object.
        /// </summary>
        /// <param name="modelObject">The object from which to create the Gcmf object.</param>
        /// <param name="textureIndexMapping">Correspondence between the textures defined in the model materials and .TPL texture indices.</param>
        public Gcmf(ObjMtlObject modelObject, Dictionary <Bitmap, int> modelTextureMapping, string presetFolder = null)
            : this()
        {
            Dictionary <ObjMtlMaterial, int> modelMaterialMapping = new Dictionary <ObjMtlMaterial, int>();

            foreach (ObjMtlMaterial mat in modelObject.Meshes.Select(m => m.Material))
            {
                if (!modelMaterialMapping.ContainsKey(mat))
                {
                    modelMaterialMapping.Add(mat, Materials.Count);
                    Materials.Add(new GcmfMaterial(mat, modelTextureMapping, presetFolder));
                }
            }

            foreach (ObjMtlMesh mesh in modelObject.Meshes)
            {
                Meshes.Add(new GcmfMesh(mesh, modelMaterialMapping, presetFolder));
            }

            UpdateBoundingSphere();
        }