Reading the Data into the Scene

[ LiB ]

Reading the Data into the Scene

One major function is declared that reads in all the data from an ASCII file. It parses and branches code based on the class name . The method reads in a file from the local file system and begins to parse each class. If a specific class is found, the class is read in and the logic is handled. The important four elements that the parser searches for are Camera , Lights , Spheres , and Triangles . The parser also searches for the Render_Settings class, but it isn't considered an element of the scene. This class is solely designed to set up the specific lighting effects for the scene that should be rendered by the rendering algorithm. Recall that you can have n amount of lights, spheres, and triangles, but you can only have one camera and one Render_Settings class.

NOTE

NOTE

The Render_Settings class isn't really considered a component of the scene because it deals with the ren- derer's settings for selecting specific types of lighting effects.

Here is the declaration:

 bool   Read_In_Scene(char * filename); 

Here is the body:

 bool  cScene::Read_In_Scene(char * filename) {    this->isDataReady = true;    ifstream  fin ( filename   ;    char buffer[BUFFER_LENGTH];    while(!fin.eof())    {        // read in data        fin >> buffer;        // branch data        if(strcmp(buffer,"Camera")        == 0)        {           Read_Camera( fin );        }        else if(strcmp(buffer,"Render_Settings") == 0)        {           Read_Render_Settings( fin );        }       else if(strcmp(buffer,"Light")      == 0)      {      Read_Light( fin );      }      else if(strcmp(buffer,"Sphere")     == 0)      {         Read_Sphere( fin );      }      else if(strcmp(buffer,"Triangle") == 0)      {          Read_Triangle( fin );       }       else       {       }    }    fin.close();    return true; } 

[ LiB ]


Focus On Photon Mapping
Focus On Photon Mapping (Premier Press Game Development)
ISBN: 1592000088
EAN: 2147483647
Year: 2005
Pages: 128
Authors: Marlon John

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net