Nothing too fancy here, just a way to quickly change the vertex diffuse color. (Decent example for novices.)
-Trouble with limbs? Try using
MAKE OBJECT FROM LIMB
-Trouble with .X files? Try using
LOAD MESH instead of LOAD OBJECT
-Use center mouse wheel to rotate and zoom
-Color palette attached
MarkerOpacity=15
ThisLimb=0
make object cube 1,1
gosub Setup
do
gosub Graphics
gosub MouseControl
gosub KeyControl
gosub CamControl
gosub PrintInfo
sync
LOOP
Graphics:
paste sprite 1,0,0
box 0,0,60,38,ThisColor,ThisColor,ThisColor,ThisColor
for m=1 to MaxGroup
point object m+1,camera position x(),camera position y(),camera position z()
next
return
MouseControl:
if mousex()<59 and mousey()<37 then if PaletteScale=10 then PaletteScale=100:size sprite 1,screen width(),screen height()`scale sprite 1,100
if PaletteScale=100 `Color-Select Mode
c=point(mousex(),mousey())
box mousex(),mousey(),mousex()+60,mousey()+38,c,c,c,c
if mouseclick()=1 then ThisColor=point(mousex(),mousey()):PaletteScale=10:scale sprite 1,10:position mouse 320,240
while mouseclick()=1:endwhile
ENDIF
if PaletteScale=10 `Normal Mode
ThisMarker=0
ThisMarker=pick object(mousex(),mousey(),2,MaxGroup+1)-1:if mouseclick()=1 then if ThisMarker>0 then gosub DoPaint
if mouseclick()=4 then dec CamAngleX#,((oldmousey-mousey())*.5):dec CamAngleY#,((oldmousex-mousex())*.5)
dec CamDist#,mousemovez()*(object size(1)*.001)
ENDIF
oldmousex=mousex():oldmousey=mousey()
return
KeyControl:
if lower$(inkey$())="f" then gosub PaintFill
if lower$(inkey$())="s"
fn$="vertex_paint_test.dbo"
if file exist(fn$) then delete file fn$
save object fn$,1:end
ENDIF
return
CamControl:
position camera object position x(1),object position y(1),object position z(1)
rotate camera CamAngleX#,CamAngleY#,CamAngleZ#
move camera -CamDist#
position light 0,camera position x(),camera position y(),camera position z()
return
PaintFill:
lock vertexdata for limb 1,ThisLimb
for v=0 to vCount-1
set vertexdata diffuse v,ThisColor
next
unlock vertexdata
return
DoPaint:
lock vertexdata for limb 1,ThisLimb
for v=0 to vCount-1
if vertGroup(v)=ThisMarker then set vertexdata diffuse v,ThisColor
NEXT
unlock vertexdata
return
PrintInfo:
if mTimer#>abs(timer()) then center text screen width()*.5,screen height()*.95,"(F)ill all vertices (S)ave Object Esc to Exit"
return
Setup:
mTimer#=abs(timer())+15000
color backdrop rgb(55,87,40)
load image "spectrum.png",1,1
sprite 1,0,0,1
scale sprite 1,10:PaletteScale=10:hide sprite 1
convert object fvf 1,338
set object cull 1,0
CamDist#=abs(camera position z()-object position z(1))
set camera range .001,object size(1)*100
lock vertexdata for limb 1,ThisLimb:vCount=get vertexdata vertex count():unlock vertexdata
set point light 0,0,0,0:color light 0,rgb(255,255,255)
dim vertX#(vCount)
dim vertY#(vCount)
dim vertZ#(vCount)
dim vX#(vCount)
dim vY#(vCount)
dim vZ#(vCount)
dim vertGroup(vCount)
lock vertexdata for limb 1,ThisLimb
MaxGroup=1
vX#(MaxGroup)=get vertexdata position x(0):vY#(MaxGroup)=get vertexdata position y(0):vZ#(MaxGroup)=get vertexdata position z(0)
vertGroup(0)=1
for v=1 to vCount-1
for g=1 to MaxGroup
Pass=0:Count=0
inc Count:if get vertexdata position x(v)=vX#(g) then inc Pass
inc Count:if get vertexdata position y(v)=vY#(g) then inc Pass
inc Count:if get vertexdata position z(v)=vZ#(g) then inc Pass
if Pass=3 then vertGroup(v)=g:exit
next
if Count=3 and Pass<3
inc MaxGroup
vX#(MaxGroup)=get vertexdata position x(v)
vY#(MaxGroup)=get vertexdata position y(v)
vZ#(MaxGroup)=get vertexdata position z(v)
vertGroup(v)=MaxGroup
endif
next
for m=1 to MaxGroup
make object plain m+1,object size(1)*.08,object size(1)*.08
set alpha mapping on m+1,MarkerOpacity
for v=0 to vCount-1
if vertGroup(v)=m then position object m+1,get vertexdata position x(v),get vertexdata position y(v),get vertexdata position z(v)
next
NEXT
unlock vertexdata
sync on:sync rate 60
return