I want to generate texture coords automatically.
This page explains how: panda3d.org/manual/index.php … oordinates
The “TexGenAttrib.MWorldPosition” mode seems what I want. However, I don’t want it to recompute the UVs when I move my Nodepath around.
So can it be baked somehow?
You can use the ProjectionScreen for that. It will create the texture coordinates based on the lens of your choice and write them into the vertexes. You can even export it to Bam, if you so desire.
Since there’s not much documentation aside from the API, here’s how you’d use that:
self.projectionScreen = ProjectionScreen("myProjectionScreen")
self.projectionScreenNP = render.attachNewNode(self.projectionScreen)
self.lens = OrthographicLens() # Perspective would work just as well
self.lensNode = LensNode("lensNode")
self.lensNP = render.attachNewNode(self.lensNode)
# Set lens transforms as you see fit
# Reparent everything you want to compute texcoords for to the projectionScreenNP
# Reparent it back
# Optionally, destroy the ProjectionScreen, if you don't need it any more.
Assuming you set the lens correctly, this will give you the exact results you need – equivalent of baking automatic world space texcoords.
If you need to use these texcoords for normal mapping, however, you will need to manually recompute tangents and binormals, because the PS doesn’t do that.
Cool. What if I need multiple coordinate sets?
Use setTexcoordName() on the ProjectionScreen.