Create a simple line between 2 bodies?
Blitz3D Forums/Blitz3D Beginners Area/Create a simple line between 2 bodies?
| ||
Hi, does anybody know a easy way to create a simple line between 2 bodies, or pivots in a 3 dimensional world? |
| ||
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. |
| ||
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 |
| ||
Ohh, so simple :) Thanks stevie! |
| ||
couldn't you also draw a 2d line between two picked entities? |
| ||
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 |
| ||
@Tab: This is nice! I didn't know that there are so simple solutions^^ |
| ||
Hey guys - I love this community when it works like this - fabtastic answers! IPete2. |
| ||
Steve G's answer as usual is simple,useful and focused on solution Thanks Steve |
| ||
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) |
| ||
*Itchy trigger finger* |