when you start your program your not starting with a sync or telling the program to set the autocam on or off
feel free to pull apart my older one, simple who used to be a coder / artist here made his out of it as well.
rem ----------------------------------------------------
rem DarkBasic Model viewer version 1.0
rem indi (david smith)
rem free source
rem tested with DB v 1.11
rem created april 2002
rem
rem Model notes
rem
rem models need to be placed in the same directory as this script
rem make sure textures are in same directory and 8.3 convention
rem models that are not correctly aligned should be fixed in the 3d app
rem instead of relying on rotating objects and fixing pivots
rem
rem stuff to add
rem better light features
rem better animation previewing
rem better camera stuff
rem more visual controls
rem credit magellans model view snippet
rem ----------------------------------------------------
rem ----------------------------------------------------
rem Script Modify Area
rem ----------------------------------------------------
REM MODIFY THESE VARIABLES
REM TO LOCK YOUR VIEWER IN PREFERED MODE
` screen res
sw = 640
sh = 480
sd = 16
` sync speed
syncnum = 0
`displayfont
fontname$ = "verdana"
txtsiz = 12
` fog details
fogdist = 800
fog_r = 0
fog_g = 0
fog_b = 0
` background colour rgb
bgd_r = 0
bgd_g = 0
bgd_b = 0
` camera setup
camx# = 0
camy# = 0
camz# = -100
min_cam_range =1
max_cam_range =5000
` ambient light colour
amb_r =255
amb_g =255
amb_b =255
` ambient light start factor
ambience = 50
` light setup
def_light_dist = 800
` default light start position
def_lgtx = 0
def_lgty = 0
def_lgtz = -100
` pre set models set object states
wiretoggle =1
transtoggle =1
culltoggle =1
filttoggle =1
lighttoggle =1
fogtoggle =1
ambienttoggle =1
` matrix reference variables
mtxsiz = 100
mtxdiv = 2
`for every division of the matrix is 2 polys times mtxdiv
` eg a mtx div of 2 = 8 polys
` eaxmple matrix layout of polys
` 2 x 2
` 2 x 2
` dont worry tho u can remove the matrix to get a clear polycount
`animation switches
` modify these animation variables
anim_flag = 1
` assign this flag to 1 if animation is required
` u must flag this for animation to work
` eg
` anim_flag = 0=no animation
` anim_flag = 1=animation
startframe = 1
endframe = 30
anim_speed = 50
interpolate_speed = 20
` end of variable mods
rem ----------------------------------------------------
rem ----------------------------------------------------
` REST of CODE : no need to change anything beyond here
rem ----------------------------------------------------
cls
sync on
sync rate syncnum
randomize timer()
` setup text display
set text font fontname$
set text size txtsiz
videocard$ = CURRENT GRAPHICS CARD$()
emulated = EMULATION MODE()
filtercheck = FILTERING AVAILABLE()
fogcheck = FOG AVAILABLE()
3dblitcheck = 3DBLIT AVAILABLE()
alphablendcheck = ALPHABLENDING AVAILABLE()
vidmem = SYSTEM DMEM AVAILABLE()
sysmem = SYSTEM SMEM AVAILABLE()
totalmem = SYSTEM TMEM AVAILABLE()
hardware = SCREEN TYPE()
bitdepth = SCREEN DEPTH()
screenhgt = SCREEN HEIGHT()
screenwide = SCREEN WIDTH()
` begin the user input
ink rgb(255,255,0),1
print "DARKBASIC Model Viewer"
ink rgb(255,255,255),1
print
print "Enter a .3ds or .x model filename from this programs directory"
input "Enter filename :",filename$
`Screen Res
set display mode sw,sh,sd
` ambient light
set ambient light ambience
color ambient light rgb(amb_r,amb_g,amb_b)
` Fog
if fogcheck = 1
fog on
fog distance fogdist
fog color rgb(fog_r,fog_g,fog_b)
endif
` Backdrop
backdrop on
color backdrop rgb(bgd_r,bgd_g,bgd_b)
` Matrix
make matrix 1,mtxsiz,mtxsiz,mtxdiv,mtxdiv
mtx_x = mtx_x - (mtxsiz/2)
mtx_y = 0
mtx_z = mtx_z - (mtxsiz/4)
position matrix 1,mtx_x,mtx_y,mtx_z
` Load Model from user filename
load object filename$,1
position object 1,0,0,0
` Camera Stuff
set camera range min_cam_range,max_cam_range
position camera camx#,camy#,camz#
` default light stuff
set point light 0,def_lgtx,def_lgty,def_lgtz
point light 0,0,0,0
set light range 0,def_light_dist
`set spot light 0,30,360
`set directional light 0,0,30,0
hide mouse
` Main
do
gosub keyinputs
set object 1,wiretoggle,transtoggle,culltoggle,filttoggle,lighttoggle,fogtoggle,ambienttoggle
` obj,wire,trans,cull,filt,light,fog,amb
cx#=wrapvalue(cx#+mousemovey()*1.2)
cy#=wrapvalue(cy#+mousemovex()*1.2)
cz#=wrapvalue(cz#+mousemovez()*1.2)
acx#=curveangle(cx#,acx#,2.1)
acy#=curveangle(cy#,acy#,2.1)
acz#=curveangle(cz#,acz#,2.1)
rotate object 1,acx#,acy#,acz#
if mouseclick()=1 then inc move#, .5
if mouseclick()=2 then dec move#, .5
rotate camera 0,0,0
move camera move#
move#=0
go=0
if upkey()=1 then rotate camera 90,0,0; go=1
if downkey()=1 then rotate camera 270,0,0; go=1
if leftkey()=1 then rotate camera 0,90,0; go=1
if rightkey()=1 then rotate camera 0,270,0; go=1
if go=1 then move camera .25
rotate camera 0,0,0
if tabinfotoggle = 1
gosub output
endif
sync
loop
rem gosubs
keyinputs:
if inkey$()="-"
if ambience < 1 then ambience = 1
if ambience > 99 then ambience = 99
ambience = ambience -1
set ambient light ambience
endif
if inkey$()="="
if ambience < 1 then ambience = 1
if ambience > 99 then ambience = 99
ambience = ambience +1
set ambient light ambience
endif
if inkey$()="]"
if fogdist < 1 then fogdist = 1
if fogdist > 10000 then fogdist = 10000
fogdist = fogdist +1
fog distance fogdist
endif
if inkey$()="["
if fogdist < 1 then fogdist = 1
if fogdist > 10000 then fogdist = 10000
fogdist = fogdist -1
fog distance fogdist
endif
` the tab key = 15 and displays the model info
If keystate(15)=1 and tab_infoswitch=0
tab_infotoggle=1-tab_infotoggle
tab_infoswitch=1
Endif
If keystate(15)=0 then tab_infoswitch=0
if tab_infotoggle = 1
gosub output
endif
` the letter i = 23
If keystate(23)=1 and helpswitch=0
helptoggle=1-helptoggle
helpswitch=1
Endif
If keystate(23)=0 then helpswitch=0
if helptoggle = 1
gosub help
endif
` the letter 2 = 31
If keystate(31)=1 and sys_checkswitch=0
sys_checktoggle=1-sys_checktoggle
sys_checkswitch=1
Endif
If keystate(31)=0 then sys_checkswitch=0
if sys_checktoggle = 1
gosub systemcheck
endif
` the letter f = 33
If keystate(33)=1 and fog_btnswitch=0
fog_btntoggle=1-fog_btntoggle
fog_btnswitch=1
fog off
Endif
If keystate(33)=0 then fog_btnswitch=0
if fog_btntoggle = 1
fog on
endif
` the letter g = 34
If keystate(34)=1 and ghost_btnswitch=0
ghost_btntoggle=1-ghost_btntoggle
ghost_btnswitch=1
ghost object off 1
Endif
If keystate(34)=0 then ghost_btnswitch=0
if ghost_btntoggle = 1
ghost object on 1
endif
` the letter m = 50
If keystate(50)=1 and mtxswitch=0
mtxtoggle=1-mtxtoggle
mtxswitch=1
position matrix 1,mtx_x,mtx_y,mtx_z
Endif
If keystate(50)=0 then mtxswitch=0
if mtxtoggle = 1
position matrix 1,10000,10000,10000
endif
` f1 - f6 toggles the set object commands
` scancodes
` 59 = f1
` 60 = f2
` 61 = f3
` 62 = f4
` 63 = f5
` 64 = f6
` 65 = f7
If keystate(59)=1 and wireswitch=0
wiretoggle=1-wiretoggle
wireswitch=1
Endif
If keystate(59)=0 then wireswitch=0
if wiretoggle = 1
endif
If keystate(60)=1 and transswitch=0
transtoggle=1-transtoggle
transswitch=1
Endif
If keystate(60)=0 then transswitch=0
if transtoggle = 1
endif
If keystate(61)=1 and cullswitch=0
culltoggle=1-culltoggle
cullswitch=1
Endif
If keystate(61)=0 then cullswitch=0
if culltoggle = 1
endif
If keystate(62)=1 and filtswitch=0
filttoggle=1-filttoggle
filtswitch=1
Endif
If keystate(62)=0 then filtswitch=0
if filttoggle = 1
endif
If keystate(63)=1 and lightswitch=0
lighttoggle=1-lighttoggle
lightswitch=1
Endif
If keystate(63)=0 then lightswitch=0
if lighttoggle = 1
endif
If keystate(64)=1 and fogswitch=0
fogtoggle=1-fogtoggle
fogswitch=1
Endif
If keystate(64)=0 then fogswitch=0
if fogtoggle = 1
endif
If keystate(65)=1 and ambientswitch=0
ambienttoggle=1-ambienttoggle
ambientswitch=1
Endif
If keystate(65)=0 then ambientswitch=0
if ambienttoggle = 1
endif
` animation settings
if anim_flag = 1
set object speed 1,anim_speed
set object interpolation 1,interpolate_speed
if inkey$()="z"
play object 1,startframe,endframe
endif
if inkey$()="x"
loop object 1,startframe,endframe
endif
if spacekey()=1
stop object 1
endif
endif
if inkey$()="q"
delete object 1
delete matrix 1
cls
end
endif
return
output:
text 10,10,"DARKBASIC model viewer"
text 10,30,"toggle [ i ] for info"
text 10,50,"fps :"+STR$(screen fps())
text 10,70,"polygons : "+STR$(statistic(1))
text 10,90,"wire : "
text 10,110,"trans : "
text 10,130,"cull : "
text 10,150,"filt : "
text 10,170,"light : "
text 10,190,"fog : "
text 10,210,"ambi : "
text 50,90,str$(wiretoggle)
text 50,110,str$(transtoggle)
text 50,130,str$(culltoggle)
text 50,150,str$(filttoggle)
text 50,170,str$(lighttoggle)
text 50,190,str$(fogtoggle)
text 50,210,str$(ambienttoggle)
text 10,230,"environment"
text 10,250,"fog on/off: "+str$(fog_btntoggle)
text 10,270,"fog distance: "+str$(fogdist)
text 10,290,"matrix hidden: "+str$(mtxtoggle)
text 10,310,"ghost on/off: "+str$(ghost_btntoggle)
text 10,330,"ambient light: "+str$(ambience)
text 10,350,"cam x pos: "+STR$(camera position x())
text 10,370,"cam y pos: "+STR$(camera position y())
text 10,390,"cam z pos: "+STR$(camera position z())
return
help:
cls
ink rgb(0,0,0),1
box 0,0,640,480
ink rgb(255,255,155),1
text 210,10,"Instructions"
text 210,30,"This Program will help u view your models in DB"
text 210,50,"controls"
text 210,70,"mouse to alter the camera view"
text 210,90,"mouse buttons to zoom in and out"
text 210,110,"arrow keys to alter the view"
text 210,130,"toggle [ f1 ] - [ f7 ] for different set object settings"
text 210,150,"toggle [ m ] to hide and show matrix reference"
text 210,170,"toggle [ g ] to ghost object on and off"
text 210,190,"toggle [ f ] to turn fog on and off"
text 210,210,"toggle [ s ] to see system settings"
text 210,230,"press [ - ] and [ = ] to change ambient light"
text 210,250,"press [ [ ] and [ ] ] to change the fog distance"
text 210,270,"press [ z ] to play animation"
text 210,290,"press [ x ] to loop animation"
text 210,310,"press [ space ] to stop animation"
text 210,330,"press [ q ] to exit"
text 210,350,"press [ tab ] to toggle info"
text 210,370,"Dont forget to hide the matrix for true polycount"
return
systemcheck:
cls
ink rgb(0,0,0),1
box 0,0,640,480
ink rgb(255,255,155),1
text 210,10,"Quick system check "
text 210,30,"videocard$ "+ videocard$
text 210,50,"emulated " + STR$(emulated)
text 210,70,"filtercheck " + STR$(filtercheck)
text 210,90,"fogcheck " + STR$(fogcheck)
text 210,110,"3dblitcheck " + STR$(3dblitcheck)
text 210,130,"alphablendcheck " + STR$(alphablendcheck)
text 210,150,"vidmem " + STR$(vidmem)
text 210,170,"sysmem " + STR$(sysmem)
text 210,190,"totalmem " + STR$(totalmem)
text 210,210,"hardware " + STR$(hardware)
text 210,230,"bitdepth " + STR$(bitdepth)
text 210,250,"screenhgt " + STR$(screenhgt)
text 210,270,"screenwide " + STR$(screenwide)
return