00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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:
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
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:
00053
00054
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:
00065 const
Vector3& p(CNT8 i)
const {
return *edge[i];}
00066
00067
private:
00068
static HitStatistics stat;
00069
00070
private:
00071
Vector3* edge[3];
00072
00073
private:
00074
00075
class TriangleIntersection:
public Intersection {
00076
00077
public:
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:
00086 DBL t;
00087
00088 };
00089
00090
00091 };
00092
00093
#endif