How to texture model?

Hi all, I’m brand new to Panda3D. Sorry if I posted this in the wrong place. Over the past few days, I’ve made a model in 3DS Max 7, and used the unwrap UVW modifier on it to get it set up for texturing. I then made a texture which is just an image of the UVW coordinates (ie. the texture just outlines all the faces of the model) and saved it as a PNG. However, I saved it to my desktop, and loaded it into 3DS from there, which might have been a mistake? I’m new to actual game pipeline stuff. So, then I exported my mesh as an egg file. Now, on my computer, when I load the model in a small python script, it works flawlessly, and the texture is automatically loaded onto the model. This led me to believe that the texture file was packed into the egg file along with the mesh, but I guess I was wrong. I sent the egg file and the python script to a friend, and when he runs the script, all he sees is a pure white model.

So, I tried using loadTexture and setTexture to make sure the model gets textured like so:

self.plr_ship = self.loader.loadModel("cruiserB.egg")
self.plr_ship.reparentTo(self.render)
self.plr_ship_txtr = self.loader.loadTexture("uvw.png")
self.plr_ship.setTexture(self.plr_ship_txtr)

But the model is still not textured.

Can anyone tell me why the texture loads automatically in Panda3D on my computer and what I need to do to get it to load for anyone I send it to?

If you look at the egg file (it’s an ordinary text file, just look at it in Notepad or something), you’ll see the reference to the texture file there. It’s an external reference, so it gets loaded by filename, and the file must be found in the same place relative to the egg file. So you need to copy both the egg file and the texture file to your friend’s computer, and ensure the texture file is in the same place relative to the egg file.

(Or, if perhaps you see a full pathname in the egg file, you might need to edit that pathname to make it a relative pathname instead. If that happens, it’s possibly an error from the converter.)

As to why your loadTexture() and setTexture() operations didn’t work, it’s hard to guess; it might be because the egg file uses named UV coordinates, which mean you have to set up the same name in your setTexture() call (using an explicit TextureStage). The code you are using is only appropriate for egg files that use the default, unnamed UV coordinates.

David

Thanks a bunch for the help. I got it working right now. It would seem that when you apply a material to an object in 3DS, the image file needs to be located somewhere relative to where you export your egg file. Before it was on my desktop, but I moved it to the folder where the egg file gets exported to and it works now. Again, thanks.