Convert Coordinate System of a Point3[SOLVED]

I tried to search for an answer for this question on the forums but I kept getting a google error about automated requests when I tried to view anything but the first 10 results.

I’m wondering if there is an easy way to convert a Point3 from one coordinate system to another.

I am taking coordinates from a modeling package and manually typing them into a text file, then loading that text file in code and creating Point3s from it. The modeling package is using a Y-up coordinate system, and Panda3D uses a Z-up, so obviously there needs to be some conversion done. Of course, I could do this either manually or in code by just plugging the Y coord from the modeling package into the Z coord of the Point3, but I thought I would ask if there is a built-in way to do it, like for example:

convertedPoint3 = someFunc(Point3, fromCoordSystem, toCoordSystem)

or something to that effect.

Sure, you just need to apply a rotation matrix. Specifically, the Y-to-Z-up matrix, which is returned by Mat4.YtoZUpMat().

m = Mat4.yToZUpMat()
convertedPoint3 = m.xformPoint(sourcePoint)

You can also use Mat4.convertMat(fromCoordSystem, toCoordSystem) to return the appropriate rotation matrix in general.


Ah, neat, thanks.

Looks like the right one for Lightwave is:

Mat4.convertMat(CSYupLeft, CSDefault)