xFile_Loader Class Reference

Class for parsing an XFile and retrieving its data. More...

#include <xFile_Loader.h>

Collaboration diagram for xFile_Loader:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 xFile_Loader ()
virtual ~xFile_Loader ()
virtual bool initialise ()
virtual bool cleanUp ()
virtual bool reset ()
bool load (LPCSTR fileName, bool verboseOutput=true)
void outputTemplateHierarchyAsText ()
void outputFrameHierarchyAsText ()

Public Attributes

vector< Mesh * > meshes
 List of pointers to all frames in the file (non-heirarchical).
vector< Material * > materials
 List of pointers to all frames in the file (non-heirarchical).
vector< EffectInstance * > effectInstances
 List of pointers to all frames in the file (non-heirarchical).
vector< TextureFilename * > textureFileNames
 List of pointers to all frames in the file (non-heirarchical).
vector< AnimationSet * > animationSets
 List of pointers to all frames in the file (non-heirarchical).
Frame * rootFrame
 List of pointers to all frames in the file (non-heirarchical).

Protected Member Functions

void displayFrameHierachy (Frame *parent)
 Stores if the text output is verbose or concise.
void displayHierarchy (stTemplate *parent)
void clearHierarchy (stTemplate *parent)
const stXDefines * getType (LPCSTR str)
bool processBlocks ()
Mesh * processMesh ()
MeshNormals * processMeshNormals ()
MeshTextureCoords * processMeshTextureCoords ()
FrameTransformMatrix * processFrameTransformationMatrix ()
Frame * processFrame ()
MeshMaterialList * processMeshMaterilalList ()
Material * processMaterial ()
TextureFilename * processTextureFileName ()
EffectInstance * processEffectInstance ()
EffectParamDword * processEffectParamDword ()
EffectParamFloats * processEffectParamFloats ()
EffectParamString * processEffectPramString ()
AnimationSet * processAnimationSet ()
Animation * processAnimation ()
AnimationOptions * processAnimationOptions ()
AnimationKey * processAnimationKey ()
void getNext ()
 Stores the previous back1 string from the file.
void debug (char *message)
 Stack of previous parents gets pushed when entering a new block and popped when leaving a block.
string trimSpeechMarkString (string instr)
 reference to the new template being added to the file template hierarchy (used by parsing functions to get generic template data).

Protected Attributes

FrameTransformMatrix worldTransform
 Public pointer to the root frame (added by the loader to all meshes) which can give linked-list access to all frames in the frame hierarchy.
bool verbose
 Stores the Root World Transformation of the Entire Hierarchy.
string current
 Stores the root Block of the file in the hierarchy.
string back1
 Stores the current string from the file.
string back2
 Stores the previous current string from the file.
stack< stTemplate * > parents
 Gets the next current string and updates back1,back2 and back3 strings.
ifstream oFile
 Outputs a specified debug message if DEBUG_X is defined.
LPCSTR FileName
 Input file stream used to access the file.
stTemplatenewTemplate
 Stores the current FileName of the File.


Detailed Description

Class for parsing an XFile and retrieving its data.

This class provides a platform independent interface to a DirectX (.X) format file.

Author:
David Beirne

Definition at line 73 of file xFile_Loader.h.


Constructor & Destructor Documentation

xFile_Loader::xFile_Loader (  ) 

Default no-args constructor, initialises class instance.

Definition at line 6 of file xFile_Loader.cpp.

References FileName, initialise(), rootFrame, and verbose.

xFile_Loader::~xFile_Loader (  )  [virtual]

Default destructor, clears any memory used by class instance.

Definition at line 18 of file xFile_Loader.cpp.

References cleanUp().


Member Function Documentation

bool xFile_Loader::initialise (  )  [virtual]

Initialises the class instance.

Returns:
true on success, false on fail.

Definition at line 27 of file xFile_Loader.cpp.

References back1, back2, and current.

Referenced by reset(), and xFile_Loader().

bool xFile_Loader::cleanUp (  )  [virtual]

Cleans up any memory used by the class instance.

Returns:
true on success, false on fail.

Definition at line 39 of file xFile_Loader.cpp.

References clearHierarchy(), parents, and rootFrame.

Referenced by reset(), and ~xFile_Loader().

bool xFile_Loader::reset (  )  [virtual]

Resets the class instance.

Returns:
true on success, false on fail.

Definition at line 51 of file xFile_Loader.cpp.

References cleanUp(), and initialise().

Referenced by load().

bool xFile_Loader::load ( LPCSTR  fileName,
bool  verboseOutput = true 
)

Loads the specified X-File data into memory.

Returns:
true on success, false on fail.
Parameters:
fileName specifies the file to load.
verboseOutput specifies if text is output for debug purposes.

Definition at line 65 of file xFile_Loader.cpp.

References debug(), FileName, getType(), stTemplate::Name, oFile, parents, processBlocks(), reset(), rootFrame, stTemplate::type, verbose, and worldTransform.

