00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef OBJECT3D_H
00022
#define OBJECT3D_H
00023
00024
#include "transparenttransformatable.h"
00025
#include "surfacepatch3d.h"
00026
#include "boundingbox.h"
00027
#include "objectconstructionerror.h"
00028
00029
class PatchObject;
00030
class InsideList;
00031
00032
class Material3D;
00033
class Texture3D;
00034
class Pigment3D;
00035
class Finish;
00036
class Interior;
00037
class Media3D;
00038
00045 class Object3D:
public SurfacePatch3D,
public TransparentTransformatable {
00046
00047
public:
00050 Material3D*
material;
00051
00052
public:
00053
00057 Object3D():
material(0),
boundingbox(0),
inverse(false) {};
00058
00063 Object3D(
Vector3 location):
TransparentTransformatable(location),
00064
material(0),
boundingbox(0),
inverse(false) {};
00065
00066
virtual ~
Object3D();
00067
00068
protected:
00071
Object3D(
const Object3D &o);
00072
00073
private:
00076
Object3D& operator=(
const Object3D&);
00077
00078
public:
00079
00080
00081
00082
00083
00084
virtual void translate(
const Vector3& v);
00085
virtual void scale(
const Vector3& v);
00086
virtual void rotateDeg(
const Vector3& v);
00087
virtual void rotateRad(
const Vector3& v);
00088
virtual void applyOrthogonalMatrix(
const Matrix& m);
00089
virtual void applyMatrix(
const Matrix& m);
00090
00091
virtual void transform(
const TransparentTransformatable& t);
00092
virtual void transformInverse(
const TransparentTransformatable& t);
00093
00094
00095
00096 virtual bool hasFinitBounding()
const {
return boundingbox != 0;}
00097
00098 virtual Vector3 getBoundingMin()
const {
00099
if (
boundingbox == 0)
throw ObjectConstructionError(
"Object3D::getBoundingMin(): no bounding");
00100
return boundingbox->
getBoxMin();
00101 }
00102
00103 virtual Vector3 getBoundingMax()
const {
00104
if (
boundingbox == 0)
throw ObjectConstructionError(
"Object3D::getBoundingMin(): no bounding");
00105
return boundingbox->
getBoxMax();
00106 }
00107
00108
virtual DBL
intersectBounding(
const Ray &r)
const;
00109
virtual DBL
intersectBounding(
const Ray &r, DBL tmax)
const;
00110
00111 virtual Intersection*
intersect(
const Ray &r)
const {
00112
Ray local = r;
00113
transformRayIn(local);
00114
return intersectLocal(local);
00115 }
00116
00117 virtual Intersection*
intersectLimitedTime(
const Ray &r, DBL maxtime)
const {
00118
Ray local = r;
00119
transformRayIn(local);
00120
return intersectLocalLimitedTime(local,maxtime);
00121 }
00122
00123
00124
00125
00129
void setMaterial(
const Material3D &m);
00130
00134
void setTexture(
const Texture3D &t);
00135
00139
void setPigment(
const Pigment3D &p);
00140
00144
void setFinish(
const Finish &f);
00145
00149
void setInterior(
const Interior &i);
00150
00154
void setMedia(
const Media3D &m);
00155
00159 virtual Object3D*
invert()
const {
00160
Object3D* inv = static_cast<Object3D*>(
duplicate());
00161
if (
inverse) inv->
inverse=
false;
else inv->
inverse=
true;
00162
return inv;
00163 }
00164
00169 virtual PatchObject*
toPatch(
double precision)
const {
return 0;}
00170
00176
virtual void listInside(
const Vector3& location,
InsideList& l)
const;
00177
00182 bool isInsideAtBounded(
Vector3 location)
const {
00183
if (
boundingbox && !
boundingbox->
isInsideAt(location))
return inverse;
00184
transformPointIn(location);
00185
return isInsideAt(location);
00186 }
00187
00191 bool isInverse()
const {
return inverse;}
00192
00193
protected:
00194
00195
virtual Intersection* intersectLocal(
const Ray& r)
const {
00196
return intersectLocalLimitedTime(r,INTERSECTION_INFINIT_TIME);
00197 }
00198
00199
virtual Intersection* intersectLocalLimitedTime(
const Ray& r, DBL maxtime)
const = 0;
00200
00201
00206
virtual bool isInsideAt(
const Vector3 &locallocation)
const = 0;
00207
00208
00209
protected:
00212 BoundingBox*
boundingbox;
00213
00216 bool inverse;
00217
00218 };
00219
00220
#endif