Archived

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

Ritual Magic

Looking for a wee bit of source code (or advice)

Recommended Posts

Hiyas all OK, first off, this all started with one of NeHe''s tutorials, so I''m going to refer to it a little bit, but anyhow, here''s the basic question... In tutorial 10, there is some simple enough code for a camera (meant to be a FPV I assume) moving around a landscape (very small). Now, in this code, the arrow keys are used to move - up and down are forward and backward, left and right are turn, and page-up and page-down are look up/down. I wanted to adapt this code so that I can use the mouse to look around while using the arrows to move (ala quake etc). Now, to make life a little easier on myself, I disabled the side arrows (I wanted to turn with the mouse, and I''ll deal with strafing later). Also, I decided to go "spaceship" rather than "running about" mode - i.e. I want to move in 3D space like a spaceship would, through all 3 dimensions. OK, so my problem is something like this (forgive any unclear thingies here - I''m not really wrapping my bain properly around this...): We have an origin, (0,0,0). Let''s assume this origin is where the camera currently is. Now, in order for me to move "forward", I would need to define a direction made up of all three factors, x, y, z - is that right? Assuming (lol) that''s correct, then this would be a vector? Assuming THAT lot is right, does anyone have any simple source code (doesn''t need to include any mouse handling or GL functions - I just really need the trig) that would work out the numbers in this case? Hell, I know source is alot to ask - a link to an article, a bit of maths advice, anything would be nice As usual, any criticism/flames/advice/morals/dubious sayings/bad jokes/etc much appreciated. I only hope I''ve made myself clear enough to be comprehensible on some level. Sorry to go on so long, but I''m a windbag RM.

Share this post


Link to post
Share on other sites
Hokie dokie

Well, I did a bit of mucking about with the code...I can now get the rotations working properly, but I still can''t get the Y-translation working...I just don''t know the geometric formula :/

Still, I''m sure I''ll figure it out eventually

Thanks for the tips, btw max - that is EXACTLY what I did in the end hehe

RM.

Share this post


Link to post
Share on other sites