Game Development Community

Help needed with object space rotation

by Konrad Kiss · in Torque Game Engine Advanced · 11/01/2008 (2:20 pm) · 4 replies

This is something really simple for many community members probably, but I've been having a hard time making this work, and since nobody had such a question before - as far as I could tell -, I decided to ask for help here.

I am modifying the fxShapeReplicator, and I want some of my trees to lie on the terrain instead of standing. Aligning to terrain is done, I just need to rotate the tree shape 90 degrees along the x axis before it is aligned to the terrain.

Can anyone help me out please?

-- Konrad

#1
11/01/2008 (5:35 pm)
Very simple to do actually. While in the World Editor and looking at your replicator in the Inspector panel find these two fields under Object Transforms: ShapeRotateMin and ShapeRotateMax. These will accept values in degrees in the standard "X Y Z" format.
#2
11/01/2008 (6:00 pm)
Thanks Mike, though I was looking for a solution in object space, not world space. The generation of the shape is in the source in fxShapeReplicator.cpp.

I'm not sure if I just add my 90 degrees rotation to the QRotation quaternion (made from the EulerF ShapeRotation) that it would solve my problem. It did not look right when I gave it a try, I believe I need this done in object space to achieve the right result.

My problem is that every transformation I ever did in code was in world space, and I'm puzzled now that I need to make a rotation in object space. I don't know what it'd look like in code.

So some sample code doing rotation (any method) in object space would help me out.
#3
11/02/2008 (1:51 am)
Last time to bump this. Forgive me, I desperately need help with this.
#4
11/02/2008 (5:21 am)
I think I managed to get to the bottom of it, at least this seems to give me what I need:

AngAxisF aa = AngAxisF(Point3F(1,0,0), mDegToRad(90.0f));
	MatrixF objmat = fxStatic->getTransform();
	MatrixF rmat;
	aa.setMatrix(&rmat);
	objmat.mul(rmat);
	fxStatic->setTransform(objmat);