Are we showing the Error Texture?
by Dreamer · in Torque Game Engine Advanced · 12/05/2006 (8:11 am) · 3 replies
Hello,
I have a rather sizable amount of assets some of which are displaying the Error Texture because they are not defined in a materials.cs file.
Short of loading up all of my assets one by one and adding them to a materials.cs file what I would rather do is generate the material mapping on the fly. All of my baseTextures share the same name as their relevant shapeBase objects.
I'm wondering if anyone has a clue on where I need to look to see if the Error Texture is currently being displayed? If I can find that I should be able to place a callback into the engine to create a new material based on the shape's file name.
Thoughts on specifically where I might look?
Thanks in advance,
Regards,
Dreamer
(p.s. It would probably make more sense to place this in the OnAdd function of the relevant object for instance TSShapeInstance, but how can I tell if there is no material defined already)
I have a rather sizable amount of assets some of which are displaying the Error Texture because they are not defined in a materials.cs file.
Short of loading up all of my assets one by one and adding them to a materials.cs file what I would rather do is generate the material mapping on the fly. All of my baseTextures share the same name as their relevant shapeBase objects.
I'm wondering if anyone has a clue on where I need to look to see if the Error Texture is currently being displayed? If I can find that I should be able to place a callback into the engine to create a new material based on the shape's file name.
Thoughts on specifically where I might look?
Thanks in advance,
Regards,
Dreamer
(p.s. It would probably make more sense to place this in the OnAdd function of the relevant object for instance TSShapeInstance, but how can I tell if there is no material defined already)
#2
All I want to do is procedurally check if the error texture is currently being displayed on a model.
If it is I want to look in the folder where the model was at to see if there is a .jpg or .png matching the name of the model. If yes then we should define a new material automatically.
12/06/2006 (7:01 am)
Nice but thats pretty much the opposite of what I'm trying to do.All I want to do is procedurally check if the error texture is currently being displayed on a model.
If it is I want to look in the folder where the model was at to see if there is a .jpg or .png matching the name of the model. If yes then we should define a new material automatically.
#3
Just as an aside, if you are looking for the warning material it is referred in the engine as warnMat and usually is assigned as gRenderInstManager.getWarningMat().
edit: I meant to mention that for interiors the engine already prints out an error in interior.cpp around line 2038 (the 'material unmapped' error).
12/06/2006 (8:55 am)
For most objects you can find out if it has the warning material on it by looking at tsShapeInstance.cpp in the initMatInstances() function. I made a previous thread about how to print out an error if your object contains no material. So instead of printing out an error you could try to load another material. This happens for every instance of objects that are in the scene, so if you do manage to load the material that it is looking for the first time an instance comes across it, the other instances shouldn't have to load it. That is just a quick way to do it, probably not the best.Just as an aside, if you are looking for the warning material it is referred in the engine as warnMat and usually is assigned as gRenderInstManager.getWarningMat().
edit: I meant to mention that for interiors the engine already prints out an error in interior.cpp around line 2038 (the 'material unmapped' error).
Associate Manoel Neto
Default Studio Name
1) Execute a pre-defined script which contains all your materials (do not name it materials.cs, to keep it from being loaded automatically). Do not worry if the script doesn't exist at first.
2) Check if a simGroup named myMaterialGroup exists, if not, create it and add it to the missionCleanup (to keep it from being saved alongside your mission). This group will store your dynamically created materials.
3) Scan your shapes folder for textures, and if a material doesn't exist for that texture (check using isObject()), create it, then add it to the simgroup your created in #2.
4) After crating all materials, call the save() method in myMaterialGroup and save it to a script file (that's the same script that should be exec'ed in step #1).
With that, you'll have a material for all of your textures placed in a single script of your liking. You can open the script and edit individual materials by hand, and when you add new textures to your shapes folder, a new material will be created for it when you run the game, and the materials your modified will retain their settings.