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 / Need Help Limiting Camera Movement

Author
Message
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 3rd Apr 2009 13:22
Hell, I am trying to write a function that will allow me to easily control the movement of my camera/character. The code I have works, with an exception: Basically I can't figure out how to limit the camera along the X-axis.

For example, if perfectly horizontal where 0 degrees I would want the camera to stay between -70 and +70 degrees of the horizontal plane. Everything I have tried either locks the camera at -70 degrees, or properly bounds the camera at -70 degrees but also causes the camera to be set to -70 degrees when the camera moves beyond +70 degrees (I hope this was clear).

Here is my code so far, I would be grateful if someone could help me out with this.



This function is of course called in my main loop. Also, the way I want this to work, when ever you let go of the right mouse button the cursor is made visible again and the mouse is set to the position it was in before clicking the right mouse button.

Thanks.
DaddyJ
15
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 3rd Apr 2009 18:56
I didnt see any checks for when the camera exceeds -70 or +70 degrees, wouldnt you need to check if the camera exceeded this value, and adjust accordingly?
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 3rd Apr 2009 19:18
They weren't in that section of code because none of them worked.

The checks where:




No changes to the equality signs made any difference.
Warspawn
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Arizona
Posted: 3rd Apr 2009 19:47 Edited at: 3rd Apr 2009 22:39
try calling this function after you rotate the camera, it will fix the rotation within the limits you want.

Note: the problem you are having with your above, is that you are limiting rotation about the X axis, where I think you want to limit rotation about the Y axis.




so you could call it after you apply rotations to keep it within bounds. ex: clampCameraAngle(0, 0, 0, -70, 70, 0, 0);

-Warspawn
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 3rd Apr 2009 21:02
Your code does not seem to be working for me. I have the exact same issue I had before. Depending on exactly what values I put it the code either locks my camera to the floor or binds the lower limit correctly, but when ever you reach the upper limit it jumps you back down to the lower limit.

This only seems to be affecting the X-axis though, I can use that code to correctly clamp the Y and Z axis.

PS, in case I wasn't clear, I want to be able to move the camera in the X and Y axis, but have the camera clamped between -70 and +70 so you can't flip the camera around and have an upside-down camera.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Apr 2009 00:43
Adapted from DBPro code I use and untested:


ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 4th Apr 2009 01:35
That works perfectly, thank you very much!
Warspawn
19
Years of Service
User Offline
Joined: 6th Apr 2005
Location: Arizona
Posted: 4th Apr 2009 01:58
ok, i used this, and it works just fine. however I noticed it didnt seem to work until I put in the matrix as reference. but i dont know why that would be...


-Warspawn
ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 4th Apr 2009 05:59
So I got that piece of code working, everything was perfect and all that jazz. Sudden;y I get the great idea that this would be the time to start working on integrating some of the various "mods" for DarkGDK, such as Sparky's plug-in (2.05b). I have made a fair amount of progress in integrating the code from the example "SlidingDemo" into my character control paths. The only problem is that in the process I seem to have introduced two new problems (and a 3rd lesser one).

Basically the method for limiting the camera no longer works and now when ever I right click somewhere on the screen (in order to activate mouse control) my screen becomes centered about that location (or at least very close to it).

The third small problem I am having is that I don't know where to insert my code for adding or decreasing the players movement speed. Some of the places I have tried have resulted in humorous scenarios as soon as I load my map I fly off into space.

Here is my code so far: Note, I created the sphere elsewhere in my program. It is Object#2:




As always, your help is greatly appreciated.

Login to post a reply

Server time is: 2024-09-30 21:38:27
Your offset time is: 2024-09-30 21:38:27