DarkBASIC / Camera Rotation |
| Author | Message | ||
|
Caleb1994
User Joined: Fri Oct 10th 2008 Location: The Internet you idiot! |
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. + Code Snippet 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 \/ |
||
| Back to top |
|||
|
OBese87
User Joined: Fri Jun 30th 2006 Location: On Toast |
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 |
||
| Back to top |
|||
|
Google Ad
AdBot Joined: Aug 26th 2002 Location: Everywhere |
|||
| Back to top |
|||
|
OBese87
User Joined: Fri Jun 30th 2006 Location: On Toast |
OK so as we tilt upwards (x/z axis) we want the x/z movement to decrease. + Code Snippet 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 |
||
| Back to top |
|||
|
Caleb1994
User Joined: Fri Oct 10th 2008 Location: The Internet you idiot! |
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 \/ |
||
| Back to top |
|||
You must be logged-in to post messages to this forum. You can register an account for free. Or click here to login.
Forum Search
Enter a word or phrase to search our Forum for:
|
|



