TGC Codebase Backup



3D Model Viewer Principles by MikeS

24th Mar 2004 15:59
Summary

Learn how to make a basic 3D model viewer.



Description

Learn how to make a basic 3D model viewer.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` This tutorial was created by Yellow -Mike- 3-24-04
` Although not necessary, it would be nice to be credited and
` notified at yellow1dbp@hotmail.com if this was used in a game
` Thanks, and I hope the tutorial helps.

`3D model viewer Tutorial
`In this tutorial you'll learn how to build a simple 3D model viewer.

sync on : sync rate 60       `Set up the refresh rate
backdrop on                  `Set up the 3D display
set display mode 1024,768,32 `Set up the screen display
set text size 26             `Set the text size

` We make our test object that we will be viewing
` This object can be replaced by any object you'd like to view.
` Just remember to make the object number 1!
make object cube 1,2

do

` Here we'll list some text statements so we can remember
` the basic commands to our 3D model viewer.

text 0,0,"1- Ghost object on   2- Ghost object off"
text 0,30,"3- Wireframe on      4- Wireframe off"
text 0,60,"+ - Yrotate object"
text 0,90,"Curved Basic Model Viewer tutorial"


if keystate(2)=1
  ghost object on 1 `This command ghosts the object if the key 1 is pressed.
endif

if keystate(3)=1
  ghost object off 1 `This command un-ghosts the object if the key 2 is pressed.
endif

if keystate(4)=1
  set object 1,0,1,1 `This will display the objects wireframe if 3 is pressed.
endif

if keystate(5)=1
  set object 1,1,1,1 `This will restore the object from a wireframe if 4 is pressed.
endif

if keystate(13)=1
  yrotate object 1,object angle y(1)+1 `This rotates the object if the "+" is pressed.
endif


sync
loop

`You now have the basis of a 3D model viewer.
`Now it's up to you to add a pretty interface and more commands and functionality.


`Hope this helped
`Copyright(c) CurvedBasic 2004