-
Notifications
You must be signed in to change notification settings - Fork 0
/
SceneObject.h
90 lines (81 loc) · 2.98 KB
/
SceneObject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include "Ray.h"
#include "simpleshape.h"
#include "Scene.h"
#include "RandGenerator.h"
#include "CosineSphericalSampler.h"
#include "NoSelfIntersectionCondition.h"
#include "Material.h"
#include "Texture.h"
class Ray;
class Scene;
class Material;
class CountHashGrid;
class SceneObject : public SimpleShape
{
protected:
Scene *scene;
vector<float> areaValues;
vector<Material*> materialList;
public:
CountHashGrid *countHashGrid;
float totalEnergy;
vector<float> energyDensity;
float weight;
float volumeWeight;
float totalArea;
float totalVolume;
int objectIndex;
Texture bumpTex;
SceneObject* findInsideObject(const Ray& ray) const;
bool canMerge;
virtual Ray scatter(const Ray& inRay, const bool russian = true) const;
SceneObject(){ this->scene = NULL; countHashGrid = NULL; }
SceneObject(Scene* scene)
{
bumpTex.setColor(vec3f(1, 1, 1));
this->scene = scene;
countHashGrid = NULL;
canMerge = false;
unitize();
}
SceneObject(Scene* scene, const string &fileName, bool normalize = true) : SimpleShape(fileName, normalize)
{
this->scene = scene;
}
virtual vec3f getWorldNormal(unsigned fi, const vec3f& position, bool flat = false) const;
virtual LocalFrame getAutoGenWorldLocalFrame(unsigned fi, const vec3f& position, bool flat = false) const;
virtual bool hasCosineTerm(){ return true; }
virtual bool emissive() const{ return false; }
virtual bool isVolumetric() { return false; }
virtual bool isHomogeneous() { return true; }
virtual float getG() const { return 0.f; }
virtual float getRefrCoeff() const{ return 1; }
virtual void preprocessEmissionSampler();
virtual void preprocessOtherSampler();
virtual void preprocessVolumeSampler(bool isUniformOrigin , float mergeRadius);
void normalizeEmissionWeight(float totalWeight){ weight /= totalWeight; }
void normalizeVolumeWeight(float totalWeight);
virtual Ray emit(bool isUniformOrigin , bool isUniformDir) const;
virtual Ray emitVolume(bool isUniformDir) const;
virtual float getEmissionWeight() const { return weight; }
virtual void scaleEnergyDensity(const float scale);
virtual void addEnergyDensity(const int triId , const vec3f& thr);
virtual void addEnergyDensity(const vec3f& pos , const vec3f& thr);
virtual void singleEnergyToSumEnergy();
virtual void sumEnergyToSingleEnergy();
virtual float getOriginProb(const int triId);
virtual float getOriginProb(const vec3f& pos);
virtual float getTotalEnergy() const;
virtual float getDirectionSampleProbDensity(const Ray& inRay, const Ray& outRay) const;
virtual float getOriginSampleProbDensity(const Ray& inRay, const Ray& outRay) const;
virtual float getContinueProbability(const Ray &inRay, const Ray &outRay) const;
virtual float evaluatePdfW(const Ray &inRay, const Ray &outRay) const { return 1; }
virtual vec3f getBSDF(const Ray& inRay, const Ray& outRay) const;
virtual vec3f getRadianceDecay(const Ray& inRay, const float& dist) const;
virtual ~SceneObject()
{
for(unsigned i=0; i<materialList.size(); i++)
delete materialList[i];
}
};