Check it out. Self extracting archive. Includes .dba. You'll need red/cyan 3d glasses. See the screeny at the bottom. I appended a copy of the code too.
Basically it renders two camera views, then displays these camera views on two plains (the one drawn second is ghosted), which are then seen by the camera that ends up on the screen. The plains are vertex coloured red and cyan. NB i originally lit the word red then cyan for taking the two pictures, which works fine too, but put some constraints on what could be done.
Also includes code of how to change the vertex colour of DB primitives. It seems the help file says that objects have a memblock format with 36 bytes per vertex, when, in actual fact they only use 32, and it appears that the vertex colours is what is missing.
I tried using sprites like many people appear to have suggested (search board for anaglyph), but no luck. You don't appear to be able to ghost sprites- just make them transparent. You could make a working anaglyph but not a very bright one.
Anyway have fun. Instructions in the folder.
A screeny:
The code:
Rem Project: ANAGLYPH a
Rem Created: 17/05/2008 01:38:55
Rem ***** Main Source File *****
`#constant cam_aspect 1.33333 `use 1.6 for 16:10, 1.7777 for 16:9
global cam_aspect as float
open to read 1,"screen ratio.txt":read string 1,temp$:cam_aspect=val(temp$):close file 1
sync on:sync rate 0
hide mouse:autocam off
make camera 1:make camera 2
dummyobjno=100
tempmeshnum=1
make object cube dummyobjno,1 `DUMMY OBJECT...
make mesh from object tempmeshnum,dummyobjno
add limb dummyobjno,1,tempmeshnum:delete mesh tempmeshnum
offset limb dummyobjno,0,-0.5,0,0 `increase spacing to make eye distance (in world)larger..
offset limb dummyobjno,1,0.5,0,0
exclude object off dummyobjno:hide object dummyobjno
set camera fov 1,40:set camera fov 2,40
color backdrop 0,0:color backdrop 1,0:color backdrop 2,0
`================================
make object plain 1,100,100 `scaled later- so can rescale..
make mesh from object 1,1:delete object 1
make memblock from mesh 1,1:delete mesh 1
numverts=memblock dword(1,8)
make memblock 2,get memblock size(1)+numverts*4
write memblock dword 2,0,338
write memblock dword 2,4,36
copy memblock 1,2,8,8,4
for n=1 to numverts
`COPY MEMBLOCK From,To,PosFrom,PosTo,Bytes
copy memblock 1,2,32*n-20,36*n-24,24
write memblock dword 2,36*n,0xFFFF0000 `SOLID RED (can dim it by changing first to hex vals)
copy memblock 1,2,32*n+4, 36*n+4, 8 `uv data
next n
make mesh from memblock 2,2
make object 1,2,0:set object 1,1,1,0,0,0,0,0 `UNIFORMLY LIT, BUT COLOUR WORKS EVEN WHEN AMB LIGHT FULLY ON.. ****** GOOD!!!
delete mesh 2
for n=1 to numverts
write memblock dword 2,36*n,0xFF00FFFF `SOLID CYAN
next n
make mesh from memblock 2,2
make object 2,2,0:set object 2,1,1,0,0,0,0,0
delete mesh 2
delete memblock 2
ghost object on 2 `only one need be ghosted- the other goes strainght on black backdrop- so ghost or ordinary look same
disable object zwrite 1:disable object zwrite 2 `maybe should disable zdepth?
disable object zdepth 1:disable object zdepth 2
set camera fov 0,90
update_3dcam_split(0.15)
texture object 1,1
texture object 2,2
`SCENE===========================
`load image "sunken dish.jpg",10
load image "rocky.jpg",5
`load image "Interior_ChessBoardc.jpg",4
`load image "test.jpg",4
`load image "sand_3_darker.jpg",6
`load image "cloudy moor.jpg",3 `low num so draws 1st (of world objs
load image "alien maelstrom b3.jpg",3 `low num so draws 1st (of world objs
make object sphere 7,1000:texture object 7,3:scale object texture 7,2,1 `:scale object texture 7,5,5 `cave
position object 7,-20,-5,300
set object cull 7,0:set object light 7,0:set object ambient 7,0:set object fog 7,0
disable object zwrite 7 `stop it witing to zbuffer- subsequent stuff always drawn on top
disable object zread 7 `no point- it's the first thing drawn
`disable object zdepth 7
make object plain 4,950,950:texture object 4,5:scale object texture 4,5,5 `ground
xrotate object 4,90:position object 4,0,-100,300
scale object 4,0,0,0 `hide permanently!!
make object cube 9,200:texture object 9,5:scale object texture 9,2,2
position object 9,0,0,700
for n=10 to 60
make object cube n,7:texture object n,5:position object n,0,-10,10*n-100 `walkway cubes
next n
for n=61 to 70
make object cube n,10:texture object n,5:position object n,10,-10,50*(n-60)-20 `spinny cubes
next n
make object sphere 8,20:texture object 8,5:position object 8,-20,-5,300
make object sphere 6,50:texture object 6,5:position object 6,-100,-60,250 `balls in air
make object sphere 5,100:texture object 5,5:position object 5,200,60,350
`SET SCENE LIGHTING
color ambient light rgb(190,180,190):set ambient light 100
set directional light 0,0.1,-1,0:color light 0,80,50,80
make light 1:set directional light 1,-0.1,1,0:color light 1,-90,-50,-90
fog on:fog color rgb(120,100,120):fog distance 2000
`color light 0,60,60,60:set directional light 0,0.5,-0.5,0
`color ambient light rgb(200,200,220):set ambient light 100
`fog off
split#=0.15
`FOR TIMER STUFF
timenow as dword
timelast as dword
timelapsed as dword
timenow=timer()
do
schange=upkey()-downkey()
if schange
split#=split#*(1.0+0.01*schange):update_3dcam_split(split#)
endif
`FIND TIME ELAPSED. SIMPLE "TIMER BASED" GAME UPDATES. NB seems to make game jerkier..
timelast=timenow:timenow=timer():timeelapsed=timenow-timelast
if controlkey() then text 10,0,str$(screen fps()) `SHOW FPS
text 10,10,str$(split#,3)
`HANDLE SCENE
for n=61 to 70:pitch object up n,-0.05*timeelapsed:next n
turn object left 8,0.05*timeelapsed
`HANDLE PLAYER ROTATION AND MOVEMENT
inc yr#,0.2*mousemovex()
inc xr#,0.2*mousemovey()
yrotate object dummyobjno,yr#
xrotate object dummyobjno,xr#
move object dummyobjno,0.03*timeelapsed*((mouseclick()&&1) - (mouseclick()&&2)/2)
`POSITION AND ORIENT THE STEREO CAMERAS
position camera 1,limb position x(dummyobjno,0),limb position y(dummyobjno,0),limb position z(dummyobjno,0)
position camera 2,limb position x(dummyobjno,1),limb position y(dummyobjno,1),limb position z(dummyobjno,1)
set camera to object orientation 1,dummyobjno
set camera to object orientation 2,dummyobjno
`TAKE PICS WITH STEREO CAMERAS
hide object 1:hide object 2 `hide the plains
for n=4 to 70:show object n:next n `show everything else
`sync mask %110:sync `can use this code if have no skysphere or other thing that's positioned differently for each cam..
`otherwise..
position object 7,limb position x(dummyobjno,0),limb position y(dummyobjno,0),limb position z(dummyobjno,0) `skysphere..
sync mask %010:sync `cam 1
position object 7,limb position x(dummyobjno,1),limb position y(dummyobjno,1),limb position z(dummyobjno,1) `skysphere..
sync mask %100:sync `cam 2
`TAKE PIC OF THE TWO PLAINS THAT HAVE THE TWO CAMERA VIEWS TEXTURED ON THE
show object 1:show object 2 `show the plains
for n=4 to 70:hide object n:next n `hide everything else
sync mask %001:sync `cam 0
loop
end
function update_3dcam_split(split#)
`splita#=1.0-split# `to just get to nearest edge- leads to distracting lines at edge.
splita#=1.0+split# `how wide need to be to be square, but also fill screen to edge.
set camera aspect 1,cam_aspect*splita#
set camera aspect 2,cam_aspect*splita#
set camera to image 1,1,int(screen width()*splita#),screen height() `these are recalled later anyway, but need to make the images now..
set camera to image 2,2,int(screen width()*splita#),screen height()
position object 1,0-screen width()*0.5*split#,0,screen height()/2
position object 2,0+screen width()*0.5*split#,0,screen height()/2
scale object 1,int(screen width()*splita#),screen height(),100
scale object 2,int(screen width()*splita#),screen height(),100
endfunction