PDA

View Full Version : help!!



fox
01-19-2001, 01:05 AM
any one explain and provide code for dragging object under the mouse - i've tried this with gluProject/Unproject but never quite succeeded - but i still need it so i want to give another shot - it is about the only this i have left to do

thanx in advance

chennes
01-19-2001, 08:19 AM
I did it using the selection buffer- the code is a bit too long to include here, since it's mixed into a fairly massive program, but...

When the user starts a drag
..set up selection buffer
..draw scene
..get selections
..manually depth buffer the selections
..if the user has clicked on an object that can drag
....while the user is dragging
......get the new (x,y) of the mouse
......calculate the percentage of the screen that that amounts to
......multiply that by the viewport size
......add it to your translation matrix
......draw the object to the screen

I hope this makes sense - good luck

Chris

Starnut coder
01-20-2001, 09:04 PM
I don't quite understand what you want here.
But from what i picked up you want to be able to click on an object and then move it and release by clicking again.
My suggestion is use collision detection code to check whether the mouse has collided with an object(if you need to know what sort of collision detection ask me).
if collieded check wether the mouse is pressed.
Next if it is pressed you could have a variable:
int pressed[max_objects];
which equals 1 when collided and pressed.
next you have a loop which checks all objects
pressed variable and then moves the object to the coordinates of the mouse.

-Starnut

fox
01-21-2001, 11:27 PM
Originally posted by Starnut coder:
from what i picked up you want to be able to click on an object and then move it and release by clicking again.
My suggestion is use collision detection code to check whether the mouse has collided with an object(if you need to know what sort of collision detection ask me).
if collieded check wether the mouse is pressed.
Next if it is pressed you could have a variable:
int pressed[max_objects];
which equals 1 when collided and pressed.
next you have a loop which checks all objects
pressed variable and then moves the object to the coordinates of the mouse.

-Starnut

yes i think you got the idea do you have code and explaination for the mouse colliding with an object - you could e-mail me thanx