a couple of example functions (will need to modified for your project), there are also other ways if using DBO by reading in the embedded DWORD codes:
function ReturnNumberOfObjectVertsIndices(obj,totalMesh,typ)
local vert_count = 0
local index_count = 0
for m = 0 to totalMesh-1
mesh = meshlist(m)
lock vertexdata for limb obj,mesh,lockMode
vertices = get vertexdata vertex count()
indices = get vertexdata index count()
unlock vertexdata
inc vert_count, vertices
inc index_count, indices
next m
if typ = 1
retval = vert_count
else
if typ = 2
retval = index_count
endif
endif
//if debugOutputOn=1
// if typ = 1
// message "total object vertices = "+str$(retval)
// else
// if typ = 2
// message "total object indices = "+str$(retval)
// endif
// endif
//endif
endfunction retval
function ReadObjectMeshData(ObjID,Fname as string )
local vertices as integer
local indices as integer
if file exist(FName)
delete file FName
endif
mtlfile$=extract filename$(change fileext$(FName,".mtl"))
fid = 1
open to write fid, FName
write string fid,"# Wavefront OBJ"
write string fid,"# Created by DBO2X/OBJ v1.0"
write string fid,"# M Fowler (BOTR) (2018)"
write string fid,""
testlimbmeshnum = 0
for l = testlimbmeshnum to array count(meshlist()) //testlimbmeshnum+10 //array count(meshlist())
lock vertexdata for limb ObjID, meshlist(l)
vertices = get vertexdata vertex count()
indices = get vertexdata index count()
write string fid, "#Limb"
write string fid, "#"+str$(l)+", "+limb name$(ObjID,meshlist(l))
write string fid, ""
write string fid, "mtllib "+mtlfile$
write string fid, "#Mesh"
write string fid, "#vertices = "+str$(vertices)
//if debugOutputOn=1
// message "vertice count = "+str$(vertices)
//endif
for i = 0 to vertices - 1
array insert at bottom vertexdata()
vertexdata(i).limbid = l
vertexdata(i).x = get vertexdata position x(i)
vertexdata(i).y = get vertexdata position y(i)
vertexdata(i).z = get vertexdata position z(i)
vertexdata(i).xn = get vertexdata normals x(i)
vertexdata(i).yn = get vertexdata normals y(i)
vertexdata(i).zn = get vertexdata normals z(i)
vertexdata(i).u = get vertexdata u(i)
vertexdata(i).v = -get vertexdata v(i)
next i
if l = 0
lastoffset = 0
lastvertices = vertices
else
lastoffset = lastoffset + lastvertices
lastvertices = vertices
endif
if indices <> 0
for i = 0 to indices - 1
array insert at bottom indexdata()
indexdata(i).index = get indexdata(i)+lastoffset
next i
endif
unlock vertexdata
for i = 0 to vertices - 1
vertexline$ = str$(vertexdata(i).x,6) + " " + str$(vertexdata(i).y,6) + " " + str$(vertexdata(i).z,6)
write string fid, "v "+vertexline$
next i
for i = 0 to vertices - 1
textureline$ = str$(vertexdata(i).u,6) + " " + str$(vertexdata(i).v,6)
write string fid, "vt "+textureline$
next i
for i = 0 to vertices - 1
normalline$ = str$(vertexdata(i).xn,6) + " " + str$(vertexdata(i).yn,6) + " " + str$(vertexdata(i).zn,6)
write string fid, "vn "+normalline$
next i
write string fid, "#"+str$(indices / 3)
write string fid, "usemtl Texture "
if smoothingOn=1
write string fid, "s "+str$(smoothingperc)
else
write string fid, "s off"
endif
combineasonemesh=0
if combineasonemesh <> 1
if array count(meshlist())>0
write string 1,"g "+limb name$(ObjID,meshlist(l))
endif
endif
// if indices = 0 then indices = array count (vertexdata()) / 3
if indices = 0
indices = vertices / 3
dim indexdata(indices)
for fidx=0 to indices-1
//array insert at bottom indexdata()
indexdata(fidx).index = fidx
next fidx
//message str$(indices)
endif
for i = 0 to indices - 3 step 3
i1$ = str$(indexdata(i).index+1)
i2$ = str$(indexdata(i + 1).index+1)
i3$ = str$(indexdata(i + 2).index+1)
uv1$ = str$(indexdata(i).index+1)
uv2$ = str$(indexdata(i + 1).index+1)
uv3$ = str$(indexdata(i + 2).index+1)
n1$ = str$(indexdata(i).index+1)
n2$ = str$(indexdata(i + 1).index+1)
n3$ = str$(indexdata(i + 2).index+1)
write string fid, "f "+i1$+"/"+uv1$+"/"+n1$+" "+i2$+"/"+uv2$+"/"+n2$+" "+i3$+"/"+uv3$+"/"+n3$
next i
next l
close file fid
//if debugOutputOn=1
// message "vertexdata array count = "+str$(array count(vertexdata()))+chr$(13)+"indexdata array count = "+str$(array count(indexdata()))
//endif
empty array vertexdata()
empty array indexdata()
endfunction
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others