src/InfinitePlane.h

Go to the documentation of this file.
00001 #ifndef INFINITEPLANE_H
00002 #define INFINITEPLANE_H
00003 
00004 
00010 class InfinitePlane : public Primitive
00011 {
00012 public:
00017     InfinitePlane(Vec3f origin, Vec3f normal)
00018         : mNormal(normal.normal()),
00019             mOrigin(origin)
00020     {
00021         calcBounds();
00022     }
00023 
00026     ~InfinitePlane()
00027     {
00028     }
00029 
00034     bool intersect(Ray & ray) const
00035     {
00036         Vec3f diff = mOrigin - ray.org();
00037         float t = diff.dot(mNormal) / ray.dir().dot(mNormal);
00038         if (t < EPSILON || t > ray.t())
00039             return false;
00040         ray.setHit(this, t);
00041         return true;
00042     }
00043 
00044     virtual Vec3f normal(const Ray & /*ray*/) const
00045     {
00046         return mNormal;
00047     }
00048 
00049 
00055     void axes(const Ray & /*ray*/, Vec3f & /*x*/, Vec3f & /*y*/) const
00056     {
00057         assert(false); //not implemented
00058     }
00059 
00060 private:
00061     Vec3f mNormal;  
00062     Vec3f mOrigin;  
00063 
00067     void calcBounds()
00068     {
00069         // a bounding box for an infinite plane
00070         // does not make any sense. However, since we could
00071         // still use this class, we have to decide what to return here.
00072         // This should be a plausible decision. I would suggest to
00073         // return box of 0 dimension.
00074         mBounds.extend(Vec3f(0, 0, 0)); // FIXME this solution looks stupid
00075 
00076         // any plausible solution is correct, since we will not
00077         // use this class in the future
00078     }
00079 
00080 };
00081 
00082 #endif
00083 

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