예제 #1
0
        // just store GenericMaterial object, we can't use it here
        public int BuildMaterial(GenericMaterial m)
        {
            int id = Materials.Count;

            Materials.Add(m);
            return(id);
        }
예제 #2
0
        // https://en.wikipedia.org/wiki/Wavefront_.obj_file#Material_template_library
        SOMaterial build_material(string sSourceFilePath, g3.GenericMaterial mIn)
        {
            OBJMaterial objMat = mIn as OBJMaterial;
            // TODO handle other types?

            int lightmodel = objMat.illum;

            if (lightmodel > 2)     // [RMS] we don't support these anyway, but don't want to ignore these materials...
            {
                lightmodel = 2;
            }
            if (lightmodel < 0 || lightmodel == 0 || lightmodel == 1 || lightmodel == 2)
            {
                SOMaterial sceneMat = new SOMaterial()
                {
                    Name     = objMat.name,
                    Type     = SOMaterial.MaterialType.TextureMap,
                    RGBColor = toColor(objMat.DiffuseColor, objMat.Alpha)
                };

                if (objMat.map_Kd != null && objMat.map_Kd != "")
                {
                    Texture2D tex = load_texture(sSourceFilePath, objMat.map_Kd);
                    sceneMat.MainTexture = tex;
                    if (objMat.Kd == GenericMaterial.Invalid)
                    {
                        sceneMat.RGBColor = Colorf.White;
                    }
                }
                return(sceneMat);
            }

            return(null);
        }
예제 #3
0
        // https://en.wikipedia.org/wiki/Wavefront_.obj_file#Material_template_library
        SOMaterial build_material(string sSourceFilePath, g3.GenericMaterial mIn)
        {
            OBJMaterial objMat = mIn as OBJMaterial;

            // TODO handle other types?

            if (objMat.illum < 0 || objMat.illum == 1 || objMat.illum == 2)
            {
                SOMaterial sceneMat = new SOMaterial()
                {
                    Name     = objMat.name,
                    Type     = SOMaterial.MaterialType.TextureMap,
                    RGBColor = toColor(objMat.DiffuseColor, objMat.Alpha)
                };

                if (objMat.map_Kd != null && objMat.map_Kd != "")
                {
                    Texture2D tex = load_texture(sSourceFilePath, objMat.map_Kd);
                    sceneMat.MainTexture = tex;
                    if (objMat.Kd == GenericMaterial.Invalid)
                    {
                        sceneMat.RGBColor = Colorf.White;
                    }
                }
                return(sceneMat);
            }

            return(null);
        }