relative to model without calculating scale?

so wich would be the best method for not taking in account a model scale when doing operations relative to that model?

for instance:

#we have a model scaled *.1

if we do:

model.setPos(model,0,0,1)

the model will be displaced only .1 up, when we want to displace it 1 unit

thanks!
c

It is logical that if the model is scaled, its local coordinates are scaled too. More, some models are created with Y-up coordinates, while Panda uses Z-up by default. Moving/rotating other nodes relative to such model becomes real mess.
The far better way is to create another model_parent nodepath and reparent the model to it. Then you can move/rotate this model_parent to place the model accurately. If you need to do anything relative to the model, just do it relative to model_parent instead.

yep, that is what i’ve been doing…

just wanted to know if there was a magic method built in panda, cause sometimes you want to work just with numbers, not rotating and moving doomies…

Thanks birukoff

The best way is not to scale your model at all. It’s a performance benefit if you don’t. Either scale it right in the modeling program, but you can also call flattenStrong after you loaded and scaled it.

model = loader.loadModel(yadda yadda)
model.setScale(.1)
model.flattenLight()

flattenLight applies the transform to the vertices, so you will afterwards be able to do setPos fine.

oohhh i see, i was still wondering what was the flatten thing :slight_smile:

so to “flatten” is to rearrange all vertices of the mesh so then the model size resets to 1?

wich is then the diference between strong and light?

wow thanks to flatten sounds a great solution!

flattenStrong does a lot more than flattenLight, it also tries to merge all the nodes into one. If it’s a static model, it sure can be a good idea to call first clearModelNodes and then flattenStrong on the model as performance optimization.

i see,
so what about animations, still work after flatten calls?

really this will make my life easier!

It works with actors, just there are some nuances. Flattening actors: discourse.panda3d.org/viewtopic.php?t=4678
Also, be careful when you use flattening in real-time. It takes quite some time to call flattenStrong().

of course it may take his time, specially on complicated models, but thanks a lot for the info, i’ll play a bit with flatten asap :slight_smile: