don't you hate it when you work on something for three days, post it on the forums, and then figure it out in an hour?
anyway here is the function that works now.
feel free to use it along with the TOK_SetMesh command that's used in the wrapper examples :)
anyway here is the function that works now.
Function TOK_AddTerrainMesh(mesh,mat=-1,textureindex=0) If EntityClass(mesh)<>"Terrain" Then RuntimeError "Not a terrain in TOK_AddTerrainMesh" scount=TerrainSize(mesh) ttltris=ttltris+((scount-1)*(scount-1)*2) ttlvert=ttlvert+(scount*scount) ResizeBank triangles,ttltris*24 ResizeBank vertices,ttlvert*16 ctr=ttltris tric=tric+cvt cvt=ttlvert ;add vertices to bank For x=0 To TerrainSize(mesh)-1 For z=0 To TerrainSize(mesh)-1 TFormPoint x,TerrainHeight(mesh,x,z),z,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 Next If mat<=0 mindex=0 Else mindex=mat EndIf ;fill bank with triangles For x=0 To TerrainSize(mesh)-2 For z=0 To TerrainSize(mesh)-2 v1=(x*TerrainSize(mesh))+z v2=(x*TerrainSize(mesh))+z+1 v3=((x+1)*TerrainSize(mesh))+z+1 v4=((x+1)*TerrainSize(mesh))+z PokeInt triangles,offsett,tric+v1 PokeInt triangles,offsett+4,tric+v2 PokeInt triangles,offsett+8,tric+v3 PokeInt triangles,offsett+12,mindex PokeInt triangles,offsett+16,0 PokeInt triangles,offsett+20,0 offsett=offsett+24 PokeInt triangles,offsett,tric+v3 PokeInt triangles,offsett+4,tric+v4 PokeInt triangles,offsett+8,tric+v1 PokeInt triangles,offsett+12,mindex PokeInt triangles,offsett+16,0 PokeInt triangles,offsett+20,0 offsett=offsett+24 Next Next End Function
feel free to use it along with the TOK_SetMesh command that's used in the wrapper examples :)