Help with LinePick

Blitz3D Forums/Blitz3D Beginners Area/Help with LinePick

Yue(Posted 2014) [#1]
I could not quite understand how a LinePick, I remember that I spoke no English and use the google translator.

I would like a small example or something as detailed as in explanation.


A greeting.

Edit:
Ok, Trial and error the only way to learn.

Graphics3D 800,600,32,2
SetBuffer BackBuffer()


Local Camara% = CreateCamera()
Local Luz%    = CreateLight()
Local Cubo%   = CreateCube()

PositionEntity Camara%,0,0,-10
EntityPickMode Cubo%,2
While Not KeyDown(1)
	Local Linea% = LinePick(0,0,-10,0,0,10,0)
	UpdateWorld 
	
	If KeyDown(203) MoveEntity Cubo%, .1,0,0
		If KeyDown(205) MoveEntity Cubo%,-.1,0,0
	RenderWorld 
	
	Flip 
	
	AppTitle Linea%
Wend 



feeble1(Posted 2014) [#2]
I am not quite sure what you are trying to do. I hope this helps you out a bit.




Matty(Posted 2014) [#3]
A linepick is a way to detect if an entity is at a certain position.

Example:

Firing a gun at a target.

To check if the bullet hits the target you might use a line pick.
The initial coordinates would be the gun's global position. (first 3 parameters)

The vector would be the direction and length to check from that starting point (next 3 parameters).

The last parameter is the thickness of the 'bullet' you wish to use..


Imagine a cylinder pointing from the start point in the direction of the vector you supply with the thickness you supply. If it hits an entity which is marked with the correct pick type mode then it will return the handle to the entity.


Mikorians(Posted 2014) [#4]
I couldn't make a line pick return anything but the entity number and had to switch to entitypick to get anywhere!


Kryzon(Posted 2014) [#5]
Complementing what Matty has said, the linepick is really the "raycast" operation, common in many game engines.
If the 3D line that you specify with the parameters of the function intersects one or more of the pickable entities in your scene, the first of these picked entities has its contact information stored in the Picked(...) functions, like PickedX(), Y() and Z() for the position of the contact and PickedEntity() for returning the handle of the entity that was picked etc.

This is a simple example of AlignToVector that uses a linepick to retrieve the point of contact and the normal of the point of contact of the entity that was picked.




Mikorians(Posted 2014) [#6]
I get pickedentity, and everything else CORRECT, but my loadanimmesh returns only
0,0,0 for pickedx,y,z - the MOST useful functions that I needed.
I carefully set up my linepick.
I also used entityxyz(e,TRUE) for the position, and a nice, long -y value above the shapes.
I'm using ver. 1.106

[EDIT]
Started working suddenly...
Wierd.


RGR(Posted 2014) [#7]
There have been times when the computer was doing what coders had programmed ...

But those times are gone ... today they resist to do their job. They start working when they want ... what a world ...

.


Mikorians(Posted 2014) [#8]
And well I remember those times!

(My object's top was also at y=0, doh!)