Game Development Community

Create material in code (2.0)

by Dieter Eichert · in Torque X 2D · 03/26/2008 (9:49 am) · 2 replies

Hello,

usally i used this code to preload a whole directory of textures:
private static void LoadMaterialDirectory(string directory, string suffix, bool translucent)
        {
            string[] charFiles = System.IO.Directory.GetFiles(directory);
            foreach (string file in charFiles)
            {
                Gener material = new DefaultEffect();
                material.Translucent = translucent;
                material.BaseTex = file;                
                
                string name = System.IO.Path.GetFileNameWithoutExtension(file);
                GarageGames.Torque.Materials.MaterialManager.Add(name + suffix, material);

            }
        }

But there is no DefaultEffect anymore. Do anyone know which class is state of the art now?


thanks, max.

#1
03/26/2008 (9:25 pm)
The DefaultEffect class has been replaced by the SimpleMaterial class and the class properties are almost exactly the same, so it should be pretty easy to port your code over.

John K.
#2
03/27/2008 (5:09 am)
Thanx.

now the method looks like this:
private static void LoadMaterialDirectory(string directory, string suffix, bool translucent)
        {
            string[] charFiles = System.IO.Directory.GetFiles(directory);
            foreach (string file in charFiles)
            {
                SimpleMaterial material = new SimpleMaterial();
                material.IsTranslucent = translucent;
                material.TextureFilename = file;                
                
                string name = System.IO.Path.GetFileNameWithoutExtension(file);
                GarageGames.Torque.Materials.MaterialManager.Add(name + suffix, material);

            }
        }