TGC Codebase Backup



AlienViewer by Lzdude69

27th May 2004 21:26
Summary

A prototype of a section of my AlienMaker program. This is the model viewing part.



Description

A prototype of a section of my AlienMaker program. This is the model viewing part. This is a fairly simple model viewer, that was designed as a section of my AlienMaker. Possibly in the future I will supply the other sections. To give you an insight of AlienMaker; AlienMaker is in development right now, but obviously not finished. AlienMaker will allow you to aniamte models (possibly make simple ones), create a matrix, and place models on the matrix, like a world builder, with more features.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem start up viewer
set window on
sync on
sync rate 40

rem prompt
print "commands:"
print "press enter to load a cube"
print "press ctrl and shift to zoom"
print "press p to play object"
print "press s to stop object"
print "press g to ghost object"
print "press w to swith to wireframe"
print "press c to clear object"
print "press up and down to switch limbs"
print "press , and . to rotate the specified limb"
print "press m and n to rotate the specified limb"
print "press left and right to rotate the specified limb"
print "press 1 to hide specified limb, and 2 to show specified limb"
print

rem load a model
input "object filename>";object$
if object$="" then ld=0 else ld=1
if ld=1
if file exist(object$) then ex=1 else ex=2
if ex=1
load object object$,1
endif
if ex=2
ld=0
endif
endif
if ld=0
if ex=2 then print "File not Found...Loading cube..."
wait (5000):
make object cube 1,4
endif

rem start main loop
do

rem find out how many limbs the object has
perform checklist for object limbs 1
numberoflimbs=checklist quantity()

rem make controls
if inkey$()= "p" then play object 1
if inkey$()= "s" then stop object 1
if inkey$()= "w" then set object 1,0,1,1
if inkey$()= "g" then ghost object on 1,0
if inkey$()= "c" then set object 1,1,1,1 : ghost object off 1

rem make a movable
if mouseclick()=1
cya#=wrapvalue(cya#+(mousemovex()/3.0))
cxa#=cxa#+(mousemovey()/3.0)
cx#=newxvalue(x#,cya#,sin(cxa#)*10)
cz#=newzvalue(z#,cya#,sin(cxa#)*10)
rotate object 1,wrapvalue(cxa#),cya#,0
endif

rem create zoom
if shiftkey()=1 then move camera .5
if controlkey()=1 then move camera -.5

rem variables
rox#=rox#
roy#=roy#
roz#=roz#

rem select a limb
lastlim=lim
if upkey()=1
	lim=lim+1 : repeat : until upkey()=0
endif
if downkey()=1
	lim=lim-1 : repeat : until downkey()=0
endif
if lim<0 or lim>numberoflimbs then lim=lastlim
if lim<>lastli
	roy#=limb angle y(1,lim)
	rox#=limb angle x(1,lim)
	roz#=limb angle z(1,lim)
endif

rem rotate the selected limb
if leftkey()=1 then roy#=roy#+5
if rightkey()=1 then roy#=roy#-5
if inkey$()="m" then rox#=rox#+5
if inkey$()="n" then rox#=rox#-5
if inkey$()="," then roz#=roz#+5
if inkey$()="." then roz#=roz#-5

rem hide and show limb controls
if inkey$()="1" then hide limb 1,lim
if inkey$()="2" then show limb 1,lim  

rem do the actual rotation
roy#=wrapvalue(roy#)
rox#=wrapvalue(rox#)
roz#=wrapvalue(roz#)
rx=curvevalue(rox#,rx,10)
ry=curvevalue(roy#,ry,10)
rz=curvevalue(roz#,rz,10)
rotate limb 1,lim,rox#,roy#,roz# 

rem print how many limbs the object has
set cursor 0,0
print "This object has ";checklist quantity();" limbs."

rem show company name
set cursor 0,460
print "Animation creator by: AlienSoftware"

rem show object information
set cursor 0,20
print
print "Limb Number:";lim
print
if limb exist(1, lim)=1
	print "limb offset x = ";limb offset x(1, lim)
	print "limb offset y = ";limb offset y(1, lim)
	print "limb offset z = ";limb offset z(1, lim)
	print "limb angle x = ";limb angle x(1, lim)
	print "limb angle y = ";limb angle y(1, lim)
	print "limb angle z = ";limb angle z(1, lim)
	print "limb position x = ";limb position x(1, lim)
	print "limb position y = ";limb position y(1, lim)
	print "limb position z = ";limb position z(1, lim)
	print "limb texture = ";limb texture(1, lim)
	print "limb visible = ";limb visible(1, lim)
endif

rem display the object
position object 1,0,0,0

rem end loop
sync
loop

rem delete object
delete object 1

rem end the program
end