Main Page | Class Hierarchy | Class List | File List | Class Members

box.h

00001 /* ************************************************************************* 00002 box.h - description 00003 ------------------- 00004 begin : Wed Oct 16 2002 00005 copyright : (C) 2002 by Micha Riser 00006 email : mriser@gmx.net 00007 00008 $Id: box_8h-source.html,v 1.1 2005/02/04 21:02:27 micha Exp $ 00009 00010 ************************************************************************* */ 00011 00012 /* ************************************************************************* 00013 * * 00014 * This program is free software; you can redistribute it and/or modify * 00015 * it under the terms of the GNU General Public License as published by * 00016 * the Free Software Foundation; either version 2 of the License, or * 00017 * (at your option) any later version. * 00018 * * 00019 ************************************************************************* */ 00020 00021 #ifndef BOX_H 00022 #define BOX_H 00023 00024 #include "object3d.h" 00025 #include "intersection.h" 00026 00031 class Box: public Object3D { 00032 00033 public: // Constructor and destructor 00034 00037 Box(const Vector3& min, const Vector3& max): boxmin(min), boxmax(max) {} 00038 00039 public: // Public methods 00040 00041 // overwrite in SurfacePatch3D 00042 bool hasFinitBounding() const; 00043 Vector3 getBoundingMin() const; 00044 Vector3 getBoundingMax() const; 00045 00046 // overwrite in Object3D 00047 void rotateRad(const Vector3& v); 00048 void rotateDeg(const Vector3& v); 00049 void scale(const Vector3& v); 00050 void translate(const Vector3& v); 00051 00052 // to implement Object3D 00053 Object3D* duplicate() const {return new Box(*this);} 00054 Intersection* intersectLocalLimitedTime(const Ray &r, DBL maxtime) const; 00055 bool isInsideAt(const Vector3 &locallocation) const; 00056 00057 private: // Private type definitions 00058 enum boxside {X,Y,Z,NONE}; 00059 00060 private: // Static members 00063 static HitStatistics stat; 00064 00065 private: // Private attributes 00066 Vector3 boxmin; 00067 Vector3 boxmax; 00068 00069 private: // Private methods 00070 void calculateBoundingBox(); 00071 00072 private: // Private inner classes 00073 00076 class BoxIntersection: public Intersection { 00077 public: // Constructor and destructor 00078 BoxIntersection(const Object3D* o, const Ray& r, DBL t1, DBL t2, 00079 boxside s1, boxside s2): Intersection(o, r), currenttime(t1), 00080 secondtime(t2), currentside(s1), secondside(s2) {} 00081 00082 public: // Public methods 00083 // inherited from Intersection 00084 DBL currentTime() {return currenttime;} 00085 void next(); 00086 Vector3 normal(); 00087 00088 private: // Private attributes 00089 DBL currenttime, secondtime; 00090 boxside currentside, secondside; 00091 00092 }; 00093 00094 }; 00095 00096 #endif

Generated on Thu Jan 27 12:16:05 2005 for raytracer.kdevelop by doxygen 1.3.8