Referenced by xFile_Render::load().

void xFile_Loader::outputTemplateHierarchyAsText (  ) 

Public function fro displaying the file hierarchy (limited to showing the entire hierarchy from the root down).

Definition at line 136 of file xFile_Loader.cpp.

References displayHierarchy().

void xFile_Loader::outputFrameHierarchyAsText (  ) 

Public function for displaying the Frame hierarchy (limited to showing the entire hierarchy from the root down).

Definition at line 216 of file xFile_Loader.cpp.

References displayFrameHierachy(), and rootFrame.

void xFile_Loader::displayFrameHierachy ( Frame *  parent  )  [protected]

Stores if the text output is verbose or concise.

Outputs the Frame hierarchy as text recursively from the specified parent / root (used for debugging). parent frame, specifies the root of transformation, used in recursive calls.

Definition at line 227 of file xFile_Loader.cpp.

Referenced by outputFrameHierarchyAsText().

void xFile_Loader::displayHierarchy ( stTemplate parent  )  [protected]

Outputs the file hierarchy as text recursively from the specified parent / root.

Parameters:
pointer to the parent to display the hierarchy down from.

Definition at line 145 of file xFile_Loader.cpp.

References stTemplate::children, stTemplate::Name, and stTemplate::type.

Referenced by outputTemplateHierarchyAsText().

void xFile_Loader::clearHierarchy ( stTemplate parent  )  [protected]

Clears recursively from the specified template.

Parameters:
pointer to the parent to clear the hierarchy down from.

Definition at line 174 of file xFile_Loader.cpp.

References stTemplate::children.

Referenced by cleanUp().

const stXDefines * xFile_Loader::getType ( LPCSTR  str  )  [protected]

Compares a specified string to the list of X-File Templates and returns a pointer to the stXDefines which specifies that type or NULL if no match found.

Returns:
pointer to the definition of the template type stored in the DirectX_FileTemplates lookup table if a match is found, otherwise returns NULL.
Parameters:
string to compare with those in the templates lookup table.

Definition at line 195 of file xFile_Loader.cpp.

Referenced by load(), and processBlocks().

bool xFile_Loader::processBlocks (  )  [protected]

Itterative function steps through file reading blocks and building up hierarchy of data structures.

Returns:
true on success, false on fail.

Definition at line 273 of file xFile_Loader.cpp.

References back1, back2, stTemplate::children, current, getNext(), getType(), stTemplate::heirachyDepth, stTemplate::Name, newTemplate, oFile, stTemplate::parent, parents, stTemplate::pdata, processAnimation(), processAnimationKey(), processAnimationOptions(), processAnimationSet(), processEffectInstance(), processEffectParamDword(), processEffectParamFloats(), processEffectPramString(), processFrame(), processFrameTransformationMatrix(), processMaterial(), processMesh(), processMeshMaterilalList(), processMeshNormals(), processMeshTextureCoords(), processTextureFileName(), and stTemplate::type.

Referenced by load().

Mesh * xFile_Loader::processMesh (  )  [protected]

Parses a Mesh block and fills in / returns a Mesh structure containing the data.

Returns:
pointer to filled Mesh struct.

Definition at line 389 of file xFile_Loader.cpp.

References current, getNext(), meshes, stTemplate::Name, newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

MeshNormals * xFile_Loader::processMeshNormals (  )  [protected]

Parses a MeshNormals block and fills in / returns a MeshNormals structure containing the data.

Returns:
pointer to filled MeshNormals struct.

Definition at line 561 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

MeshTextureCoords * xFile_Loader::processMeshTextureCoords (  )  [protected]

Parses a MeshTextureCoords block and fills in / returns a MeshTextureCoords structure containing the data.

Returns:
pointer to filled MeshTextureCoords struct.

Definition at line 710 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

FrameTransformMatrix * xFile_Loader::processFrameTransformationMatrix (  )  [protected]

Parses a FrameTransformMatrix block and fills in / returns a FrameTransformMatrix structure containing the data.

Returns:
pointer to filled FrameTransformMatrix struct.

Definition at line 798 of file xFile_Loader.cpp.

References current, debug(), getNext(), stTemplate::Name, newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

Frame * xFile_Loader::processFrame (  )  [protected]

Parses a Frame block and fills in / returns a Frame structure containing the data.

Returns:
pointer to filled Frame struct.

Definition at line 878 of file xFile_Loader.cpp.

References stTemplate::Name, newTemplate, stTemplate::parent, stTemplate::pdata, rootFrame, and stTemplate::type.

Referenced by processBlocks().

MeshMaterialList * xFile_Loader::processMeshMaterilalList (  )  [protected]

Parses a MeshMaterialList block and fills in / returns a processMeshMaterilalList structure containing the data.

Returns:
pointer to filled processMeshMaterilalList struct.

Definition at line 911 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

Material * xFile_Loader::processMaterial (  )  [protected]

Parses a Material block and fills in / returns a Material structure containing the data.

Returns:
pointer to filled material struct.

Definition at line 970 of file xFile_Loader.cpp.

References current, debug(), getNext(), materials, stTemplate::Name, newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

TextureFilename * xFile_Loader::processTextureFileName (  )  [protected]

Parses a TextureFilename block and fills in / returns a TextureFilename structure containing the data.

Returns:
pointer to filled TextureFilename struct.

Definition at line 1098 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, textureFileNames, trimSpeechMarkString(), stTemplate::type, and verbose.

Referenced by processBlocks().

EffectInstance * xFile_Loader::processEffectInstance (  )  [protected]

Parses a EffectInstance block and fills in / returns a EffectInstance structure containing the data.

Returns:
pointer to filled EffectInstance struct.

Definition at line 1143 of file xFile_Loader.cpp.

References current, debug(), effectInstances, getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, trimSpeechMarkString(), stTemplate::type, and verbose.

Referenced by processBlocks().

EffectParamDword * xFile_Loader::processEffectParamDword (  )  [protected]

Parses a effectParamDword block and fills in / returns a effectParamDword structure containing the data.

Returns:
pointer to filled effectParamDword struct.

Definition at line 1190 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

EffectParamFloats * xFile_Loader::processEffectParamFloats (  )  [protected]

Parses a EffectParamFloats block and fills in / returns a EffectParamFloats structure containing the data.

Returns:
pointer to filled EffectParamFloats struct.

Definition at line 1238 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

EffectParamString * xFile_Loader::processEffectPramString (  )  [protected]

Parses a EffectParamString block and fills in / returns a EffectParamString structure containing the data.

Returns:
pointer to filled EffectParamString struct.

Definition at line 1328 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

AnimationSet * xFile_Loader::processAnimationSet (  )  [protected]

Parses an AnimationSet block and fills in / returns a AnimationSet structure containing the data.

Returns:
pointer to filled AnimationSet struct.

Definition at line 1378 of file xFile_Loader.cpp.

References animationSets, stTemplate::Name, newTemplate, and verbose.

Referenced by processBlocks().

Animation * xFile_Loader::processAnimation (  )  [protected]

Parses an Animation block and fills in / returns a Animation structure containing the data.

Returns:
pointer to filled Animation struct.

Definition at line 1401 of file xFile_Loader.cpp.

References current, debug(), getNext(), stTemplate::Name, newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

AnimationOptions * xFile_Loader::processAnimationOptions (  )  [protected]

Parses an AnimationOptions block and fills in / returns a AnimationOptions structure containing the data.

Returns:
pointer to filled AnimationOptions struct.

Definition at line 1451 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

AnimationKey * xFile_Loader::processAnimationKey (  )  [protected]

Parses an AnimationKey block and fills in / returns a AnimationKey structure containing the data.

Returns:
pointer to filled AnimationKey struct.

Definition at line 1497 of file xFile_Loader.cpp.

References current, debug(), getNext(), newTemplate, stTemplate::parent, stTemplate::pdata, stTemplate::type, and verbose.

Referenced by processBlocks().

void xFile_Loader::getNext (  )  [protected]

Stores the previous back1 string from the file.

Gets the next current string and updates back1, and back2 strings.

Definition at line 1691 of file xFile_Loader.cpp.

References back1, back2, current, and oFile.

Referenced by processAnimation(), processAnimationKey(), processAnimationOptions(), processBlocks(), processEffectInstance(), processEffectParamDword(), processEffectParamFloats(), processEffectPramString(), processFrameTransformationMatrix(), processMaterial(), processMesh(), processMeshMaterilalList(), processMeshNormals(), processMeshTextureCoords(), and processTextureFileName().

void xFile_Loader::debug ( char *  message  )  [protected]

Stack of previous parents gets pushed when entering a new block and popped when leaving a block.

Outputs a specified debug message if DEBUG_X is defined.

Definition at line 1701 of file xFile_Loader.cpp.

Referenced by load(), processAnimation(), processAnimationKey(), processAnimationOptions(), processEffectInstance(), processEffectParamDword(), processEffectParamFloats(), processEffectPramString(), processFrameTransformationMatrix(), processMaterial(), processMeshMaterilalList(), processMeshNormals(), processMeshTextureCoords(), and processTextureFileName().

string xFile_Loader::trimSpeechMarkString ( string  instr  )  [protected]

reference to the new template being added to the file template hierarchy (used by parsing functions to get generic template data).

Trims the ' " ',' " ' and ' ; ' characters from the ends of string values.

Returns:
string with no speech marks.
Parameters:
string with speech marks.

Definition at line 1717 of file xFile_Loader.cpp.

Referenced by processEffectInstance(), and processTextureFileName().


The documentation for this class was generated from the following files:
Generated on Sun May 18 21:45:10 2008 for PS2X by  doxygen 1.5.4