Create a simple line between 2 bodies?

Blitz3D Forums/Blitz3D Beginners Area/Create a simple line between 2 bodies?

elcoo(Posted 2008) [#1]
Hi,
does anybody know a easy way to create a simple line between 2 bodies, or pivots in a 3 dimensional world?


DJWoodgate(Posted 2008) [#2]
Using a cylinder mesh is an easy way. I am pretty sure there is something in the code archives that shows how but basically you positionmesh the cylinder so it starts at zero in y, scalemesh so it is unit size and rotatemesh the Y axis into Z. Then you can just positionentity, pointentity and scaleentity in Z to the distance between the two points, setting X and Y scale parameters to the desired thickness.


Stevie G(Posted 2008) [#3]
Something like this ...


Pivot1 = createpivot()
positionentity Pivot1, -10,10,10
Pivot2 = createpivot()
positionentity Pivot2, 10,-10,10

3dLine( Pivot1 , Pivot2 )

;==========================

Function 3dLine( P1, P2 , Thickness# = 1.0 )

  Line = createcylinder()
  rotatemesh Line, 90,0,0
  fitmesh Line, -1,-1,0,2,2,1
  
  entityparent Line, P1
  positionentity Line, 0,0,0
  pointentity P1, P2
  scaleentity Line, Thickness, Thickness , entitydistance( P1, P2 )

End Function




elcoo(Posted 2008) [#4]
Ohh, so simple :)
Thanks stevie!


chwaga(Posted 2008) [#5]
couldn't you also draw a 2d line between two picked entities?


Tab(Posted 2008) [#6]
CameraProject camera,EntityX(Ent1),EntityY(Ent1),EntityZ(Ent1)
TMP_X1# = ProjectedX()
TMP_Y1# = ProjectedY() 				
CameraProject camera,EntityX(Ent2),EntityY(Ent2),EntityZ(Ent2)
TMP_X2# = ProjectedX()
TMP_Y2# = ProjectedY()

Line TMP_X2,TMP_Y2,TMP_X1,TMP_Y1


Bye... =P


elcoo(Posted 2008) [#7]
@Tab: This is nice! I didn't know that there are so simple solutions^^


IPete2(Posted 2008) [#8]
Hey guys - I love this community when it works like this - fabtastic answers!

IPete2.


Moraldi(Posted 2008) [#9]
Steve G's answer as usual is simple,useful and focused on solution

Thanks Steve


Ross C(Posted 2008) [#10]
I think Stevie's solution is more robust in the long run, as when entities go off screen and behind the camera, whilst the other is in front, using a 2d line isn't a great idea :o)


Ross C(Posted 2008) [#11]
*Itchy trigger finger*