line pick

Blitz3D Forums/Blitz3D Beginners Area/line pick

Ben(t)(Posted 2007) [#1]
can someone help me on how to use this? I'm very confused.


jfk EO-11110(Posted 2007) [#2]
It's simple. THe entities you may pick must have their pickmode set, see ENtityPickmode.

Everything else is explained in http://www.blitzbasic.com/b3ddocs/command.php?name=LinePick&ref=goto

cube1=createcube()
positionentity cube1,0,0,50
entitypickmode cube1,2

pick=linepick(0,0,0,0,0,100)

if pick=cube1 then print "picked the cube mesh"


see also:
http://www.blitzbasic.com/b3ddocs/command.php?name=pick&ref=goto


Ben(t)(Posted 2007) [#3]
I still don't entirely understand so is the pick going in all directions?


mindstorms(Posted 2007) [#4]
in the example, the line pick is from point (0,0,0) to point (0,0,100), so it is traveling along the "z" axis. If any part of an entity is along that line, it will be returned. If a radius was set, the line would look more like a cylinder with the two endpoints being the center of the circles at the ends.


Matty(Posted 2007) [#5]
Linepick -

if an object is 'pickable' then it may be pickable in 3 different ways, either as a sphere, a box or as its actual shape 'polygon' method.

Linepick takes up to 7 parameters, ofwhich the first 6 are mandatory.

as an example:

Linepick StartX,StartY,StartZ,VectorX,VectorY,VectorZ,Radius

StartX,StartY,StartZ is the point in 3d space that the 'pick' command will begin from.

VectorX,VectorY,VectorZ are the distances along each of those axes (x,y,z) from the start position that the 'pick' command will check along.

Radius is how 'thick' the line is. Default value is zero. It can be useful to have a thickness however in some cases.

The result returned from the linepick is the entity handle of any entity which was picked using the values above.

The following functions return values based on the pick most recently performed:

pickedentity() - the entity handle of the last pick command, 0 if nothing was picked.
pickedx(),pickedy(),pickedz() - the point in 3d space that the pick command encountered a pickable entity.
pickednx(),pickedny(),pickednz() - the components of the normal to the point picked.



There are many many uses for a line pick.

Some of these are:

1. As a means of detecting if a player is 'on the ground' by picking from beneath their feet to 'a long way below' and if the pickedy() is small enough they are on the ground, otherwise they should be allowed to fall.

2.Determining if a player is on too steep a slope to stand/move on by using the pickedny() command - if the normal (which is a unit vector) in the y direction is less than a certain tolerance the player should slide down the slop.

3.For determining line of sight from AI players to other objects in the game - cast a linepick from the AI to the object with their own pick modes set to 0 temporarily and ensuring that the level geometry and other objects in game are set to their relevant non zero pick mode. If the linepick returns 0 then the AI can see the object.

There are many others, I've just touched on some more common ones....

Ask as many questions as you need to.


Ben(t)(Posted 2007) [#6]
thank you all so much for the help.
I think I'm starting to understand it, so is there a way to use this instead of entitypick ?