How to 'select' an object in 3D space?

Blitz3D Forums/Blitz3D Beginners Area/How to 'select' an object in 3D space?

Tobo(Posted 2009) [#1]
Dear all,

Say you had a collection of cubes and spheres on your screen, some obscuring others. How would you select individual objects with the mouse?

Hope that question makes sense.

Many thanks.


Tobo


Matty(Posted 2009) [#2]
Have a look into the camerapick command in the documentation. That covers this kind of thing, as do linepick and entitypick.


Uncle(Posted 2009) [#3]
Hi,

First of all you would need to make the entities pickable using the entitypickmode command (http://www.blitzbasic.com/b3ddocs/command.php?name=EntityPickMode&ref=3d_cat). Here you can also state that the object obscures others.

Then you would need to do a camerapick command (http://www.blitzbasic.com/b3ddocs/command.php?name=CameraPick&ref=3d_cat) at the mousex(),mousey() coordinates. In fact the camerapick help page has an example of what you are looking for.


Cheers,


Unc


Tobo(Posted 2009) [#4]
Many thanks, guys.

T


Ross C(Posted 2009) [#5]
It's best also, if you have a lot of objects, to look into using Object() and Handle() commands.

The basic idea is, you store the handle to a type object, inside the EntityName() field of an entity. This way, when you pick an entity, you can call EntityName() on it and move directly to the type object holding the information about the entity. It saves you cycling through each type object and comparing the handles against the one you picked. You obviously have to be using types to do this :D