64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#ifndef MATERIALOPTIONS_H
|
|
#define MATERIALOPTIONS_H
|
|
|
|
#include "../../../floorplan/v2/Floorplan.h"
|
|
#include "../../../Assertions.h"
|
|
|
|
/** raytracing attributes for one material */
|
|
struct MaterialAttributes {
|
|
|
|
struct Shadowing {
|
|
float attenuation;
|
|
Shadowing() : attenuation(NAN) {;}
|
|
Shadowing(float attenuation) : attenuation(attenuation) {;}
|
|
} shadowing;
|
|
|
|
struct Reflection {
|
|
float attenuation;
|
|
Reflection() : attenuation(NAN) {;}
|
|
Reflection(float attenuation) : attenuation(attenuation) {;}
|
|
} reflection;
|
|
|
|
MaterialAttributes(float shadowA, float reflectA) : shadowing(shadowA), reflection(reflectA) {;}
|
|
|
|
MaterialAttributes() {;}
|
|
|
|
};
|
|
|
|
class Materials {
|
|
|
|
public:
|
|
|
|
/** singleton access */
|
|
static Materials& get() {
|
|
static Materials instance;
|
|
return instance;
|
|
}
|
|
|
|
/** get the attributes for the given material */
|
|
inline const MaterialAttributes& getAttributes(const Floorplan::Material mat) const {
|
|
const int idx = (const int) mat;
|
|
Assert::isBetween(idx, 0, (int)materials.size()-1, "material index out of bounds");
|
|
return materials[idx];
|
|
}
|
|
|
|
private:
|
|
|
|
std::vector<MaterialAttributes> materials;
|
|
|
|
/** hidden ctor */
|
|
Materials() {
|
|
|
|
materials.resize((int)Floorplan::Material::_END);
|
|
materials[(int)Floorplan::Material::CONCRETE] = MaterialAttributes(12, 5);
|
|
materials[(int)Floorplan::Material::DRYWALL] = MaterialAttributes(2, 5);
|
|
materials[(int)Floorplan::Material::GLASS] = MaterialAttributes(28, 2);
|
|
materials[(int)Floorplan::Material::UNKNOWN] = MaterialAttributes(2, 5);
|
|
materials[(int)Floorplan::Material::WOOD] = MaterialAttributes(5, 5);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif // MATERIALOPTIONS_H
|