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 / Changing camera views smoothly

Author
Message
Master Sam
16
Years of Service
User Offline
Joined: 15th Jan 2008
Location: Cyberspace
Posted: 21st Oct 2009 14:56
Hi, i'm just messing around with controlling the camera of a character. Right now, if no mouse buttons are pressed, the camera is behind and above the character and can be used to change the direction the character faces. If the right mouse button is pressed, the camera stops changing the direction of the character and can do a 360 around the character.

My first problem is that when you right click, the camera immediately jumps to a certain place rather than staying where it is.
My second problem is that in either camera views, if you rotate too far there comes a point where you cannot rotate any further.

Any help with these problems would be much appreciated, as well as any other suggestions.

Heres my code:
entomophobiac
21
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 21st Oct 2009 16:13
The first problem is because you reposition the camera as soon as you click -- it's different code for working it out. It has a completely different target set and everything, meaning that it won't use its current position but recalculate instead. You have to work it out in another way. I'd suggest to create a general camera class that stores all the specifics, such as position and so on, and then use two separate methods for calculating the different movement modes by modifying these values.

The second problem is because you use dbMouseX(), which returns the X position of the mouse and not the difference between previous movement and old. It has a max value equal to your screen resolution. What you should do is modify the current view incrementally using dbMouseMoveX() to get how much the mouse has moved during a particular sync.
Master Sam
16
Years of Service
User Offline
Joined: 15th Jan 2008
Location: Cyberspace
Posted: 22nd Oct 2009 02:15
OK, Second problem solved, thankyou.

First problem still unsolved...
I'm not sure about how to use the current position of the camera to change to another position.
My class looks like this right now:


And in the main loop:

Im not sure what to put for the RightClick Values, since i had worked that out by using the same position as the object, turning it and then moving it out.
Master Sam
16
Years of Service
User Offline
Joined: 15th Jan 2008
Location: Cyberspace
Posted: 24th Oct 2009 14:57
Ok, i think i'v got a good idea of how to change the camera views...but i'v reorganised my code and the camera isn't doing what its supposed to lol!

The CameraAlt function isn't working as it should - it always changes its angle for a split second then reverts back to the original angle!

Heres the camera functions:



Would anyone be able to tall me whats going on?

Login to post a reply

Server time is: 2024-10-01 16:47:10
Your offset time is: 2024-10-01 16:47:10