here is the function to export any object into a .x file in dark basic pro.To export a object out into a .dbo file,use save object command.
you have to have easy rotate for this one,but there are others to my friend.
.x file export function.
function exportXfile(fileName$,objID,texStage)
dim texNames$() as string
if right$(fileName$,2) <> ".x" and right$(fileName$,2) <> ".X"
exitfunction
endif
oldDir$ = get dir$()
set dir g_OutputFolder$
if file exist(fileName$) <> 0
delete file fileName$
endif
SET OBJECT NORMALS objID
fileID = 1
`create file header
open to write fileID,fileName$
write string fileID, "xof 0302txt 0032"
write string fileID, "// GDS X Exporter"
write string fileID, "Header {"
write string fileID, " 1;"
write string fileID, " 0;"
write string fileID, " 1;"
write string fileID, " }"
`get the material list
n = 0
while limb exist(objID,n)
stFull$ = limb texture name(objID,n,texStage)
if stFull$ <> ""
st$ = EXTRACT FILENAME$( stFull$ )
if file exist(st$) = 0
if file exist(stFull$)
COPY FILE stFull$, st$
else
if limb texture(objID,n,texStage) > 0
save image st$,limb texture(objID,n,texStage)
endif
endif
endif
matIndex = -1
for i = 0 to array count(texNames$(0))
if texNames$(i) = st$
matIndex = i
exit
endif
next i
if matIndex = -1
ARRAY INSERT AT BOTTOM texNames$(0)
texNames$(array count(texNames$(0))) = st$
endif
endif
n = n + 1
endwhile
`write out materail list
for i = 0 to array count(texNames$(0))
write string fileID,"Material material_" + str$(i+1) + " {"
write string fileID," 1.0;1.0;1.0;1.0;;"
write string fileID," 10.0;"
write string fileID," 1.0;1.0;1.0;;"
write string fileID," 0.0;0.0;0.0;;"
write string fileID," TextureFilename { " + chr$(34) + texNames$(i) + chr$(34) + ";" + " }"
write string fileID," }"
next i
`create farame world and transform
write string fileID, "Frame World {"
write string fileID, " FrameTransformMatrix {"
write string fileID, " 1.0,0.0,0.0,0.0,"
write string fileID, " 0.0,1.0,0.0,0.0,"
write string fileID, " 0.0,0.0,1.0,0.0,"
write string fileID, " 0.0,0.0,0.0,1.0;;"
write string fileID, " }"
EZro_SetPos 0,0,0
n = 0
while limb exist(objID,n)
` if limb name$(objID,n) = "new limb"
write string fileID, " Mesh limb" + str$(n+1) + " {"
` else
` write string fileID, " Mesh " + limb name$(objID,n) + " {"
` endif
px# = limb offset x(objID,n)
py# = limb offset y(objID,n)
pz# = limb offset z(objID,n)
dx# = limb angle x(objID,n)
dy# = limb angle y(objID,n)
dz# = limb angle z(objID,n)
`EZro_SetPos 0,0,0
EZro_SetEuler dx#, dy#, dz#
lock vertexdata for limb objID,n,1
nIndexs = GET VERTEXDATA INDEX COUNT()
nVeritces = GET VERTEXDATA VERTEX COUNT()
if nIndexs = 0
`use mesh if tri-strip object
unlock vertexdata
tmpObj = getFreeObject()
make object from limb tmpObj,objID,n
tmpMesh = getFreeMesh()
make mesh from object tmpMesh,tmpObj
change mesh objID,n,tmpMesh
delete object tmpObj
delete mesh tmpMesh
lock vertexdata for limb objID,n,1
nIndexs = GET VERTEXDATA INDEX COUNT()
nVeritces = GET VERTEXDATA VERTEX COUNT()
endif
`write the vertex count
write string fileID, " " + str$(nVeritces) +";"
`write the vertexes
for i = 0 to nVeritces - 2
EZro_FindPointFromOffset GET VERTEXDATA POSITION X(i), GET VERTEXDATA POSITION Y(i),GET VERTEXDATA POSITION Z(i)
write string fileID, " " + str$(px# + EZro_GetOffsetX(),6) + ";" + str$(py# + EZro_GetOffsetY(),6) + ";" + str$(pz# + EZro_GetOffsetZ(),6) + ";,"
next i
`add ending
i = nVeritces - 1
EZro_FindPointFromOffset GET VERTEXDATA POSITION X(i), GET VERTEXDATA POSITION Y(i),GET VERTEXDATA POSITION Z(i)
write string fileID, " " + str$(px# + EZro_GetOffsetX(),6) + ";" + str$(py# + EZro_GetOffsetY(),6) + ";" + str$(pz# + EZro_GetOffsetZ(),6) + ";;"
`write the index count
write string fileID, " " + str$(nIndexs/3) +";"
`write the indices
for i = 0 to nIndexs - 4 step 3
write string fileID, " 3;" + str$(GET INDEXDATA(i)) + ";" + str$(GET INDEXDATA(i+1)) + ";" + str$(GET INDEXDATA(i+2)) + ";,"
next i
`add ending
i = nIndexs - 3
write string fileID, " 3;" + str$(GET INDEXDATA(i)) + ";" + str$(GET INDEXDATA(i+1)) + ";" + str$(GET INDEXDATA(i+2)) + ";;"
`write the uv maps
write string fileID, " MeshTextureCoords {"
write string fileID, " " + str$(nVeritces) +";"
for i = 0 to nVeritces - 2
write string fileID, " " + str$(GET VERTEXDATA U(i, texStage),6) + ";" + str$(GET VERTEXDATA V(i, texStage),6) + ";,"
next i
i = nVeritces - 1
write string fileID, " " + str$(GET VERTEXDATA U(i, texStage),6) + ";" + str$(GET VERTEXDATA V(i, texStage),6) + ";;"
write string fileID, " }"
`write the normals
write string fileID, " MeshNormals {"
`vertices
write string fileID, " " + str$(nVeritces) +";"
for i = 0 to nVeritces - 2
write string fileID, " " + str$(GET VERTEXDATA NORMALS X(i),6) + ";" + str$(GET VERTEXDATA NORMALS Y(i),6) + ";" + str$(GET VERTEXDATA NORMALS Z(i),6) + ";,"
next i
i = nVeritces - 1
write string fileID, " " + str$(GET VERTEXDATA NORMALS X(i),6) + ";" + str$(GET VERTEXDATA NORMALS Y(i),6) + ";" + str$(GET VERTEXDATA NORMALS Z(i),6) + ";;"
`indicies
write string fileID, " " + str$(nIndexs/3) +";"
for i = 0 to nIndexs - 4 step 3
write string fileID, " 3;" + str$(GET INDEXDATA(i)) + ";" + str$(GET INDEXDATA(i+1)) + ";" + str$(GET INDEXDATA(i+2)) + ";,"
next i
`add ending
i = nIndexs - 3
write string fileID, " 3;" + str$(GET INDEXDATA(i)) + ";" + str$(GET INDEXDATA(i+1)) + ";" + str$(GET INDEXDATA(i+2)) + ";;"
write string fileID, " }"
unlock vertexdata
`look for this texture in the material list
matIndex = -1
st$ = limb texture name(objID,n,texStage)
if st$ <> ""
st$ = EXTRACT FILENAME$( st$ )
for i = 0 to array count(texNames$(0))
if texNames$(i) = st$
matIndex = i
exit
endif
next i
endif
if matIndex > -1
write string fileID, " MeshMaterialList {"
write string fileID, " " + str$(1) +";"
write string fileID, " " + str$(nIndexs/3) +";"
for i = 0 to nIndexs/3 - 1
write string fileID, " " + str$(0) +","
next i
write string fileID, " " + str$(0) +";;"
write string fileID, " { material_" + str$(matIndex+1) + " }"
write string fileID, " }"
endif
write string fileID, " }"
n = n + 1
endwhile
write string fileID, " }"
close file fileID
set dir oldDir$
undim texNames$(0)
endfunction
function getFreeObject()
obj = 0
for i = 1 to 262144
if object exist(i) = 0
obj = i
exit
endif
next i
ENDFUNCTION obj
function getFreeMesh()
mesh = 0
for i = 1 to 131072
if mesh exist(i) = 0
mesh = i
exit
endif
next i
ENDFUNCTION mesh
my signature keeps being erased by a mod So this is my new signature.