1 | #pragma once
|
---|
2 | #include "Transformation.hpp"
|
---|
3 | #include "TriangleMesh.h"
|
---|
4 |
|
---|
5 | struct D3DXMATRIX;
|
---|
6 |
|
---|
7 | class Transformed : public Intersectable
|
---|
8 | {
|
---|
9 | Transformation modelToWorld;
|
---|
10 | Transformation worldToModel;
|
---|
11 | Intersectable* object;
|
---|
12 | public:
|
---|
13 | Transformed(std::istream& isc, Material** materialTable, int nMaterials)
|
---|
14 | {
|
---|
15 | worldToModel = Transformation(isc);
|
---|
16 | char key[200];
|
---|
17 | isc >> key;
|
---|
18 | /* if(strcmp(key, "Sphere") == 0)
|
---|
19 | object = new Sphere(isc, materialTable, nMaterials);
|
---|
20 | else if(strcmp(key, "PlaneXAligned") == 0)
|
---|
21 | object = new PlaneXAligned(isc, materialTable, nMaterials);
|
---|
22 | else if(strcmp(key, "PlaneYAligned") == 0)
|
---|
23 | object = new PlaneYAligned(isc, materialTable, nMaterials);
|
---|
24 | else if(strcmp(key, "PlaneZAligned") == 0)
|
---|
25 | object = new PlaneZAligned(isc, materialTable, nMaterials);
|
---|
26 | else*/ if(strcmp(key, "TriangleMesh") == 0)
|
---|
27 | object = new TriangleMesh(isc, materialTable, nMaterials);
|
---|
28 | modelToWorld.setInvert(worldToModel);
|
---|
29 | object->getTransformedBoundingBox(modelToWorld, bbox);
|
---|
30 | material = object->getMaterial();
|
---|
31 | }
|
---|
32 | Transformed(Intersectable* object)
|
---|
33 | {
|
---|
34 | this->object = object;
|
---|
35 | bbox = object->bbox;
|
---|
36 | material = object->getMaterial();
|
---|
37 | }
|
---|
38 | void translate(Vector translation);
|
---|
39 | void rotateX(float angle);
|
---|
40 | void rotateY(float angle);
|
---|
41 | void rotateZ(float angle);
|
---|
42 | void scale(float factor);
|
---|
43 | bool intersect(const Ray& ray, float& depth, float rayMin, float rayMax);
|
---|
44 | bool intersectBackSide(const Ray& ray, float& depth, float rayMin, float rayMax);
|
---|
45 | void getOccluder(int index, Occluder& occ);
|
---|
46 |
|
---|
47 | void setTransforms(D3DXMATRIX& mw, D3DXMATRIX& itmw);
|
---|
48 | float getSurfaceArea();
|
---|
49 | void sampleSurface(Radion& radion);
|
---|
50 | };
|
---|