Bot I hope you don't mind...
Mr. Picklesworth
These Functions are in the Documents for tokamak
Mr. Picklesworth
These Functions are in the Documents for tokamak
Global vertices=CreateBank(0),triangles=CreateBank(0) Global offsett,offsetv,tric,ttlvert,ttltris Dim tname$(20),tMindex(20) Global cur=0 Function TOK_SetTextureMaterial(fil$,Mindex) tname$(cur)=fil$ tMindex(cur)=Mindex cur=cur+1 End Function Function TOK_AddMesh(mesh,recurse=0,mat=-1,textureindex=0) scount=CountSurfaces(mesh) For ind=1 To scount surface=GetSurface(mesh,ind) ttltris=ttltris+CountTriangles(surface) ttlvert=ttlvert+CountVertices(surface) Next ResizeBank triangles,ttltris*24 ResizeBank vertices,ttlvert*16 For ind=1 To scount surface = GetSurface(mesh,ind) bru=GetSurfaceBrush(surface) tex=GetBrushTexture(bru,textureindex) nam$=strippath$(TextureName$(tex)) fo=0 For a=0 To cur-1 If tname$(a)=nam$ Then mindex=tMindex(a):fo=1:Exit Next If fo=0 Then mindex=0 FreeBrush bru ctr=CountTriangles(surface) tric=tric+cvt cvt=CountVertices(surface) ;add vertices to bank For v=0 To cvt-1 TFormPoint VertexX#(surface,v),VertexY#(surface,v),VertexZ#(surface,v),mesh,0 PokeFloat vertices,offsetv,TFormedX() PokeFloat vertices,offsetv+4,TFormedY() PokeFloat vertices,offsetv+8,TFormedZ() PokeFloat vertices,offsetv+12,0.0 offsetv=offsetv+16 Next ;fill bank with triangles For v=0 To ctr-1 PokeInt triangles,offsett,tric+TriangleVertex(surface,v,0) PokeInt triangles,offsett+4,tric+TriangleVertex(surface,v,1) PokeInt triangles,offsett+8,tric+TriangleVertex(surface,v,2) If mat=-1 Then PokeInt triangles,offsett+12,mindex Else PokeInt triangles,offsett+12,mat PokeInt triangles,offsett+16,0 PokeInt triangles,offsett+20,0 offsett=offsett+24 Next Next If recurse Then children=CountChildren(mesh) If children>0 Then For childcount = 1 To children child = GetChild(entity,childcount) TOK_AddMesh child,recurse,mat Next EndIf EndIf End Function Function TOK_SetMesh() ;Hand over the terrain data to Tokamak TOKSIM_SetStaticMesh vertices,ttlvert,triangles,ttltris ; Now we can free the banks as Tokamak has copied all data FreeBank vertices FreeBank triangles End Function Function StripPath$(file$) If Len(file$)>0 For i=Len(file$) To 1 Step -1 mi$=Mid$(file$,i,1) If mi$="" Or mi$="/" Then Return name$ Else name$=mi$+name$ Next EndIf Return name$ End Function Function TOK_ReInitializeBanks() vertices=CreateBank(0) triangles=CreateBank(0) offsett=0 offsetv=0 tric=0 ttlvert=0 ttltris=0 End Function