Intersect Range (Raw Collision)

Blitz3D Forums/Blitz3D Programming/Intersect Range (Raw Collision)

Banshee(Posted 2004) [#1]
Is there a way to do a linepick but instead of returning the entity of collision to return the range down the line at which collision occured.

IE: vectorLength#=rangePick(EntityNo,srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#)

Help please, I am struggling to master the supplied collision system! :)


DJWoodgate(Posted 2004) [#2]
PickedTime() does that, more or less. After a successful pick multiply the length of your pick vector by it: pickrange#=pickedtime()*sqr(lenx*lenx+leny*leny+lenz*lenz).

Ignore the docs on pickedtime(), they are barking.

Not sure exactly what you want that rangepick function to do though.


Gabriel(Posted 2004) [#3]
Untested, but should work.


Function RangePick(srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#,radius#)
   LinePick(srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#,radius#)
   If PickedEntity()<>0
      xd#=PickedX#()-srcX#
      yd#=PickedY#()-srcY#
      zd#=PickedZ#()-srcZ#
      Return Sqr(xd*xd + yd*yd + zd*zd)
   End If
End Function




Binary_Moon(Posted 2004) [#4]
You can do a linepick and get the picked x, y, and z positions (along with the normal of the picked object), from which you can work out essentially the same thing.

so it would actually be something like,

rangePick(EntityNo,srcX#,srcY#,srcZ#,lenX#,lenY#,lenZ#) 
vectorLength#=3ddistance(srcx#,srcy#,srcz#,pickedx(),pickedy(),pickedz())


obviously you need a 3d distance function but I'm sure you can work that one out :)


Banshee(Posted 2004) [#5]
Tbank you, I modified your function to return a float and it works perfectly ! (after realising it doesnt pick backfaces that is :) ).

Cheers


Gabriel(Posted 2004) [#6]
Oops, yeah, forgot to make it return a float. Glad you have it working anyway.