entityPick?

Blitz3D Forums/Blitz3D Beginners Area/entityPick?

timmport(Posted 2006) [#1]
I am attempting to figure out how make a simple trigger for an event by mousing over one object and thus making another object rotate. I undersatnd entitypickmode() and I have a fuzzy notion of camerPick(from looking at samples) and I have hacked something togther using these. However I have no idea how EntityPick is used. There is very minimal documentation on how this specific command is used. Does someone have a very basic example of how EntityPick might be used for the very basic trigger I want to create.


jfk EO-11110(Posted 2006) [#2]
Entitypick doesn't seem to be useful for your purpose. Instead use Camerapick. eg:

cube=createcube()
Entitypickmode cube,2
....
pick=camerapick(mouseX(),mousey())
if pick=cube then print "gotcha!!"
....


timmport(Posted 2006) [#3]
Thank you for posting this exmaple code. It is very useful. As I am new and the documentation of the entityPick (and also camerapick somewhat) is a little sparse can you explain how these two commands funtion differently from each other?


jfk EO-11110(Posted 2006) [#4]
to be honest, I never ever used EntityPick :). As far as I see it will pick the entity that has the lowest distance to the entity that is used with the command. It won't let you control the direction of picking. I have no idea in what situations this could be used.

Camerapick at the other hand is used oftenly, especially by guns, optics etc. It will simply pick the entity that is visible on a certain screen coordinate (correct is: a viewport coordinate, but as long as the screen is equal the viewport this is the same).

You have to set the entity to EntityPickMode mesh,2.

After picking something you can use PickedX, PickedY and PickedZ() to determine the position of the last pick. As well as PickedNX() etc. to obtain the angle of the surface that was picked. This is often used for bullet decals etc.

Imagine Camerapick will send a ray from the camera position in the direction given by the screen coordinate. LinePick, another command of the Pick Family, will also send a ray, but you have to define the start position and the xyz offset to it as the end position of the ray. If it hits an entity, it will return the handle of it, otherwise zero, exactly like camerapick. Unlike Linepick the range of a Camerapick is as far as the CameraRange is set.

A practical use of Camerapick would be to color the crosshair green or red, depending on the target behind it, if it's a civilist or an enemy.

Be aware of the fact that all picks are pretty slow (the longer the range, the slower they are, where the number of polygons in the scene additionally slow it down). You may do a hand full of picks every frame, but that's about it. Don't try to do thousands of picks every frame.


lo-tekk(Posted 2006) [#5]
I always assumed that EntityPick performs a raycast along the local positive z-axis with a given range.