Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
camera movement
Topic Started: Apr 8 2009, 02:57 PM (325 Views)
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
i am currently using this to toggle camera movement with mouse:
Quote:
 
if MouseCheckButton(mb_right)
{
GetMousePos();
//Mousecontrol
rotx+=(1-2*invert_mouse_rotation)*(global.mouse_y-display_get_height()/2)*mouse_speed;
roty+=(1-2*invert_mouse_rotation)*(global.mouse_x-display_get_width()/2)*mouse_speed;
SetMousePos(display_get_width()/2,display_get_height()/2);
AdjustCameraPivot();
AdjustCameraPosition();
ManageCameraCollisions();
MoveCamera();
}


this "snaps" the camera to where the mouse is, and then puts the mouse in the middle until you let go.

i need it to do the opposite, i need it to when you right click you have to drag to move it, also the mouse should not go to the middle(a WoW style camera i guess)

Posted Image
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
zelda4evr
Apr 8 2009, 02:57 PM
this "snaps" the camera to where the mouse is, and then puts the mouse in the middle until you let go.

i need it to do the opposite, i need it to when you right click you have to drag to move it, also the mouse should not go to the middle(a WoW style camera i guess)
Add this to the camera Create Event:
Code:
 
prev_mouse_x=mouse_x;
prev_mouse_y=mouse_y;

The following goes into the camera Step Event:
Code:
 
if keyboard_check_direct(mb_right)
{
//Mousecontrol
rotx+=(mouse_y-prev_mouse_y)*mouse_speed;
if (rotx < -60)
rotx=-60;
if (rotx > 60)
rotx=60;
roty+=(mouse_x-prev_mouse_x)*mouse_speed;
}

MoveCamera();

prev_mouse_x=mouse_x;
prev_mouse_y=mouse_y;
Just adapt the above to your code and it should work fine.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
thanks, but its very jumpy, when it moves it jumps around sparatically

Posted Image
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
zelda4evr
Apr 9 2009, 02:29 AM
thanks, but its very jumpy, when it moves it jumps around sparatically
If that happens on your machine, then you'll probably want to use the window functions to get and set the mouse position to what ever.


Another way is to keep the cursor in the center of the screen, and have the movement of the cursor instead add to a fake mouse_x and mouse_y . That WILL work on every machine.
Blog|EHS
Offline Profile Quote Post Goto Top
 
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
i need the mouse to be able to move freely because i need an advanced gui, how is the first method done?

Posted Image
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Simply, it isn't.

You can fake a mouse, as I said.

Code:
 

//Mousecontrol
mouse_difx = (global.mouse_x-display_get_width()/2);
mouse_dify = (global.mouse_y-display_get_height()/2);
SetMousePos(display_get_width()/2,display_get_height()/2);

// Drag control
if keyboard_check_direct(mb_right)
{
rotx += (mouse_dify)*mouse_speed;
roty += (mouse_difx)*mouse_speed;
}

// Move control
MoveCamera();

// Fake mouse control
fake_mouse_x += mouse_difx;
fake_mouse_y += mouse_dify;


See?
Blog|EHS
Offline Profile Quote Post Goto Top
 
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
kind of, im not really understanding it though, i understand it, but i don't get how it works enough to make my own. ugh...cameras...

Posted Image
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Code:
 
//Mousecontrol
mouse_difx = (global.mouse_x-display_get_width()/2);
mouse_dify = (global.mouse_y-display_get_height()/2);
SetMousePos(display_get_width()/2,display_get_height()/2);


Imagine that Windows normally does that code for you. It measures the mouse movement, and adds that measurement to the mouse position.

Here, we sorta override that: we're instead taking the mouse movement measurement 'directly' from the mouse. We must supply the mouse ourselves.
Blog|EHS
Offline Profile Quote Post Goto Top
 
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
i see...i still have no idea how to code this :P maybe ill just ditch mouse+camera

Posted Image
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
zelda4evr
Apr 9 2009, 04:59 AM
maybe ill just ditch mouse+camera
I say try it. The more effort, the more proud you feel, even if it's crap.
Blog|EHS
Offline Profile Quote Post Goto Top
 
zelda4evr
Member Avatar
Forum God
[ *  *  *  *  *  * ]
ya but this is something that i plan on releasing within the next few days, and i need to solve my problems asap, and it has to be as polished as possible

Posted Image
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply