00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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:
00034
00037 Box(
const Vector3& min,
const Vector3& max): boxmin(min), boxmax(max) {}
00038
00039
public:
00040
00041
00042
bool hasFinitBounding() const;
00043
Vector3 getBoundingMin() const;
00044
Vector3 getBoundingMax() const;
00045
00046
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
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:
00058
enum boxside {X,Y,Z,NONE};
00059
00060
private:
00063
static HitStatistics stat;
00064
00065
private:
00066
Vector3 boxmin;
00067
Vector3 boxmax;
00068
00069
private:
00070
void calculateBoundingBox();
00071
00072
private:
00073
00076
class BoxIntersection:
public Intersection {
00077
public:
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:
00083
00084 DBL currentTime() {
return currenttime;}
00085
void next();
00086
Vector3 normal();
00087
00088
private:
00089 DBL currenttime, secondtime;
00090 boxside currentside, secondside;
00091
00092 };
00093
00094 };
00095
00096
#endif