The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
DarkBASIC / Camera Rotation

Go to the first page of this board Return to the Forum Menu Post Message
4 Messages - Page   of 1   
Bookmark and Share Search the Forum

Author Message
Caleb1994

User


Joined: Fri Oct 10th 2008
Location: The Internet you idiot!
Posted: 6th Nov 2009 20:49     Edited: 6th Nov 2009 21:29     | link | toggle

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
d.x = (d.x*camMat.m00)+(d.y*camMat.m10)+(d.z*camMat.m20);
d.y = (d.x*camMat.m01)+(d.y*camMat.m11)+(d.z*camMat.m21);
d.z = (d.x*camMat.m02)+(d.y*camMat.m12)+(d.z*camMat.m22);


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
MyDarkPrograms
Report this message as abusive
OBese87

User


Joined: Fri Jun 30th 2006
Location: On Toast
Posted: 7th Nov 2009 06:16           | link | toggle

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
Report this message as abusive
Google Ad
Back to top
 
OBese87

User


Joined: Fri Jun 30th 2006
Location: On Toast
Posted: 7th Nov 2009 06:41           | link | toggle

OK so as we tilt upwards (x/z axis) we want the x/z movement to decrease.
+ Code Snippet
inc cposz#, cos(cangy#) * cos(cangx#)
inc cposx#, sin(cangy#) * cos(cangz#)


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
Report this message as abusive
Caleb1994

User


Joined: Fri Oct 10th 2008
Location: The Internet you idiot!
Posted: 7th Nov 2009 16:56     Edited: 7th Nov 2009 17:05     | link | toggle

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
MyDarkPrograms
Download: 3d Calculations.exe Size: 633856 bytesReport this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
4 Messages - Page   of 1   
Search the Forum

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:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Dark Game Studio
Privacy Policy AUP Top of Page