Graphics.NewbieCube - lordmundi/wikidoctest GitHub Wiki

Newbie Cube

« Starting Doug | NewbieIndex | Beyond Black »

Goal

Render a cube using a wavefront file

Make A Wavefront File

The cube has 8 vertices marked 'v' and 6 faces marked 'f'. The line f 1 2 3 4 says that a face is made from the first four vertices.

% vi cube.obj 


v  0.5000000  0.5000000 -0.5000000
 v  0.5000000 -0.5000000 -0.5000000
 v -0.5000000 -0.5000000 -0.5000000
 v -0.5000000  0.5000000 -0.5000000
 v  0.500000   0.5000000  0.5000000
 v  0.500000  -0.5000000  0.5000000
 v -0.5000000 -0.5000000  0.5000000
 v -0.5000000  0.5000000  0.5000000
 f 1 2 3 4
 f 5 8 7 6
 f 1 5 6 2
 f 3 7 8 4
 f 5 1 4 8
 f 2 6 7 3

Doug Does Not Comprendo Wavefront

There are three choices:

  1. Make a plugin for wavefront files (TODO)
  2. Convert wavefront to something like AC3D which Doug understands
  3. Cheat and just grab cube.ac

Create Input Files For Doug To Load The Cube

I recommend reading the bare bones Doug section which gives some context for the input files you need to create. If you haven't looked at user data information I highly recommend it. Go on. This will still be here when you get back.

Then what we want to, is to make a new userdata area specific to this cube set up:

% cp -a $DOUG_HOME/userdata $DOUG_HOME/userdata.cube
 % setenv USERDATA $DOUG_HOME/userdata.cube

Copy the struct file and model file to $USERDATA

% cp [cube.str][9] ${USERDATA}/structs
 % cp [cube.ac][6] ${USERDATA}/models

Edit the user.cfg to add the cube stuff

% vi ${USERDATA}/user.cfg   # this is auto sourced
   # copy the LOADS block from [cube.cfg][10] into
   # user.cfg right after DSP_CONFIG and before POSTLOAD block
     LOADS
     {
         CUBE
         {
              scenes
              {
                  default ${USERDATA}/structs/cube.str
              }
         }
      }
   # copy the CUBE block from under DISPLAY from [cube.cfg][10] 
   # into user.cfg under the DISPLAY block between DEFAULT and ENG_GRAPHICS
        CUBE
        {
                channel1
                {

                      view.MAIN   CubeCam perspective( 40.9, 1.333, 2.0, 1000000000000.0 ); xywh( 0, 0, 640, 480 ); attribs(CAMINFO);
                }
         }
   # Finally, add the following under the DEFINES block in user.cfg
   # This will disable all the CEV stuff in the scene
     DOUG_LOAD_NAME CUBE
     DOUG_STATE_DIR ${USERDATA}/states 

But wait? How does doug know about the cube model, cube.ac ? Great question, we want to put that here:

% vi ${USERDATA}/configs/user_models.cfg
   # Copy the line from  [cube.cfg][10] 
        node( CUBE ) ; model (cube.ac) ; parent( CUBE_BASE ) ;
   # To user_models.cfg under DSP_CONFIG { DATA { SCENE_LOAD { MODELS {

Doug Init

Things should be ready… Give it a whirl..

% cd $DOUG_HOME
 % ./run_graphics -load CUBE -display CUBE

You should see all sorts of messages in the x-terminal, and the following splash screen followed by what looks like a black screen of death (which will suck printer ink for no good reason… if you are using a printer):


Continuing

The tutorial continues with another fun filled chapter which will hopefully walk us beyond The Black Screen Of Death…

« Starting Doug | NewbieIndex | Beyond Black »