InstancedShape.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  InstancedShape
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @author Matthew Jacobs (jacobs.mh@gmail.com)
00005    @date   Fall 2008
00006    
00007    @brief
00008       Acts as a proxy for a shape which has been instanced
00009    <!-------------------------------------------------------------------->**/
00010 
00011 #ifndef INSTANCED_SHAPE_H_
00012 #define INSTANCED_SHAPE_H_
00013 
00014 #include <shapes/Transformable.h>
00015 
00016 class InstancedShape : public Transformable {
00017    public:
00018       ///@name Constructors
00019       //@{-----------------------------------------------------------------
00020       
00021       inline InstancedShape(Shape *instancee = NULL)
00022          : Transformable(), m_instancee(instancee)
00023       { }
00024       
00025       virtual ~InstancedShape()
00026       { }
00027       
00028       
00029       //@}-----------------------------------------------------------------
00030       ///@name Initialization
00031       //@{-----------------------------------------------------------------
00032       
00033       /**
00034        * @brief
00035        *    Initializes this InstancedShape, assuming the underlying instancee 
00036        * has already been initialized
00037        */
00038       virtual void init();
00039       
00040       
00041       //@}-----------------------------------------------------------------
00042       ///@name Main usage interface
00043       //@{-----------------------------------------------------------------
00044       
00045       /**
00046        * @brief
00047        *    Tests the given ray with this object for intersection. If a valid 
00048        * intersection exists, its "t" value will be returned and the given 
00049        * SurfacePoint will be initialized with enough data for this object to 
00050        * later fill in all relevant information lazily (world space normal 
00051        * at intersection point, uv coordinates, etc.)
00052        * 
00053        * @note if you only care about whether or not an intersection exists 
00054        *    and don't actually need to know the exact intersection point, 
00055        *    see the intersects method instead.
00056        * @returns the smallest positive "t" value of any intersections 
00057        *    found, or INFINITY if no valid intersection exists
00058        */
00059       virtual real_t getIntersection(const Ray &ray, SurfacePoint &pt);
00060       
00061       /**
00062        * @brief
00063        *    Used for occlusion/visibility testing where you don't necessarily 
00064        * care about anything other than whether or not an intersection exists.
00065        * (generally faster than getIntersection)
00066        * 
00067        * @note default implementation defers to getIntersection
00068        * @returns whether or not the given ray intersects this object with a 
00069        *    positive "t" value greater than EPSILON and less than the given 
00070        *    @p tMax
00071        */
00072       virtual bool intersects(const Ray &ray, real_t tMax = INFINITY);
00073       
00074       /**
00075        * @returns whether or not this Shape supports the concept of a geometric
00076        *    surface normal defined over its surface
00077        * 
00078        * @note default implementation returns true
00079        */
00080       virtual bool hasNormal() const;
00081       
00082       /**
00083        * @brief
00084        *    Displays a crude OpenGL preview of this shape
00085        * 
00086        * @note default implementation calls preview on this shape's material
00087        */
00088       virtual void preview();
00089       
00090       
00091       //@}-----------------------------------------------------------------
00092       ///@name Sampling functionality
00093       //@{-----------------------------------------------------------------
00094       
00095       /**
00096        * @returns a point chosen uniformly random over the surface of this 
00097        *    shape in 'pt'
00098        * @note the probability density of selecting this point is assumed to 
00099        *    be (1.0 / getSurfaceArea())
00100        */
00101       virtual void getRandomPoint(SurfacePoint &pt);
00102       
00103       /**
00104        * @returns the point on the surface of this shape corresponding to the 
00105        *    given UV coordinates
00106        */
00107       virtual Point3 getPosition(const UV &uv);
00108       
00109       
00110       //@}-----------------------------------------------------------------
00111       ///@name Lazy evaluation of SurfacePoint information
00112       //@{-----------------------------------------------------------------
00113       
00114       virtual void initSurfacePoint(SurfacePoint &pt) const;
00115       
00116    protected:
00117       virtual void _getUV(SurfacePoint &pt) const;
00118       virtual void _getGeometricNormal(SurfacePoint &pt) const;
00119       
00120       virtual real_t _getSurfaceArea();
00121       
00122       //@}-----------------------------------------------------------------
00123       
00124    protected:
00125       Shape *m_instancee;
00126 };
00127 
00128 #endif // INSTANCED_SHAPE_H_
00129 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6