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 / Rotating Camera with Left Click

Author
Message
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 28th May 2009 23:11
I'm trying to rotate the camera by moving the mouse when the left mouse button is clicked but I'm not sure how I would do this.

Can someone help?
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 28th May 2009 23:56 Edited at: 28th May 2009 23:57
if (dbMouseClick()==2) { dbTurnCameraLeft(1); }

prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 29th May 2009 02:14
Isn't mouseclick 2 right click?


Website coming soon!!
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 29th May 2009 02:34
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 29th May 2009 05:23
That doesn't work right because what I want it to do is turn in the direction that I am moving the mouse.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 29th May 2009 09:49


ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 29th May 2009 10:37
That helped at little bit, but for some reason the camera doesn't rotate on the Y axis.

Also, I'm trying to figure out how to invert the rotation so that the camera rotates around the location of the mouse.
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 30th May 2009 03:31
Anyone?
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 1st Jun 2009 05:03
Well then...
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 2nd Jun 2009 09:00
I will try to help but I don't completely understand the question. What do you mean by rotating the camera around the location of the mouse? Could you describe how you want it to behave exactly? Also, what is the problem with the code posted by jezza?
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 9th Jun 2009 21:44
The code that Jezza provided should work but for some reason it does work on the Y axis.

Also I want the mouse to move the camera like an RTS.
Death Protocol
15
Years of Service
User Offline
Joined: 10th Jun 2009
Location:
Posted: 10th Jun 2009 13:25
I've looked over your code snippets, and i've found them to be quite useful in my studies of 3d game design.

I noticed while you move the mouse , the y moves in reverse.
There is a very simple solution to inversed axes. Use negatives.
Example.
Instead of stating:

Just replace dbPitchCameraUp(dbMouseMoveY());
with


All that's being done there is inversing the y axis, thus making the camera rotating properly.

%force #run protocol("final"
"The end of the world is near, what will you do..."?
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 11th Jun 2009 20:43 Edited at: 11th Jun 2009 20:45
I finally got around to testing this problem. First I tried the suggested code with dbPitchCameraUp and dbTurnCameraRight. There were two problems with it. (1) When you press the mouse button for the first time, if you moved the mouse before clicking, then the first reading of dbMouseMoveX/Y will be so large that the camera jumps away and your objects will be out of sight. (2) While moving the mouse around, the camera not only turns but also starts to roll around the Z axis. I'm puzzled why this is happening, but it has an undesirable effect.

To eliminate both these problems, I tried the following code and it seems to work properly:



The MouseDown flag indicates when the mouse button is pressed first, and the first mouse movement reading is discarded, so problem (1) is solved. For problem (2), I would use the dbRotateCamera instead of the right and up functions, to be able to constrain the rotation to only two axes.

Try if this works for you.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 12th Jun 2009 01:40
http://forum.thegamecreators.com/?m=forum_view&t=151682&b=22

did everyone miss this??

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 12th Jun 2009 08:23
Apparently I missed it. That works well too. Thanks for calling attention to the thread.
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 12th Jun 2009 08:40 Edited at: 12th Jun 2009 08:42
Your very welcome =D

I'm also ALWAYS on msn if you would like some 1 on 1 help =D

EDIT: Always = while there is unsecured wifi xD

Login to post a reply

Server time is: 2024-10-01 03:27:03
Your offset time is: 2024-10-01 03:27:03