Hi, this is my problem today:
Let’s say I want 2 of my actors to look at each other, I use lookAt … and the actors look at opposite directions.
I know it’s very likely to be a coordinates problem in the model. I don’t think manually editing and rotating all my models is a good idea, as I would probably mess something in them in the proccess.
I think I can solve this by making a function ‘myLookAt’ that would do lookAt + rotate 180Âº
Someone knows a better system to fix the facing of the models?
It would be nice if you could tell somehow the facing of the model just after loading it.
Well, it’s hard to imagine how you could determine algorithmically which way a model is facing just by loading it, unless you have some algorithm that can recognize a character’s face by the shape of its vertices. Since basically, you are asking for a way to ask which way a character’s nose is pointing.
But you know that all of your actors are modeled the wrong way. No problem. You can just do this:
actor.getGeomNode().setHpr(180, 0, 0)
This will rotate the “geom node” of each actor, which is a nested node below the root node. So now when you call actor.lookAt(), it rotates only the root node, and the geom node comes along with it.
Thanks for the answer.
I wasn’t asking automatic face detection, I do know that even if possible, it would be tons of work just to point the model, the same that you could get with some very short code like the line you posted, and that was exactly what I was looking for… but it didn’t work for me
actor.getGeomNode().setHpr(180, 0, 0) rotates the actor but when lookAt is called it seems to overwrite or ignore the previous rotation and again the actor is facing wrong. Maybe I’m doing something wrong?
Anyway, if the geomnode.setHpr worked it would be perfect, and I think this problem maybe usual for people importing models from several formats with its own axis set up, I just expect not to trouble you too much with such a little issue, as my initial solution is still there.
Jus’ wondering, can’t egg-trans rotate the model geometry?
if i have a model with wrong orientation i often modify it in panda3d itself:
# in python
x = loader.loadModel( 'model.egg' )
x.setHpr( 180,0,0 )
# in console
bam2egg -o model-new.egg model.bam
the advantage is that you will not increase your code, and you dont have to start the 3d modeller again to fix it.
with egg-trans the model gets completely messed, I think egg-trans doesn’t rotate the armature
with the method suggested by Hypnos, It seems to rotate the model well, but does not load it: model-new is not a character! Some animation info got lost in rotation.
For me, models are good examples of the butterfly effect, so I feel inclined to use a software workaround, but thank you for the replies anyway.
It would be a surprise if bam2egg preserves animation.
How about this :
egg-optchar can be used to rotate a model and all of its animations at the same time. You have to give all of the related egg files on the same command line and let it process all of them.
Hmm, my original advice would have worked if you pass flattenable = 0 to the Actor constructor. But this adds a little bit of additional overhead, so you might be better off using the egg-optchar trick instead.
It works! The models and their animations get rotated with egg-optchar and they look right.
Luckily, the number of models in my project is … well, not overwhelming, so it won’t be a problem to rotate them all this way. Thank you all.