PDA

View Full Version : Translating relative to orientation with matrices


FreakyT
05-21-2011, 10:05 AM
I'm working a script that builds a world and outputs a new VRML file. I'm just doing it in Vizard so I can take advantage of the easy-to-use matrix calculation. Or so I thought...

Anyway, I need to build a road out of components that are rotated, and then translated relative to their orientation. My code looks like this:


current_transform.preTrans(0, 120, 0)
current_transform.preEuler(current_area_curvature, 0, 0)


The idea is that I first rotate the object, and then push it forward in the correct direction. However, when I call


current_transform.getPosition()


I just get [0, 240, 0], [0, 360, 0], etc. Is there any way to move the object relative to its current orientation?

farshizzo
05-23-2011, 08:55 AM
Vizard uses the Z-axis for forward and Y-axis for up. Changing the code to the following should give you the behavior you are wanting:current_transform.preTrans(0, 0, 120)
current_transform.preEuler(current_area_curvature, 0, 0)

FreakyT
05-23-2011, 07:16 PM
Vizard uses the Z-axis for forward and Y-axis for up. Changing the code to the following should give you the behavior you are wanting:current_transform.preTrans(0, 0, 120)
current_transform.preEuler(current_area_curvature, 0, 0)

Ah, that did the trick. Thanks!