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 Professional Discussion / Pick object question

Author
Message
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 12th Aug 2010 17:36
Hello everyone,

My program has 3d objects that I want to be able to select with a mouse click. Everything works great, but it not only selects the object under the mouse cursor, but also all other objects behind the object I wish to select...

Here is the code I'm using. Any help is much appreciated!




Thanks ahead!

Regards,
Sph!nx
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 12th Aug 2010 17:43
You should order them by distance. Also, I think pick object uses collision spheres or boxes for the collision. If that's the case, you should record all the objects and do another loop to do a raycast and get the shortest distance.

The fastest code is the code never written.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th Aug 2010 18:31
If you only want to pick the front object you should only use "pick object" once. You are calling it in a "for" loop including all of your objects...

Try taking it out of a loop and do it like this:


Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 12th Aug 2010 18:40 Edited at: 12th Aug 2010 18:42
Thanks Hawkblood, but I don't have much experience yet with ray casting...

I've got a de-selection code working that might offer me the solution. What I now need to know, is how to limit the distance of the pick object. Any ideas?

Edit:
Thanks, baxslash, we posted at the same time. I will take a look and give it a try!

Regards,
Sph!nx
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 12th Aug 2010 18:46
When you do a pick object, there are some other commands that will give you more info about the object picked. "get pick distance" I think is what will give you the distance of the object "picked". I can't verify this at the computer I'm on now, but you can go to the help and under "commands" select "basic 3D commands" (or something like that) and under "object expression" (I think) you will find all the "pick" commands. Play around with that and you should find what you need.

The fastest code is the code never written.
Sph!nx
17
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 12th Aug 2010 19:09 Edited at: 12th Aug 2010 19:09
baxslash, your help did it. Though, I've got a slightly different setup than what you provided, in basics it's the same, a separate function!

Thanks a lot to the both of you!


Regards,
Sph!nx

Login to post a reply

Server time is: 2026-07-25 23:12:02
Your offset time is: 2026-07-25 23:12:02