ShapeSet.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  ShapeSet
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @author Matthew Jacobs (jacobs.mh@gmail.com)
00005    @date   Fall 2008
00006    
00007    @brief
00008       Represents a collection of shapes which all have the same transformation
00009    <!-------------------------------------------------------------------->**/
00010 
00011 #ifndef SHAPE_SET_H_
00012 #define SHAPE_SET_H_
00013 
00014 #include <shapes/Transformable.h>
00015 #include <utils/PropertyMap.h>
00016 
00017 class SpatialAccel;
00018 
00019 class ShapeSet : public Transformable, public PropertyMap {
00020    public:
00021       ///@name Constructors
00022       //@{-----------------------------------------------------------------
00023       
00024       inline ShapeSet(bool ownMemory = true)
00025          : Transformable(), PropertyMap(), 
00026            m_primitives(), m_spatialAccel(NULL), 
00027            m_ownMemory(ownMemory)
00028       { }
00029       
00030       inline ShapeSet(const PrimitiveList &primitiveList, 
00031                       bool ownMemory = true)
00032          : Transformable(), PropertyMap(), 
00033            m_primitives(primitiveList), m_spatialAccel(NULL), 
00034            m_ownMemory(ownMemory)
00035       { }
00036       
00037       virtual ~ShapeSet();
00038       
00039       
00040       //@}-----------------------------------------------------------------
00041       ///@name Core functionality
00042       //@{-----------------------------------------------------------------
00043       
00044       virtual void init(bool initChildren);
00045       virtual void init();
00046       
00047       virtual void preview();
00048       
00049       virtual real_t getIntersection(const Ray &ray, SurfacePoint &pt);
00050       
00051       virtual bool   intersects(const Ray &ray, real_t tMax = INFINITY);
00052       
00053       
00054       //@}-----------------------------------------------------------------
00055       ///@name Accessors / Mutators
00056       //@{-----------------------------------------------------------------
00057       
00058       inline unsigned size() const {
00059          return m_primitives.size();
00060       }
00061       
00062       inline Shape *operator[](unsigned int index) {
00063          ASSERT(index >= 0 && index < size());
00064          
00065          return m_primitives[index];
00066       }
00067       
00068       inline void push_back(Shape *shape) {
00069          ASSERT(shape);
00070          
00071          m_primitives.push_back(shape);
00072       }
00073       
00074       inline void clear() {
00075          m_primitives.clear();
00076       }
00077       
00078       inline PrimitiveList &getPrimitives() {
00079          return m_primitives;
00080       }
00081       
00082       
00083       //@}-----------------------------------------------------------------
00084       
00085    protected:
00086       virtual void _getUV(SurfacePoint &pt) const;
00087       virtual void _getGeometricNormal(SurfacePoint &pt) const;
00088       
00089       /**
00090        * @returns the total surface area of this shape
00091        */
00092       virtual real_t _getSurfaceArea();
00093       
00094    protected:
00095       PrimitiveList     m_primitives;
00096       SpatialAccel     *m_spatialAccel;
00097       bool              m_ownMemory;
00098 };
00099 
00100 #endif // SHAPE_SET_H_
00101 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6