I'm building a C++ project and I would like to create a global custom object. I have created a custom class called Material.
rt.h
template<typename T>
class Material
{
public:
Vec3<T> ka, kd, ks, kr;
T sp, transparency, reflectivity;
Material( ) {
ka = Vec3<T>(0);
kd = Vec3<T>(0.0, 0.0, 0.0);
ks = Vec3<T>(0.0, 0.0, 0.0);
sp = 0.0;
kr = Vec3<T>(0.0, 0.0, 0.0);
reflectivity = 0.0;
transparency = 0.0;
}
};
At the top of my rt.cpp file I have the following.
#include <"rt.h">
Material<float> currentMaterial();
Later I call currentMaterial and get an error
raytracer.cpp:294:3: error: base of member reference is a function; perhaps you meant to call it with no arguments?
currentMaterial.ka = Vec3<float>(kar, kag, kab);
when I call:
currentMaterial.ka = Vec3<float>(kar, kag, kab);
Thanks
Material<float> currentMaterial();
looks like a function declaration to the compiler. Declare your variable like this:
Material<float> currentMaterial;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With