Help Needed with 3D accelerated 2D lines
Blitz3D Forums/Blitz3D Programming/Help Needed with 3D accelerated 2D lines
| ||
| I've written this code to emulate the 2d Line function using single surface triangles. The code works great as long as the origin of the line is 0,0. If I change the origin it all goes a bit "Pete Tong". Can anyone help? I also want the origin to map on to the normal 2d co-ords, ie. 0,0 = Top Left. Thanks in advance. |
| ||
I have adapted that for better 3d lines - may help.
Function Line3d( mesh, x0#,z0#,x1#,z1#, y# , r, g, b)
If mesh = 0
mesh = CreateMesh()
surf = CreateSurface(mesh)
Else
surf = GetSurface(mesh,1)
If CountVertices(surf)>30000
surf = CreateSurface(mesh)
EndIf
End If
dx# = x1 - x0
dz# = z1 - z0
d# = Sqr( dx*dx + dz*dz ) * 4.0
dx = dx / d
dz = dz / d
v0 = AddVertex( surf , x0-dz, z0+dx , y )
v1 = AddVertex( surf, x1-dz, z1 + dx, y )
v2 = AddVertex( surf, x1+dz, z1 - dx, y )
v3 = AddVertex( surf, x0 + dz, z0 - dx , y )
For v = v0 To v3
VertexColor surf, v, r,g, b
Next
AddTriangle surf,v0,v1,v2
AddTriangle surf,v2,v3,v0
entityfx mesh,2
Return mesh
End Function
|
| ||
| Your the man. I always make it too complicated :) |