#### Archived

This topic is now archived and is closed to further replies.

# First contact with vectors

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

## Recommended Posts

I''m just starting out with 3d coding and while I understand what I''ve read about vectors so far I must have missed something. I wan''t to write a simple demo that allows me to fly around a cube and loot at it from various angles. Basically if I look do(with mouse) and press forward(up arrow) the I shoudl move down. Getting the input is no problem, I can''t seem however to understand how to do the vector math. Here is what I understand. You start at CurrentPosition, with a veiwing angle of CurrentDirection. After mouse movement you have 2 values. After pushingh forward on the keyboard you have t add x units of forward movement. So, how do I add the mouse''s x,y delta to the CurrentDirection vector, then move X units along that vector so I can update the CurrentPoint x,y,z position. I have looked around for good examples, NeHe has some that are similar but look messy and are locked to the x,y plane. Assume I have access to a vector class like this: http://glvelocity.gamedev.net/files/vector.zip Many Thanks... Chris

##### Share on other sites
Okay first thing, when you move forward in 3D, it''s along teh Z axis not the X. Also, you say something about CurrentAngle. What kind if structure is this? The current direction of the camera should be a vector and the position should be a vertex. Basically you rotate the vector based on your angles and then add each vectors(You have 3, x, y, and z) x to your position.x and y to position.y and z to position.z. you have chosen one of the most math intensive parts of a basic 3d engine to do first, I''d suggest you worry first about getting the cube up in the screen and then rotating around the cube''s center and then move to a full 3d camera. For further info checkt he links section or the GD.net search engine.

##### Share on other sites
I've got the cube up and running, rotating etc...
...

..
Come to think of it the rotating cube is just another Nehe messy looking thing. Taking your advice I should probably get that working with vectors, I guess moving that around would be easier that doing the camera as there is less to screw up(and you don't have to work out where you looking when you have a black screen in fron t of you

Thanks, I probably should have tried that first.... I guess I consider everything except my goal to be the easy parts... (My goal was to make a frustum culled octree that is highlighted by a wireframe'd cubes. The mouse motion was nothing more that a side thought...

I might back off and look for easier stuff... The hard part is that i understand how everything should work(all the pictues are in my head) it's just a matter of not knowing the math to make it work...

gimp

..Oh, and CurrentDirection was a vector and CurrentPosition a Point.

Edited by - gimp on October 5, 2000 11:53:40 PM

1. 1
2. 2
Rutin
25
3. 3
4. 4
JoeJ
18
5. 5
gaxio
11

• 14
• 22
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002215
×