Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Camera Rotation

Author
Message
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 7th Nov 2009 03:49 Edited at: 7th Nov 2009 04:29
I know. there was already a post about 3d in 2d, but it floated down to the bottom, and i need help lol


I am sorry this is from DarkGDK so there are types in here. just think of em as variables. d.x is the x distance from object to camera d.y is y distance z is the z distance. camMat.m00,10,20,01,11 blaa blaa blaa is the camera rotation matrix. it's 3x3 matrix.



isn't this the correct formula to find the rotated vector?

Again sorry about the DarkGDK but no one would answer in the DarkGDK forum(i geuss no one wanted to touch this hahaha) I know latch was helping before so i was just wondering.


Edit:


Nevermind! I got it! it had to do with the fact that i needed to use radians and the way i was calculating the angleX and angleY(i was doing mouse look)

I do have another question. How would i know how to move the camera 'forward' after rotation?

New Site! Check it out \/
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 7th Nov 2009 13:16
Quote: "I do have another question. How would i know how to move the camera 'forward' after rotation?"

Use the sin and cos of the camera's angles and that will give you the x, y and z factors for the movement.

For example if your camera starts off facing straight down the z axis the angle would be 0,0,0 and to move forward you'd just want to move along the z axis. cosine returns 1 at 0 degrees so we use it.
inc cposz#, cos(cangy#)
Now if you turned the camera 90* to the right we'd want to move solely along the x axis. cosine returns 0 at 90* so that still works for our z movement but for x movement we use sine.
inc cposx#, sin(cangy#)

Here's where the third axis messes things up a bit. If we point the camera upwards (cangz#=90) while it's facing right (cangy#=90), when we move the camera forwards (up) it will still strafe to the right. So we need to go back and alter the x and z movement formulas to account for y movement.
Here's where I'm a bit rusty so I might get this wrong...

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 7th Nov 2009 13:41
OK so as we tilt upwards (x/z axis) we want the x/z movement to decrease.


I'll stop there, I think that works and hopefully that's enough for you to elaborate on.

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 7th Nov 2009 23:56 Edited at: 8th Nov 2009 00:05
Something weird is happening when i try to apply this. It's not moving correctly, and the camera rotation is going wierd. i uploaded a exe because this(as i said) is in dark GDK not dbc(because i wanted structures, and pointers they are easier for this type of thing).

If you do know c++(anyone not just obese) then you can email me, because i don't want to put dark GDK stuff on this board. at this point this is still a math question, but the moment i put code then it will have to do with a certain language.

up and down to move. shift and ctrl control the FOV(i know useless for this but it's there lol), and Mouse to look around. escape to exit.

New Site! Check it out \/

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-04 04:11:17
Your offset time is: 2024-05-04 04:11:17