3D Curved lines
Blitz3D Forums/Blitz3D Programming/3D Curved lines
| ||
I want to draw the trajectory of a golf ball as a smooth 3D line. Any idea how one would do this? Example below. |
| ||
You would probably need some kind of 3d line draw first off, and also, a way to break the line into points, to assign your vertices co-ords. Creating the 3d line is fairly easy, however, i'm not much on curve maths, sorry... |
| ||
I see several 3d Line functions like the one below by Fredborg. I suppose I could use this but would need lots of points to get a smoothish line.Function Line3D(mesh,x0#,y0#,z0#,x1#,y1#,z1#) If mesh = 0 mesh = CreateMesh() surf = CreateSurface(mesh) EntityFX mesh,1+16 Else lastsurf = CountSurfaces(mesh) surf = GetSurface(mesh,lastsurf) If CountVertices(surf)>30000 surf = CreateSurface(mesh) EndIf End If v0 = AddVertex(surf,x0,y0,z0) v1 = AddVertex(surf,x1,y1,z1) v2 = AddVertex(surf,(x0+x1)*0.5,(y0+y1)*0.5,(z0+z1)*0.5) AddTriangle surf,v0,v1,v2 Return mesh End Function |
| ||
Check this out... http://filax.celeonet.fr/_fofo/index.php?PHPSESSID=36ea6fb45eec2fed81c8f65c2f09b77f&topic=3004.0 Sadly I think the backslashes were stripped out of the code. |
| ||
That's interesting, but as you said it's mangled. |
| ||
Yeah sadly. I thought Draw3D could do 3D lines? |
| ||
U need bezier interpolation + linedrawing routine |
| ||
There is a good 3d bezier curve lib in the archives. I might try tinkering with that. This is just for a prototype so I could just texture some quads with the 2d trajectories with alpha. Not ideal but would demonstrate the idea. |
| ||
You don't need bezier - you need to actually calculate the trajectory based on initial velocity, gravity and various other factors depending on how accurate you want it. The bog standard physics functions below will help. S = UT + .5 * T^2 D = S * T Store the X & Y coords and then draw the 3d-lines between them. |
| ||
So theoretically I could store the x,y,z coords and use the function in my second post to draw lines between them. Looks like I'll be bust this evening, thanks Stevie G. |