src/OBJObject.h

Go to the documentation of this file.
00001 #ifndef OBJOBJECT_H
00002 #define OBJOBJECT_H
00003 
00004 
00005 #include <vector>
00006 
00007 #include "Object.h"
00008 #include "PrimitiveFactories.h"
00009 #include "KDTree.h"
00010 
00011 
00016 class OBJObject : public Object
00017 {
00018 public:
00023     OBJObject(const std::string & fileName);
00024 
00027     virtual ~OBJObject();
00028 
00033     virtual Object * createCopy()
00034     {
00035         return new OBJObject(*this);
00036     }
00037 
00040     virtual void setShader(Shader * sh);
00041 
00044     virtual void setCastShadows(bool b);
00045 
00046 protected:
00050     class ObjectFileOpenException : public std::exception
00051     {
00052     public:
00055         ObjectFileOpenException(const std::string filename) : mFileName(filename)
00056         {}
00057         
00058         virtual ~ObjectFileOpenException() throw() {}
00059 
00062         const char* what() const throw()
00063         {
00064             static std::string error;
00065             error = "Exception in ObjectParser (Object::Read)\n This file returned a bad status: \"";
00066             error += mFileName + "\"";
00067             return error.c_str();
00068         }
00069 
00070     private:
00071         const std::string mFileName; 
00072     };   
00073 
00074 
00076     std::vector<Primitive *> *  mPrimitives;
00077 
00079     KDTree *                    mKdTree;
00080 
00081 
00087     OBJObject(const OBJObject & other);
00088 
00093     virtual bool doIntersect(Ray & localRay) const
00094     {
00095         return mKdTree->intersect(localRay);
00096     }
00097 
00103     void read(const std::string & fileName, const PrimitiveFactory & factory = TexturedSmoothTriangleFactory());
00104 
00107     virtual void calcBounds();
00108 
00111     virtual void buildAccelStructure();
00112 };
00113 
00114 
00115 #endif
00116 

Generated on Fri Feb 1 00:01:42 2008 for Grayfall by  doxygen 1.5.1