Mesh pivot [SOLVED]

can i change the mesh rotation pivot?

my exported models are always with the wrong pivot and i cant manage to fix on blender.
So i would like to change it by code. Any tips?

thanks :slight_smile:

The mesh rotation pivot is always the origin of the node, in Panda. So, to change the rotation pivot, you must change the origin.

One way to do this is to apply a transform, then flatten it onto the vertices, like this:

model.setPos(10, 5, 0)
model.flattenLight()

This puts the rotation pivot at the point that was previously -10, -5, 0.

Another approach, if you can’t flatten, is to create an intervening node:

top = NodePath('top')
model.setPos(10, 5, 0)
model.reparentTo(top)
top.reparentTo(render)

Now operate on top instead of model, and the rotation pivot is the point (-10, -5, 0) on the model.

David

thanks a lot dwr!