#------------------------------------------------------------------------------ # Name: sample.gfx # Desc: GFX file format demonstration # # Autumn 2000 - Ge Wang - GFX file format design and implementation #------------------------------------------------------------------------------ #-- include statement - see 'COMPOSITE OBJECT' section for explanation -- INCLUDE composite_collection1.gfx #------------------------------------------------------------------------------ # ************************ -- SIMPLE OBJECTS -- ***************************** #------------------------------------------------------------------------------ # -- define simple object inline called 'quad' -- OBJECT quad SIMPLE # -- vertices ( x y z=0 w=1 ) -- v 0 0 0 v 1 0 0 v 1 0 -1 v 0 0 -1 # -- texture coordinates ( u v w=0 ) -- vt 0 0 vt 1 0 vt 1 1 vt 0 1 # -- normals ( x y z ) -- vn 0 1 0 # -- colors (r g b a=1) -- vc 0.4 1.0 0.4 1.0 # -- face 'v/vt/vn/vc' -- f 1/1/1/1 2/2/1/1 3/3/1/1 4/4/1/1 END # -- or you load the content from .obj file: OBJECT couch SIMPLE FILE couch.obj END #-- SIMPLE objects defines a rigid polyhedral 3D model #-- should have one or more vertices, but can also have texture coordinates, # normals, and color #-- use these vertices (and optionally tex coordinates, normals, and colors # to define faces, line segments, and points #-- no limit on number of vertices/faces/lines/points #------------------------------------------------------------------------------ # ************************ -- COMPOSITE OBJECTS -- ************************** #------------------------------------------------------------------------------ #-- define composite object called 'sphere_over_quad' OBJECT sphere_over_quad COMPOSITE # -- center our quad -- TRANSLATE -0.5 0.0 .5 # -- draw 'quad' -- SUBOBJ quad # -- restore our local transformation -- SEPARATOR # -- elevate along y -- TRANSLATE 0.0 1.0 0.0 # -- color it yellow -- COLOR .8 .8 0 # -- draw the sphere using glut -- GLUT SPHERE .25 16 16 END #-- composite objects can also other defined composite objects #-- you may include the contents of another .gfx file to use # the INCLUDE statement: # # INCLUDE composite_collection1.gfx # #-- this will make the items defined in the other .gfx file available # to objects in this file _after_ the INCLUDE statement. #-- you can only INCLUDE other .gfx files #------------------------------------------------------------------------------ # ****************************** -- LIGHT -- ******************************** #------------------------------------------------------------------------------ LIGHT light_red # color for ambient, diffuse, and specular AMBIENT 1.0 0.0 0.0 1.0 DIFFUSE 1.0 0.0 0.0 1.0 SPECULAR 1.0 0.0 0.0 1.0 # constant, linear, and quadratic attenuation CA 1.0 LA 0.0 QA 0.0 END #-- AMBIENT, DIFFUSE, and SPECULAR each default to 1.0 1.0 1.0 1.0 #-- CA default to 1.0 - LA and QA default to 0.0 #------------------------------------------------------------------------------ # ***************************** -- SCENE -- ********************************* #------------------------------------------------------------------------------ SCENE main # place camera LOOKAT 0 2 5 0 1 0 0 1 0 # place 'light_red' LIGHT light_red 2 5 0 1 # place a 'sphere_over_quad' object TRANSLATE 0 0 -2 SUBOBJ sphere_over_quad SEPARATOR # place another 'sphere_over_quad' object at origin, rotated 45 about y ROTATE 45 0 1 0 SUBOBJ sphere_over_quad SEPARATOR END