Moving objects

This topic is 5395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I've implemented a camera using Right, Up and Look vectors. Now I want to move objects within my world. The question is do I use the same system? The objects should have space-sim style manoeuvring. Thanks in advance Derek

Share on other sites
There's no reason why you can't use an at/right/up system to update objects. I'm using that system for my soccer game I'm writing. You will also be able to incrementally yaw/roll/pitch the object without fear of the Gimbal Lock provided you incrementally rotate the object's matrix about the object's up/at/right vectors. The only downside is that you'll need to orthonormalise the object's matrix every hundred frames or so as the floating point inaccuracies will build up over time.

Skizz

Share on other sites

How do you build the world matrix?

Derek

Share on other sites
The world matrix is defined as:

-           -| Rx Ry Rz 0|| Ux Uy Uz 0|| Ax Ay Az 0|| Px Py Pz 1|-           -

Where the right vector is (Rx Ry Rz) and so on, P is the position vector.

That is a row major matrix, which DX uses. You can also transpose it to form a column major version which is what OpenGL uses.

I prefer the row major version because you can access the components easier:
Vector *at = (Vector *) ((float *) matrix) + 8);

Using C++ you can make the above neater by doing the following:
class Matrix{public:    Vector &GetAt (void) {return at;}    // and so onprivate:    Vector right; float r0c3;    Vector up; float r1c3;    Vector at; float r2c3;    Vector pos; float r3c3;};

Skizz

Share on other sites
Thanks Skizz. I'm moving now. :)

Derek

Share on other sites
I suppose there's a good reason why when I initialise Look to (0.0f, 0.0f, 1.0f) my object points toward the -z axis.

Any why it is necessary to use a negative value to move the object forward?

Derek

Share on other sites
Yep. It's most likely you're using 3Ds or simular modeler and your exporter has it's forward axis backwards.

My DirectX (quest) exporter has it's forward backwards as well. Rather than fix it or recode my own exporter, I just build my models facing backwards [lol]. How lazy is that?

The only other alternatives are to rotate all of every model's vertices 180 degrees on the Y axis when you load it, or simply multiply all of your matrices by a 180 y rotation. Both can cause problems when working with skeletal meshes.

Share on other sites

The models I'm using are out of the DX9 SDK.

Derek

• 18
• 29
• 11
• 21
• 16