pick problems and mesh deformation

Blitz3D Forums/Blitz3D Beginners Area/pick problems and mesh deformation

H. T. U.(Posted 2008) [#1]
I'm an experienced Blitz3D programer, but have never needed to use pick comands or mesh deformation. Now I don't know how on earth to do something as simple as deform a sphere when it impacts another object. I'm not even sure what pick comands exactly do or how to "trigger" a collision using them or any other means. I haven't been this confused since I started C++ several years ago.


Ross C(Posted 2008) [#2]
A pick is basically an invisible line that starts from the co-ords you state. It then travels along a vector/distance you give it.

ie. start (3,3,3)

Then you say how much in each direction you want the pick to go. This will give you another point in 3d space, which is the destination point.

Now, anything between these two points, in a straight line, has the possiblity of being picked, or collided with the line. The line travels from the start point to the end point.

Now, to enable a mesh to be collided with, you need to set the pickmode (EntityPickMode). The most useful setting is the poly pickmode, exactly like the EntityType command.

If the pick collides with anything it will stop and return the entity it collided with. You can read this using PickedEntity().

Global Ball = createsphere()

blah blah set up code and stuff

If PickedEntity() = ball then
   ;Ball entity has been picked
End if


If nothing is picked, PickedEntity will return 0.

The pick command is fairly general and can be used for lots of stuff, but in the case of a collision, you would grab the distance of the collision that happened. Using PickedX(),PickedY() and PickedZ().

As a side note, PickedTime() does NOT return the time it takes, but rather, how far along the line the pick happened. Between 0 and 1. Confusing command...

Anyway, so work out the distance from your start co-ords to the picked x,y and z. If this distance is close enough to trigger a collision, then execute your code.

You can also grab the PickedSurface() and PickedTriangle that the collision happened on. And you can get the normals if you wish to work out a collision angle.

As for deforming a sphere, well if it's completly round, then that should be fairly easy :o) Take the centre point of the sphere and the vertex you want to deform and simply move the vertex towards the centre of the sphere.

Hope some of that helps ya.


H. T. U.(Posted 2008) [#3]
Thanks! That explaines everything (can't wait to try it).