# How to make a cube move from a circle a certan amount in a direction based on an angl

• 08-08-2009
azjherben
How to make a cube move from a circle a certan amount in a direction based on an angl
How to make a cube move from a circle a certan amount in a direction based on an angle between 0 and 360?

You use left and right keys to increase/decrease the angle from 0 to 360. (at 361 it goes to 0 and vise versa) and You have a cube that's a little infront of your view. How do I make it move so it's always infront of your view?
• 08-08-2009
zacs7
Are you writing a software renderer? If so you should be able to answer your own question, otherwise you're going down the wrong track.

Or, you need to explain what coordinate system/API whatever you're using uses.
• 08-09-2009
VirtualAce
Quote:

How do I make it move so it's always infront of your view?
You don't. You move the cube and then translate the camera a set distance along the negative look vector of the cube and then create a look at matrix to look at the cube. The look-at matrix becomes the final view matrix for the scene. If you want to swing the camera back and forth gradually for smooth transition effects (think Tombraider style) you will need to use quaternions to spherically interpolate (SLERP) between two different 3D orientations.

Quote:

How to make a cube move from a circle a certan amount in a direction based on an angle between 0 and 360?
Generally the use of Euler angles is a bad idea in a 3D environment. Normally your objects have an up, right, and look vector. Based on those three vectors you can yaw (rotate around the up), pitch (rotate around the right), and roll (rotate around the look). While you can orient items using Euler angles they don't fit easily into yaw, pitch, roll. A better representation is to say you have a set amount of yaw, a set amount of pitch, and a set amount of roll. To say you want to fly off at 135 degrees means nothing. 135 degrees with respect to what orientation and what axes? You could have 135 degrees of roll, pitch, and yaw but that does not mean the end result is the object is moving at 135 degrees with respect to x, y and z axes. Again there is no frame of reference.
• 08-09-2009
azjherben
I have a most of the program done, you can move around with the forward and back arrow keys and look to the left and right with the left and right arrow keys. But so far the cube just stays at the position your at plus one on the x axis, so you can see it. How do I make it so it will be one infront of you, no matter where your looking?
• 08-09-2009
VirtualAce
I just told you.
• 08-09-2009
azjherben
Could someone give some example code?

(They don't have to do it all for me, but I don't have much idea what you are talking about)

I'm using C++ with OpenGL, I can give sorce code if that helps.
Also, yes you can look up and down, but the cube olny needs to move with the left/right view.