[DBPro]
This snippet will create segmented versions of 2D fonts in 3D, with each pixel treated as a separate limb.
[Edit] I've cleaned up this code quite a bit since I originally posted it.
gosub Setup
gosub MakeBackdrop
gosub GetData
Gosub MakeObjects
do
gosub ObjDisplay
gosub CamControl
sync
loop
Setup:
autocam off:move camera 20:rotate camera 0,235,0:set point light 0,0,0,0
White=rgb(255,255,255):Black=rgb(0,0,0):ink White,Black
CubeSize=1:CubeMesh=1
EndRange=26 `how many charachters to display at once
ChrOffset=64 `how many ASCII charachters to skip
FontX=8 `8 pixels wide for default system font - adjust per other fonts
FontY=11 `11 pixels high for default system font - adjust per other fonts
dim Graph(EndRange,FontX*FontY)
hide mouse
sync on:sync rate 60
return
MakeBackdrop:
Sky=1000
make object cube Sky,-10
convert object fvf Sky,338
lock vertexdata for limb Sky,0
vCount=get vertexdata vertex count()-1
for v=o to vCount
randomize timer():rRoll=rnd(10000)
randomize (get vertexdata position x(v)+get vertexdata position y(v)+get vertexdata position z(v))
set vertexdata diffuse v,rgb(rnd(100),55+rnd(100),155+rnd(100))
NEXT
unlock vertexdata
set object light Sky,0
enable object zbias Sky,0,1
return
GetData:
for c=1 to EndRange
cls
text -1,-3,chr$(c+ChrOffset) `-1 and -3 offsets should be adjusted per font's pixel size
Lcount=0
for y=0 to FontY-1
for x=0 to FontX-1
inc Lcount
Graph(c,Lcount)=point(x,y)
NEXT
NEXT
NEXT
return
MakeObjects:
make object cube CubeMesh,CubeSize:make mesh from object CubeMesh,CubeMesh:delete object CubeMesh
for o=1 to EndRange
Xadj=0
make object plain o,0,0
xx#=-FontX/2:ox#=xx#:yy#=FontY/2:Lcount=0
for y=FontY-1 to 0 step -1
for x=0 to FontX-1+Xadj
inc Lcount
add limb o,Lcount,CubeMesh:if Graph(o,Lcount)=Black then hide limb o,Lcount
offset limb o,Lcount,xx#,yy#,0
randomize timer() `OPTIONAL
color limb o,Lcount,rgb(rnd(255),rnd(255),rnd(255)) `OPTIONAL
if rnd(10)=1 then randomize o:color limb o,Lcount,rgb(155+rnd (55),55+rnd(155),55+rnd(100)) `OPTIONAL
inc xx#,CubeSize
if xx#-ox#=(FontX+Xadj)*CubeSize then xx#=-FontX/2:ox#=xx#:dec yy#,CubeSize
next
next
move object right o,o*(CubeSize*(FontX*2))
set object specular power o,100
next
return
ObjDisplay:
for o=1 to EndRange
yrotate object o,object angle y(o)-2
for l=1 to get limb count(o)
rotate limb o,l,0,limb angle y(o,l)+2,0
rotate object Sky,object angle x(Sky)+.0001,object angle y(Sky)+.0001,object angle z(Sky)+.0001
NEXT
NEXT
return
CamControl:
control camera using arrowkeys 0,.7,3
cx#=camera position x():cy#=camera position y():cz#=camera position z()
position light 0,cx#,cy#,cz#
position object Sky,cx#,cy#,cz#
return