Help with LinePick
Blitz3D Forums/Blitz3D Beginners Area/Help with LinePick
| ||
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 |
| ||
I am not quite sure what you are trying to do. I hope this helps you out a bit. |
| ||
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. |
| ||
I couldn't make a line pick return anything but the entity number and had to switch to entitypick to get anywhere! |
| ||
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. |
| ||
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. |
| ||
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 ... . |
| ||
And well I remember those times! (My object's top was also at y=0, doh!) |