00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef BOUNDINGBOX_H
00022
#define BOUNDINGBOX_H
00023
00024
#include "vector.h"
00025
#include "transformatable.h"
00026
#include "statistics.h"
00027
00028
class TransparentTransformatable;
00029
00035 class BoundingBox {
00036
00037
public:
00038
00043 BoundingBox(
Vector3 edgemin,
Vector3 edgemax): boxmin(edgemin), boxmax(edgemax) {}
00044
00045
public:
00046
00047
void translate(
const Vector3& v) {boxmin.
add(v); boxmax.
add(v);}
00048
void scale(
const Vector3& v);
00049
void rotateDeg(
const Vector3& v);
00050
void rotateRad(
const Vector3& v);
00051
void applyOrthogonalMatrix(
const Matrix &m) {applyMatrix(m);}
00052
void applyMatrix(
const Matrix &m);
00053
00054
public:
00055
00059 Vector3 getBoxMin()
const {
return boxmin;}
00060
00064 Vector3 getBoxMax()
const {
return boxmax;}
00065
00066
public:
00067
00071
void transformate(
const TransparentTransformatable &t);
00072
00078 DBL
intersect(
const Ray &r)
const;
00079
00086 DBL
intersect(
const Ray &r, DBL tmax)
const;
00087
00092
bool isInsideAt(
const Vector3& a)
const;
00093
00094
private:
00095
00098
static HitStatistics stat;
00099
00100
private:
00101
00104
Vector3 boxmin;
00107
Vector3 boxmax;
00108
00109
private:
00110
void updateBoundingBoxPoints(
Vector3& min,
Vector3& max,
const Matrix& rot,
Vector3 test);
00111
00112 };
00113
00114
#endif