How would you go about cycling through all the vertexs in a mesh?
Cycle through all vertexs
Blitz3D Forums/Blitz3D Programming/Cycle through all vertexs for surf_no = 1 to countsurfaces(mesh)
for vert_no = 0 to countvertices(surf_no)-1
{do something to vert}
vertexcolor surf_no,vert_no,blah,blah,blah
next
next
... or did you mean something else??
for vert_no = 0 to countvertices(surf_no)-1
{do something to vert}
vertexcolor surf_no,vert_no,blah,blah,blah
next
next
... or did you mean something else??
yeah, that's what i mean, but i'm looking to get the co-ords of the vertexs. It's the index number that's putting me off tho. How do i get the vertexs index. When i cycle thru, i imagine it's starts at index 0?
Here's an example, a function I wrote to examine vertex information.
I usually copy the DebugLog output and paste it into an empty window in the Blitz IDE.
The MaxVertices parameter is there so I can quickly examine some vertices without filling up the DebugLog with thousands of lines of output.
If you want all vertices just use a huge number like 999999.
; Sample usage of DumpVertices. Graphics3D 800,600,16,2 cone=CreateCone(5) dumpvertices(cone,100,"Blitz primitive: Cone(5)") Stop : End Function DumpVertices( mesh, maxVertices, message$="Vertex list" ) Local nSurfs, sIndex, surface, vCount, lf$, txt$ Local x$,y$,z$, nx$,ny$,nz$ lf$=Chr$(10) nSurfs=CountSurfaces( mesh ) DebugLog lf+message+lf DebugLog "Number of surfaces = "+nSurfs For sIndex=1 To nSurfs DebugLog lf + lf DebugLog "Surface = "+sIndex+lf surface=GetSurface( mesh, sIndex ) For v=0 To CountVertices( surface ) - 1 vCount = vCount + 1 If vCount > maxVertices DebugLog lf+"Number of vertices shown = "+(vCount-1) Return End If x = RSet( VertexX( surface, v ), 13) y = RSet( VertexY( surface, v ), 13) z = RSet( VertexZ( surface, v ), 13) nx = RSet( VertexNX( surface, v ), 13) ny = RSet( VertexNY( surface, v ), 13) nz = RSet( VertexNZ( surface, v ), 13) txt="v="+RSet(v,4)+" "+x+y+z+" "+nx+ny+nz DebugLog txt Next Next DebugLog lf+"Number of vertices shown = "+vCount End Function
I usually copy the DebugLog output and paste it into an empty window in the Blitz IDE.
The MaxVertices parameter is there so I can quickly examine some vertices without filling up the DebugLog with thousands of lines of output.
If you want all vertices just use a huge number like 999999.
There are two surfaces on a blitz cone? Never knew that. What does knowing the normals of the vertexs help with?
Thanks for the code :)
Thanks for the code :)
Normals determine how the mesh reacts to light.