Final remark.
I think your point is that one should not use TexGen as a substitute for UV coordinates. That is a fair point to make.
I’m not arguing against your point or recommending this as alternative to UV mapping, but you can use tex projectors to create a local version of MWorldPosition that does not have the issue you described:
model.set_tex_projector(tex_stage, render, model)
All these opportunities should be used with an understanding of what needs to be achieved.
We have previously experimented with this: http://panda3d.org.ru/forum/11-217-1
I will add that in this case it is more convenient to use NodePath
instead of the model
.
You can set the projection direction without rotating the model itself.
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, NodePath, TextureStage, TexGenAttrib
class TextureTester(ShowBase):
def __init__(self):
ShowBase.__init__(self)
tex_stage = TextureStage('test_texture_stage')
plane_projector = NodePath('plane_projector')
plane_projector.set_hpr(0, 90, 0)
model = loader.load_model("test_model.stl")
model.set_tex_gen(tex_stage, TexGenAttrib.MWorldPosition)
model.set_tex_projector(tex_stage, model, plane_projector)
model.set_texture(tex_stage, loader.load_texture('panda.jpg'))
model.set_tex_scale(tex_stage, 0.12)
model.reparent_to(render)
app = TextureTester()
app.run()