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 / how to make object follow cursor

Author
Message
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 18th Dec 2004 12:23
Just a little confused.... I want my object to follow my cursor. I would have thought the following code would make that happen in my loop, but it does not....

dbPointObject(2, dbMouseX(),dbMouseY(), dbMouseZ());
dbMoveObject(2,1);

How do I accomplish this?

thanx
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 18th Dec 2004 18:02
Would something like :



be better ?

Beware the cat... The alien... The heretic...
Smithy
19
Years of Service
User Offline
Joined: 8th Dec 2004
Location: Switzerland
Posted: 19th Dec 2004 01:22
As far as I know is the MouseZ for the mousewheel axis.

//Pentium IV 3200E/Prescott; 800Mhz FSB; Hyperthreading; WinXP Pro (!XP2); ATI R9700PRO; 1024MB RAM (2x 512MB "DualChanneled"; VC++; Delphi; ADSL;
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 19th Dec 2004 08:54
Thanx, that helped, but it brings up a couple of question. I put your line of code in my simple app:
dbPositionObject(2,dbMouseX(),0.0,dbMouseY());

Why is the object not real close to my cursor?
Why did you set the Y position to 0?
Why did you set the Z position to dbMouseY()?

The behavior I would expect is that the object would be under my mouse cursor as I moved the cursor around....

I am slightly confused...
Steve O
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: The Netherlands
Posted: 19th Dec 2004 10:42 Edited at: 19th Dec 2004 10:43
the object is positioned in 3D space and not in 2D screen coordinates like the mouse is.

Stevil
21
Years of Service
User Offline
Joined: 31st Oct 2002
Location: Australia
Posted: 19th Dec 2004 20:55
if you are looking at 2D space there is a few tricks to do it. I haven't used DB for donkeys years so it could be simpler now. Back in the day though you need to calculate where abouts in 3D space to position the object. This was effected by the camera angle, FOV, screen res, etc, etc, etc. I used BigDan256's code for this so hard for me to remember EXACTLY it but I think the general idea was that X# distance from the camera is relative to the mouse position (in our case I think it was 20 or 200, it was like 3 years ago give me a break). So position the object that distance from the camera using the new?value commands, then add the mouse positions.

I work with BigDan256 now, he's part of a programming team I lead will order him to answer me the exacts of this method next day he is in the office (which will be the next aussie wednesday I believe). Sorry I'm not much help at the moment.
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 19th Dec 2004 23:55
Thanx. I will wait for the answer. Sounds complicated.
Stevil
21
Years of Service
User Offline
Joined: 31st Oct 2002
Location: Australia
Posted: 21st Dec 2004 17:19
I haven't got it working 100% yet, aslong as you don't rotate camera you are fine got visitors here an still haven't got dan to confirm it properly but I think I can get it without him

You Must First Realise Your Limitations Before You Set Your Goals
Stevil
21
Years of Service
User Offline
Joined: 31st Oct 2002
Location: Australia
Posted: 21st Dec 2004 20:03
Tah Dah



Finally got dan online to help me fix up my equations. This works now God we are good he he he

You Must First Realise Your Limitations Before You Set Your Goals
roujesky
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location:
Posted: 21st Dec 2004 23:23
Hey! Thanx. that really works great. I am at work right now, but tonight I will look at your algorithm closer and will probably have more questions....

Again, thanx
BigDan256
20
Years of Service
User Offline
Joined: 29th Oct 2003
Location: NSW, Australia
Posted: 30th Dec 2004 18:48
It's taking forever for stevil to post the updated code, so here you go:


This one supports the roll and pitch camera commands, and can be converted back to dbpro easy enough

Login to post a reply

Server time is: 2024-03-29 14:53:29
Your offset time is: 2024-03-29 14:53:29