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.

DarkBASIC Discussion / Something Hard

Author
Message
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 21st Oct 2005 06:39
How do you code it so that you can click on an objet in a 3D world?

--------------
Uncle Sam
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 21st Oct 2005 07:20
Uncle Sam,

Search "Vector Math" on Google.com.



+NanoBrain+
Freddy 007
20
Years of Service
User Offline
Joined: 30th Nov 2004
Location: Denmark
Posted: 21st Oct 2005 15:49
Doesn't DBC have a PICK OBJECT command?

the Last Programmer
19
Years of Service
User Offline
Joined: 14th Jul 2005
Location: Abilene, TX
Posted: 21st Oct 2005 18:33 Edited at: 21st Oct 2005 18:39
Hi Uncle Same,

You taxed me too much last year so I won't answer your post. Just kidding!

You first use the command "pick screen". This command takes in the parameters: xScreen, yScreen, and distance. You plug in the mouse positions like this:

PICK SCREEN mousex(), mousey(), 1000

I picked a 1000 just to give some distance into the 3d scene. Now, dbpro has stored that new 3d position in "get pick vector x,y,z" commands. So now let's create an object in our scene.

MAKE OBJECT SPHERE 1, 100

Now let's go ahead and select that object using the command "object intersect" AND store the 'get pick vectors' and the object's position and the camera's position in variables.

vectorX# = get pick vector x
vectorY# = get pick vector y()
vectorZ# = get pick vector z()

objPosX# = object position x(1)
objPosY# = object position y(1)
objPosZ# = object position z(1)

camPosX# = camera position x()
camPosY# = camera position y()
camPosZ# = camera position z()

disVar# = intersect object(objNum, camPosX#, camPosY#, camPosZ#, vectorX#, vectorY#, vectorZ#)

Now, we test if it hit the cube I had made or not.

if disVar# = 0 THEN hide object bounds 1
if disVar# > 0 THEN show object bounds 1

Now there you have it!!!! Object selection.

Here is an example and a function if you still need help.




Now you know how to select an object so create the next great video game!

go to my website to download cool new games:

www.fishbrosentertainment.net
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 21st Oct 2005 19:05 Edited at: 21st Oct 2005 19:06
There is no Pick Screen command in DBC (or Hide Object Bounds or Show Object Bounds, for that matter). That's why NanoBrain suggested researching a method so as to do it manually...

You could always use TDK's way out of MatEdit, which is to have a 3D cone as the mouse pointer that you can move (moving your mouse up moves the object further into the scene and vice versa) and then you could simply check for collision with the cone... But that would not work in all cases.

I also suggest looking up Sparky's DBClassic version of his collision DLL and digging through the demos, as I think I saw one that could do this. And his DLL is teh 1337ness ^_^
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Oct 2005 21:08
I believe too that Sparky's DLL will be the best solution for you:

BTW: DBC doesn't have vectors either...

Immunity and Annihalation makes Immunihalation...
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 21st Oct 2005 22:30
Somebody made a vector math library, don't know if it works too great with the squirrelly DB rotation system though. Phillip has the best begginer's vector tutorial, so try searching around for that.


I'm going to eat you!
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd Oct 2005 11:52
I know about it, though I never got to get it worked...

Immunity and Annihalation makes Immunihalation...
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 23rd Oct 2005 06:25
Thanks for all the help, guys.

--------------
Uncle Sam
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 24th Oct 2005 23:49
Actually, I'm still having trouble.

--------------
Uncle Sam
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 27th Oct 2005 20:32
Don't think it's just you.

It's almost impossible to make an object follow your mouse. There are always alternatives, but pure coding with math are even a pain in the ass for experienced coders.

Immunity and Annihalation makes Immunihalation...
Uncle Sam
19
Years of Service
User Offline
Joined: 23rd Jul 2005
Location: West Coast, USA
Posted: 28th Oct 2005 01:06
Oh...

--------------
Uncle Sam
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 28th Oct 2005 17:29
Remember, there are always alternatives

Immunity and Annihalation makes Immunihalation...

Login to post a reply

Server time is: 2025-05-22 14:11:24
Your offset time is: 2025-05-22 14:11:24