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

trianglepatch.h

00001 /* ************************************************************************* 00002 trianglepatch.h - description 00003 ------------------- 00004 begin : Sun Dec 1 2002 00005 copyright : (C) 2002 by Micha Riser 00006 email : mriser@gmx.net 00007 00008 $Id: trianglepatch_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 TRIANGLEPATCH_H 00022 #define TRIANGLEPATCH_H 00023 00024 #include "surfacepatch3d.h" 00025 #include "intersection.h" 00026 #include "statistics.h" 00027 00032 class TrianglePatch: public SurfacePatch3D { 00033 00034 public: // Constructor and destructor 00035 00038 TrianglePatch(Vector3* edge1, Vector3* edge2, Vector3* edge3) { 00039 edge[0] = edge1; 00040 edge[1] = edge2; 00041 edge[2] = edge3; 00042 } 00043 00044 private: 00045 // Copy constructor 00046 TrianglePatch(const TrianglePatch& p): SurfacePatch3D(p) { 00047 for(CNT8 i = 0; i<3; ++i) edge[i] = p.edge[i]; 00048 } 00049 00050 TrianglePatch& operator=(const TrianglePatch&); 00051 00052 public: // Public methods 00053 00054 // to implement SurfacePatch3D 00055 SurfacePatch3D* duplicate() const; 00056 bool hasFinitBounding() const; 00057 Vector3 getBoundingMin() const; 00058 Vector3 getBoundingMax() const; 00059 00060 DBL intersectBounding(const Ray &r) const; 00061 DBL intersectBounding(const Ray &r, DBL tmax) const; 00062 Intersection* intersectLimitedTime(const Ray &r, DBL maxtime) const; 00063 00064 private: // Private methods 00065 const Vector3& p(CNT8 i) const {return *edge[i];} 00066 00067 private: // Static members 00068 static HitStatistics stat; 00069 00070 private: // Private members 00071 Vector3* edge[3]; 00072 00073 private: // inner classes 00074 00075 class TriangleIntersection: public Intersection { 00076 00077 public: // Constructor and destructor 00078 TriangleIntersection(const SurfacePatch3D* o, const Ray& r, DBL time): Intersection(o,r), t(time) {} 00079 00080 public: 00081 void next() {t = INTERSECTION_INFINIT_TIME;} 00082 DBL currentTime() {return t;} 00083 Vector3 normal(); 00084 00085 private: // Private attributes 00086 DBL t; 00087 00088 }; 00089 00090 00091 }; 00092 00093 #endif

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