Code fix for a confusing model?

I have a model. I like the model. But, it turns out it’s oriented wrong. What you expect to be its Y is actually its X (and vice versa), ditto with pitch and roll.

So I figure, my options are:

  1. Get it imported into Blender or similar and fix orientation.

  2. Use a different model, but I like this one!

  3. Live with it (the option I’m currently taking). It’s not that hard to remember swapping X/Y and P/R.

But then I pondered, and here’s the question…

  1. Is there a Python ‘code fix’ I could use for this? Some calls on the model to sort her out?

Thanks!

Gary

You could load the model, apply a transformation that swaps X and Y (probably some kind of rotation, but it’s probably easier to use a matrix), and call flattenLight() to apply the transformations onto the vertices.

You could probably also fix it in the EGG file (assuming it is an EGG) by adding a coordinate system tag at the start of the file.
For example:

<CoordinateSystem> { Y-Up }

Interesting. I like the idea of the EGG file fix, I’ll give that a try!

Thanks,
Gary

Nope.

"This entry indicates the coordinate system used in the egg file; the egg loader will automatically make a conversion if necessary. The following strings are valid: Y-up, Z-up, Y-up-right, Z-up-right, Y-up-left, or Z-up-left. (Y-up is the same as Y-up-right, and Z-up is the same as Z-up-right.) "

My problems are not Y or Z related.

I might try the approach rdb gave - or perhaps just live with the model!

Cheers,
Gary

Load it into an image program like 3ds Max, apply a mirror, bake it in, delete the original object, orient and center the mirrored object, export it as an egg.

You could always wrap it in another NodePath if you want.

mycar = loader.loadModel('car')
tmp = NodePath('car-fixed')
tmp.reparentTo(render)
mycar.reparentTo(tmp)
tmp.setH(180) # rotate 180 degrees, or use setX() setHpr() etc...
mycar = tmp

and then your problem is solved.
Pretty? no
will it work? ok

~powerpup118

you can load the file. apply the correct orientation, flattenStrong and writeBamFile. and in the future load the bam file. just remember to keep the egg file because bam can change the format with every major panda version.