Bit of cheat this but realy easy enough to do once you get your head around .x format files.This is part of a UV Painting Program im working on in DBPro.I asked in another thread if any one knew how to acces the textures that were loaded from a .x file as if they were normal DBPro textures so you could adjust them.But so far no one has answered,so i decided to attack the problem from the other end and simply make the .x object and add the textures i want to it in the positions i want,then reload the newly created object.DBPro then simply loads it as any other object but now it has as many textures as you want built into it.
This code snippet simply generates a cube and 10 random textures and builds them in to 1 .x object.
Ill post up the UV Painter in the WIP forum some time later,or at least some screen shots of it.
`Vertex Extractor Part Of UV Painter Code
`======================
`P.Parkinson
`======================
`Main Source File
sync on
sync rate 60
autocam off
color backdrop 0, 0
set text font "Arial"
set text size 12
set text transparent
position camera 10,80,-80
point camera 0,0,0
position mouse screen width()/2,screen height()/2
dummy=mousemovex()
dummy=mousemovey()
`*******Start Up Code*********
`test object to work with
`make object sphere 1,10
`make mesh from object 1,1
`delete object 1
`make object 1,1
`delete mesh 1
make object cube 1,10
`.x exporter suports only indexed list data or plain triangle list(vertex data) type objects
`so things like DBPro sphere objects must be converted before use
global header as string
header="xof 0303txt 0032"
type material
name as string
file_name as string
face_color_r as float
face_color_g as float
face_color_b as float
face_color_a as float
power as float
spec_color_r as float
spec_color_g as float
spec_color_b as float
emis_color_r as float
emis_color_g as float
emis_color_b as float
endtype
global total_materials as integer
dim materials(255) as material
`make 10 random textures and 1 deafault texture
`these are added at random to the object being exported
text 0,0,"MAKING TEST MATERIALS"
sync
sync
build_and_save_materials()
type vertex_data
vertex_pos_x as float
vertex_pos_y as float
vertex_pos_z as float
endtype
type face_data
point1 as integer
point2 as integer
point3 as integer
texture as integer
normal1 as integer
normal2 as integer
normal3 as integer
endtype
type uv_data
u as float
v as float
endtype
type normal_data
normal_pos_x as float
normal_pos_y as float
normal_pos_z as float
endtype
`*******main loop********
extract_data(1,0)
delete object 1
load object "vertex data.x",1
do
mousecontrol(0.5)
sync
loop
`*******Functions********
function MouseControl(Speed as float)
xrotate camera camera angle x()+mousemovey()
yrotate camera camera angle y()+mousemovex()
if mouseclick()=1 then move camera Speed
if mouseclick()=2 then move camera (0-Speed)
endfunction
function extract_data(obj,limb)
lock vertexdata for limb obj,limb
index_count=get vertexdata index count()
vertex_count=get vertexdata vertex count()
if index_count>0
face_count=index_count/3
else
face_count=vertex_count/3
endif
dim v_pos(vertex_count) as vertex_data
dim uv(vertex_count) as uv_data
dim normal(vertex_count) as normal_data
dim poly(face_count) as face_data
for l=0 to vertex_count
v_pos(l).vertex_pos_x=get vertexdata position x(l)
v_pos(l).vertex_pos_y=get vertexdata position y(l)
v_pos(l).vertex_pos_z=get vertexdata position z(l)
uv(l).u=get vertexdata u(l)
uv(l).v=get vertexdata v(l)
normal(l).normal_pos_x=get vertexdata normals x(l)
normal(l).normal_pos_y=get vertexdata normals y(l)
normal(l).normal_pos_z=get vertexdata normals z(l)
next l
p=0
if index_count=0
for l=0 to face_count-1
poly(l).point1=p
poly(l).point2=p+1
poly(l).point3=p+2
poly(l).texture=rnd(10)`use a random texture for testing
poly(l).normal1=p
poly(l).normal2=p+1
poly(l).normal3=p+2
inc p,3
next l
endif
if index_count>0
for l=0 to face_count-1
poly(l).point1=get indexdata (p)
poly(l).point2=get indexdata (p+1)
poly(l).point3=get indexdata (p+2)
poly(l).texture=rnd(10)`use a random texture for testing
poly(l).normal1=get indexdata (p)
poly(l).normal2=get indexdata (p+1)
poly(l).normal3=get indexdata (p+2)
inc p,3
next l
endif
if file exist ("vertex data.x") then delete file "vertex data.x"
open to write 1,"vertex data.x"
`header
write string 1,header
`materials
for l=0 to total_materials-1
write string 1,"Material "+materials(l).name+" {"
write string 1," "+decimalize(materials(l).face_color_r)+"; "+decimalize(materials(l).face_color_g)+"; "+decimalize(materials(l).face_color_b)+";"+decimalize(materials(l).face_color_a)+";;"
write string 1," "+decimalize(materials(l).power)+";"
write string 1," "+decimalize(materials(l).spec_color_r)+"; "+decimalize(materials(l).spec_color_g)+"; "+decimalize(materials(l).spec_color_b)+";;"
write string 1," "+decimalize(materials(l).emis_color_r)+"; "+decimalize(materials(l).emis_color_g)+"; "+decimalize(materials(l).emis_color_b)+";;"
if materials(l).file_name>""
write string 1," TextureFilename { "+chr$(34)+materials(l).file_name+chr$(34)+"; }"
endif
write string 1,"}"
next l
`vertex points
write string 1,"Mesh mesh_0{"
write string 1," "+str$(vertex_count)+";"
for l=0 to (vertex_count-2)
write string 1," "+decimalize(v_pos(l).vertex_pos_x)+"; "+decimalize(v_pos(l).vertex_pos_y)+"; "+decimalize(v_pos(l).vertex_pos_z)+";,"
next l
write string 1," "+decimalize(v_pos(vertex_count-1).vertex_pos_x)+"; "+decimalize(v_pos(vertex_count-1).vertex_pos_y)+"; "+decimalize(v_pos(vertex_count-1).vertex_pos_z)+";;"
`face data
write string 1," "+str$(face_count)+";"
for l=0 to face_count-2
write string 1," 3;"+str$(poly(l).point1)+", "+str$(poly(l).point2)+", "+str$(poly(l).point3)+","
next l
write string 1," 3;"+str$(poly(face_count-1).point1)+", "+str$(poly(face_count-1).point2)+", "+str$(poly(face_count-1).point3)+";;"
`face material
write string 1," MeshMaterialList {"
write string 1," "+str$(total_materials)+";"
write string 1," "+str$(face_count)+";"
for l=0 to face_count-2
write string 1," "+str$(poly(l).texture)+","
next l
write string 1," "+str$(poly(face_count-1).texture)+";"
for l=0 to total_materials-1
write string 1," { "+materials(l).name+" }"
next l
write string 1," }"
`uv
write string 1," MeshTextureCoords {"
write string 1," "+str$(vertex_count)+";"
for l=0 to vertex_count-2
write string 1," "+decimalize(uv(l).u)+", "+decimalize(uv(l).v)+";"
next l
write string 1," "+decimalize(uv(vertex_count-1).u)+", "+decimalize(uv(vertex_count-1).v)+";;"
write string 1," }"
`normals
write string 1," MeshNormals {"
write string 1," "+str$(vertex_count)+";"
for l=0 to vertex_count-2
write string 1," "+decimalize(normal(l).normal_pos_x)+"; "+decimalize(normal(l).normal_pos_y)+"; "+decimalize(normal(l).normal_pos_z)+";,"
next l
write string 1," "+decimalize(normal(vertex_count-1).normal_pos_x)+"; "+decimalize(normal(vertex_count-1).normal_pos_y)+"; "+decimalize(normal(vertex_count-1).normal_pos_z)+";;"
write string 1," "+str$(face_count)+";"
for l=0 to face_count-2
write string 1," 3;"+str$(poly(l).point1)+", "+str$(poly(l).point2)+", "+str$(poly(l).point3)+";"
next l
write string 1," 3;"+str$(poly(face_count-1).point1)+", "+str$(poly(face_count-1).point2)+", "+str$(poly(face_count-1).point3)+";;"
write string 1," }"
write string 1,"}"
close file 1
unlock vertexdata
endfunction
function decimalize(num#)
num$=str$(num#)
if len(num$)<8
ud=0
for l=1 to len(num$)
if mid$(num$,l,1)="." then ud=1
next l
if ud=1
for l=len(num$)+1 to 8
num$=num$+"0"
next l
endif
if ud=0
num$=num$+"."
for l=len(num$)+1 to 8
num$=num$+"0"
next l
endif
endif
endfunction num$
function FreeObject()
repeat
inc i
if object exist(i)=0 then found=1
until found
endfunction i
function FreeImage()
repeat
inc i
if image exist(i)=0 then found=1
until found
endfunction i
function build_and_save_materials()
`default material
materials(total_materials).name="Default_Material"
materials(total_materials).file_name=""
materials(total_materials).face_color_r=1.0000000
materials(total_materials).face_color_g=1.0000000
materials(total_materials).face_color_b=1.0000000
materials(total_materials).face_color_a=1.0000000
materials(total_materials).power=1.0
materials(total_materials).spec_color_r=0.0000000
materials(total_materials).spec_color_g=0.0000000
materials(total_materials).spec_color_b=0.0000000
materials(total_materials).emis_color_r=0.0000000
materials(total_materials).emis_color_g=0.0000000
materials(total_materials).emis_color_b=0.0000000
inc total_materials
for l=1 to 10
read r,g,b
img=freeimage()
ink rgb(255,255,255),0
box 0,0,255,255
for b=1 to 10
x=rnd(205)
y=rnd(205)
box x,y,x+50,y+50,rgb(r,g,b)
next b
get image img,0,0,255,255
if file exist("Material"+str$(img)+".bmp") then delete file "Material"+str$(img)+".bmp"
save image "Material"+str$(img)+".bmp",img
materials(total_materials).name="Material"+str$(img)
materials(total_materials).file_name="Material"+str$(img)+".bmp"
materials(total_materials).face_color_r=1.0000000
materials(total_materials).face_color_g=1.0000000
materials(total_materials).face_color_b=1.0000000
materials(total_materials).face_color_a=1.0000000
materials(total_materials).power=1.0
materials(total_materials).spec_color_r=0.0000000
materials(total_materials).spec_color_g=0.0000000
materials(total_materials).spec_color_b=0.0000000
materials(total_materials).emis_color_r=0.0000000
materials(total_materials).emis_color_g=0.0000000
materials(total_materials).emis_color_b=0.0000000
inc total_materials
next l
for l=1 to 1000
if image exist(l) then delete image l
next l
ink rgb(255,255,255),0
endfunction
data 255,0,0
data 0,255,0
data 0,0,255
data 255,255,0
data 255,0,255
data 0,255,255
data 255,128,128
data 128,255,128
data 128,128,255
data 0,0,0
maybe using some matrix1 code in it somewhere,i cant remember the last time i didnt use it,and cant understand why some of the commands arnt in DBPro anyway.