Linepick command

Blitz3D Forums/Blitz3D Programming/Linepick command

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Not my code. It's quite big as well.
If you can hack your way through it may help:
Graphics3D 640,480 
SetBuffer BackBuffer() 

camera=CreateCamera()
light=CreateLight() 

PositionEntity camera,0,1000,0
CameraRange camera,950,1050
CameraZoom camera,75 ; eliminate perspective

Local hit1$,hit2$, rad#=0,dist#=5,mode=1

c2=CreateSphere() 
EntityColor c2,255,50,50 : EntityAlpha c2,0.7
PositionEntity c2,0,0,0 
PointEntity camera,c2 
EntityRadius c2,1 
c3=CreateSphere() 
EntityColor c3,0,0,255 : EntityAlpha c3,0.7
pickLine=CreateCylinder(16,True,c3) ; The pickline radius
RotateMesh pickline,-90,0,0
EntityColor pickLine,255,255,0 : EntityAlpha pickline,0.6
distline=CreateCylinder(8,True,c3) ; The distance line
RotateMesh distline,-90,0,0
EntityColor distline,0,255,0

y#=0

While Not KeyDown( 1 ) 

hit1$="" 
hit2$="" 

If KeyHit(57) Then mode=(mode+1) Mod 3 :; space changes pickmode (none,sphere,poly)
EntityPickMode c2,mode

x#=x+(KeyDown(205)-KeyDown(203))*0.1 ; Left/Right arrow Alters X
z#=z+(KeyDown(200)-KeyDown(208))*0.1 ; Up/Down arrow Alters Z
rad=rad+(KeyHit(210)-KeyHit(211))*0.1 ; Insert/Delete alters radius
dist=dist+(KeyHit(199)-KeyHit(207))*0.1 ; Home/End alters distance

PositionEntity c3,x,y,z
ScaleEntity pickLine,rad,rad,dist/2
PositionEntity pickLine,0,0,rad+dist/2
ScaleEntity distline,0.1,0.1,dist/2
PositionEntity distline,0,0,dist/2

If EntityPick(c3,dist#)<>0 Then hit1$="Entitypick found entity"
If LinePick(x#,y#,z#,0,0,dist#,rad#)<>0 Then hit2$="Linepick found entity" 

UpdateWorld
RenderWorld 
Color 255,255,255
Text 0,0,"X:"+EntityX(c3)+" Y:"+EntityY(c3)+" Z:"+EntityZ(c3)+" Pick:"+mode+" Dist:"+dist+" Radius:"+rad
Text 0,15,"Arrow keys to move, Insert/Delete alters Radius, Home/End alters pick distance, Spacebar changes pick mode"
Color 0,255,0
Text 0,30,hit1$
Color 255,255,0 
Text 0,50,hit2$ 

Flip 

Wend 
End