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.

Dark GDK / Wierd problem with camera and player rotation.

Author
Message
Isocadia
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 10th Sep 2009 19:52
Well, when i rotate my camera, it moves correctly for 180 degrees, but after that the camera starts to do wierd things:

So i start to turn my object:



Then i reach about 180 degrees ( i turn 90 but you can do it in both ways ):



And then i cross the range and the camera moves one way instead of staying behind the object.



Can someone help me solve this problem???

Isocadia
Red Eye
16
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 10th Sep 2009 21:17
Sometimes using a user made camera instead of the normal 0 cam, fixes some issues.


Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 10th Sep 2009 21:43
Please post the code. It's impossible to tell what's happening without seeing the program.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 11th Sep 2009 00:29
Yeh, code would be good.
Also useing dbText to display your angles on-screen can tell you alot more about what is going on.

Did you know there are two types of rotation? The documentation is not very clear on this matter and it can cause alot of confusion.
The two different types cannot be used together or you get strange results, anyway thats just a guess, we would need to see code.
Isocadia
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 11th Sep 2009 15:18
Oh xD, forgot the code. Here it is:

Camera.cpp


Player.cpp



Right now the camera should just follow the player, later i will try to make a independent camera movement system.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 12th Sep 2009 14:11 Edited at: 12th Sep 2009 14:18
I suggest not to use the dbTurnObjectLeft/dbTurnObjectRight functions. The problem is that Dark GDK likes to use negative angles during rotation (you can see it if you print the dbObjectAngleY on the screen) and I guess that confuses what is left and what is right. It's best to calculate your own angles, making sure they stay in the 0-359 range. For example:



Also, in the MoveCamera function, delete the dbYRotateCamera line. I tested the code with these modifications and it works, the rotation does not change direction. Of course the code can be optimized by storing the rotation angles in variables instead of querying the object angles all the time, but the main point is keeping the angles in the positive range.

(If someone knows a more scientific explanation of what the "turn left", "turn right" functions are really doing, then I'd be interested too. They are acting weird.)
Isocadia
15
Years of Service
User Offline
Joined: 24th Jul 2009
Location:
Posted: 12th Sep 2009 18:13
@Mireben: Thanks, that fixed it, so now i'm trying to make my camera being able to move around.

Isocadia
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Sep 2009 20:31 Edited at: 12th Sep 2009 20:33
Quote: "If someone knows a more scientific explanation of what the "turn left", "turn right" functions are really doing, then I'd be interested too. They are acting weird."


Not 100% sure how it works myself but I think that if you want complete freedom of rotation on all three axis you use "turn left" turn right", it is a different rotation than dbRotateObject().
Free rotation in 3D space can be very confusing as the rotations all affect each other and give strange results or cause Gimbal Lock.

To get around this DarkGDK is probably using advanced mathematical techniques(Quaternions) behind the scenes when using the turn, pitch and roll commands and therefore it seems like their angles are all messed up when really they are not.

Login to post a reply

Server time is: 2024-11-20 15:27:21
Your offset time is: 2024-11-20 15:27:21