basic 3d object control by chris allen6th Jan 2004 19:55
|
---|
Summary simple 3d model controller, which lets the user rotate, move and zoom in/out on the model Description this is the first program i have written with DarkBasic on my own. I have only had DarkBasic for a couple of days and although I'm sure almost everyone else will be able to do this it is a real acheivement for me. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem 3d object controller rem set screen display mode set display mode 800,600,16 rem hide the mouse pointer hide mouse rem turn sync on and set rate to 40 sync on sync rate 40 rem create variables for positioning and rotation of the 3d object rem positioning xPos = 0 yPos = 0 zPos = 0 rem rotation xRot = 0 yRot = 0 zRot = 0 rem load the 3d model load object "car.3ds",1 rem main loop do rem draw the co-ordinates on screen set cursor 0,0 print "x co-ordinate - ";xPos print "y co-ordinate - ";yPos print "z co-ordinate - ";zPos print " " print "horizontal rotation angle - ";xRot; " degrees" print "vertical rotation angle - ";yRot; " degrees" rem print instructions set cursor 0,380 print "controls:" print "left cursor - rotate model left" print "right cursor - rotate model right" print "up cursor - rotate model up" print "down cursor - rotate model down" print " " print "on the numeric keypad:" print "4 - to move model left" print "6 - to move model right" print "8 - to move model up" print "2 - to move model down" print "+ - to zoom in" print "- - to zoom out" rem draw the 3d object on screen in the correct position position object 1,xPos,yPos,zPos rotate object 1,xRot,yRot,zRot rem check for user input if leftkey()=1 then yRot=wrapvalue(yRot+3) if rightkey()=1 then yRot=wrapvalue(yRot-3) if upkey()=1 then xRot=wrapvalue(xrot+3) if downkey()=1 then xRot=wrapvalue(xRot-3) if inkey$()="4" then dec xPos if inkey$()="6" then inc xPos if inkey$()="8" then inc yPos if inkey$()="2" then dec yPos if inkey$()="-" then inc zPos if inkey$()="+" then dec zPos rem redraw the screen sync rem end of main loop loop |