I got all my textures and everything working the way I want. Here is a screeny of the vehicle. I haven’t done any art for the turret guns yet, but the rest is finished.
As you can see, I’m using gloss and glow on it. Right now, I’m setting that up in my program, but what I’d like to do is just load the egg of the model and have it pop up with the textures in the right channels and everything.
Is there a way to set that up?
Do you mean, you’re assembling the vehicle within a Panda program, by loading up the different pieces, setting the appropriate states on them, and assembling the nodes together?
There’s no way to write a node back into an egg file directly, but you can save it as a bam file via model.writeBamFile(‘foo.bam’). If you really wanted an egg file, you can then process the bam file with bam2egg, though I’m not sure whether bam2egg supports advanced features like gloss maps and glow maps. It might, though.
Honestly, an egg itself is not wholly necessary. All I really want is to not have to run all this:
self.colorGlossTS = TextureStage(self.name + "_Color_TexStage")
self.glowTS = TextureStage(self.name + "_Glow_TexStage")
self.teamTex = self.assetLoader.loadTexture("SuicideJockeys/TeamTex.png", "Shared/HighGloss.png")
self.coffinTex = self.assetLoader.loadTexture("Shared/Coffin.png", "Shared/LowGloss.png")
self.plainMetalTex = self.assetLoader.loadTexture("Shared/HighGloss.png", "Shared/LowGloss.png")
self.discTex = self.assetLoader.loadTexture("Discs/Color01.png", "Shared/LowGloss.png")
self.discGlow = self.assetLoader.loadTexture("Discs/Blank.png", "Discs/Glow01.png")
self.ppTex = self.assetLoader.loadTexture("PowerPlants/Color01.png", "Shared/LowGloss.png")
self.ppGlow = self.assetLoader.loadTexture("PowerPlants/Blank.png", "PowerPlants/Glow01.png")
self.spTex = self.assetLoader.loadTexture("ShieldProjectors/Color01.png", "Shared/LowGloss.png")
self.spGlow = self.assetLoader.loadTexture("ShieldProjectors/Blank.png", "ShieldProjectors/Glow01.png")
self.coffin.setTexture(self.colorGlossTS, self.coffinTex, 1)
#self.cycle.setColor(color.getX(), color.getY(), color.getZ())
# recolors the cycle and turret.
For each of the 8 vehicles at the start of each race, just to set up their textures. If model.writeBamFile will store their texture settings, that’s all I need. I don’t even want to compile the different models together, I made them separate to begin with so that when a vehicle explodes I can scatter them off.
I tried writing out a bam file using the following code:
self.assetLoader = AssetLoader()
self.model = self.assetLoader.loadModel("SuicideJockeys/FrontMolding.egg")
self.colorGlossTS = TextureStage("Color_TexStage")
self.glowTS = TextureStage("Glow_TexStage")
self.modelTex = self.assetLoader.loadTexture("SuicideJockeys/TeamTex.png", "Shared/HighGloss.png")
result = self.model.writeBamFile("FrontMolding.bam")
To my great surprise, it worked perfectly! The bam file includes the texture stage information and the gloss effect works just as intended right out of the box.
I do want to mention that when I used bam2egg, the resulting egg file did not have the texture stage information, and the alpha was interpreted as transparency rather than gloss. Just for people’s information.
I do have one remaining question. I tested the bam in a completely different folder tree using pview, and it was unable to find the textures. The paths were printed out in the error, and they were relative paths. However, when I moved the bam to a different subfolder in the same folder tree, the textures loaded up without a problem, even though I can be sure the relative paths were not correct. Any thoughts as to why?
When relative texture paths appear in a bam file, Panda will attempt to load them (a) relative to the bam file itself, and then (b) relative to the model-path. So perhaps the textures were found relative to your model-path?
Incidentally, you can control the way that texture paths are written when you use writeBamFile(). In your Config.prc file, you can set “bam-texture-mode fullpath” or “bam-texture-mode relative” for full pathnames, or relative pathnames, respectively. There are some other options that are probably less useful, like “unchanged”, “basename”, or “rawdata”. “rawdata” means to write the texture data directly within the bam file, which is nice for keeping the texture data from getting lost, but isn’t so good for shared textures.
Okay, the bam file was created in:
and then moved to
The images is in
(Suicide Jockeys is both the name of the game and the name of the racing team the player will belong to, that’s why it’s used twice.)
The path in the bam is
What exactly would the model-path be, and is it the reason the textures are still loaded?
I’m confident I can get the correct relative paths by creating the bam in the same folder I intend to keep it in, I’m just curious.
Perhaps you have “.” on your model-path, and you are running with SuicideJockeys/Code as the current directory? I’m just guessing, of course. You can print out the current model-path with “print getModelPath()”.
Thanks again for your help, David, I got it all sorted out.