Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Which way is forward? :)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 b00ny   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 June 2001 - 10:19 PM

I’m new to this, so please excuse me if this is a stupid question. If an object has been rotated through its axis, how can I determine which way is forwards? My object starts off with its X,Y and Z angles all at 0. So I consider forwards to be in the XZ plane, and depending on the rotation through the Y axis, I can work out how much to translate in X and Z. However, if I then rotate the object through the X axis, say by 90 degrees, then forwards is now in the YX plane. I have managed to get this working on 90 degree rotations, but the code is horrible – I keep track of the current forwards plane using an enumeration. Also, I want it to work for any amount of rotation. Does anyone know of a formula that allows me to work this out based on the current rotations? Hope that’s clear, maybe the code below will clarify what I want to achieve. // x,y and z are all 0 initially pObj->MoveForwards(10.0f); // will move along z axis pObj->RotateY(90.0f); pObj->MoveForwards(10.0f); // will move along x axis pObj->RotateY(-90.0f); pObj->RotateX(90.0f); pObj->MoveForwards(10.0f); // will move along y axis Thanks for reading!

Sponsor:

#2 Tassadar   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 June 2001 - 10:30 PM

Wouldn''t it work when you keep track of a direction vector as well? When calling the rotate function, you also change the vector that sets the forward direction. But then you will also need a vector pointing to the top of your object, orthogonally (don''t know the exact term, maths in English isn''t my strongest point) on the directional vector, so your program knows exactly how to draw the object. In your class, you just save 6 extra variables.

I hope it helps and that I wasn''t too confusing!
Wouter

#3 b00ny   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 June 2001 - 11:34 PM

Thanks for replying Wouter.

So you’re saying I should keep a forward vector.

So initially, if I’m moving in positive Z, it would be [0,0,1]

I think I understand what you’re getting at, I’ll give it a whirl.

Cheers...


#4 Vetinari   Members   -  Reputation: 133

Like
Likes
Like

Posted 23 June 2001 - 03:28 AM

You want to rotate your original view direction by whatever you rotate your camera.


Mike




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS