src/rcrt/loaders/AnimLoader.cpp

Go to the documentation of this file.
00001 #include "AnimLoader.h"
00002 #include "conversion.hpp"
00003 
00004 using namespace std;
00005 
00006 namespace rcrt
00007 {
00008 
00009 AnimLoader::AnimLoader(std::string filePath):XMLLoader(filePath),materials(0),scene(0)
00010 {
00011         nextStartTag("animation");
00012         nextStartTag("frames");
00013         firstF = convertTo<int>(parser.getAttributeValue("","first"));
00014         lastF = convertTo<int>(parser.getAttributeValue("","last"));
00015         nextStartTag("materials");
00016         materials = new MaterialLoader(parser.getAttributeValue("","file"));
00017         nextStartTag("scene");
00018         scene = new SceneLoader(parser.getAttributeValue("","file"), materials);
00019         currentFrame = firstF-1;
00020         try {
00021                 goToFrame(firstF);
00022         }catch(XmlPullParserException e){
00023                 cout << e.description << endl;
00024         }
00025 }
00026 
00027 AnimLoader::~AnimLoader()
00028 {
00029 }
00030 
00031 bool AnimLoader::goToFrame(const int& n)
00032 {
00033         if(n < currentFrame || n > lastF)
00034                 return false;
00035         if(n == currentFrame)
00036                 return true;
00037 
00038         
00039         bool m = materials->goToFrame(n);
00040         bool s = scene->goToFrame(n);
00041         //TODO do something useful with bools from mat/scene?
00042         return true;
00043 }
00044 
00045 bool AnimLoader::nextFrame()
00046 {
00047         if(currentFrame >= lastF)
00048                 return false;
00049         else
00050                 currentFrame++;
00051         
00052         materials->nextFrame();
00053         scene->nextFrame();
00054         
00055         return true;
00056 }
00057 
00058 
00059 Scene* AnimLoader::getScene()
00060 {
00061         return scene->getScene();
00062 }
00063 
00064 Camera* AnimLoader::getCamera()
00065 {
00066         return scene->getCamera();
00067 }
00068 
00069 }

Generated on Thu Jan 31 19:26:19 2008 for RenderingCompetitionRayTracer by  doxygen 1.5.3