Commit 185a4b4f authored by Laurent Belcour's avatar Laurent Belcour
Browse files

Adding export of values in a BRDF form

parent 7b2f7264
......@@ -17,9 +17,12 @@ class data
virtual void load(const std::string& filename, const arguments& args) = 0 ;
// Acces to data
// virtual bool get(int i, double& x, double& y, double& t) const = 0 ;
virtual vec get(int i) const = 0 ;
virtual vec operator[](int i) const = 0 ;
virtual vec value(vec in, vec out) const
{
return vec(_nY) ;
}
// Get data size, e.g. the number of samples to fit
virtual int size() const = 0 ;
......
......@@ -280,6 +280,23 @@ vec data_merl::operator[](int i) const
{
return get(i) ;
}
vec data_merl::value(vec in, vec out) const
{
// compute thetain fi_in, theta_out fi_out
double th_in = acos(in[2]);
double fi_in = atan2(in[1], in[0]);
double th_out = acos(out[2]);
double fi_out = atan2(out[1], out[0]);
double r, g, b;
lookup_brdf_val(brdf, th_in, fi_in, th_out, fi_out, r, g, b) ;
vec res(3);
res[0] = r;
res[1] = g;
res[2] = b;
return res;
}
// Get data size, e.g. the number of samples to fit
int data_merl::size() const
......
......@@ -20,6 +20,7 @@ class data_merl : public QObject, public data
// Acces to data
virtual vec get(int i) const ;
virtual vec operator[](int i) const ;
virtual vec value(vec in, vec out) const ;
// Get data size, e.g. the number of samples to fit
virtual int size() const ;
......
......@@ -12,6 +12,7 @@
#include <fstream>
#include <limits>
#include <cstdlib>
#include <cmath>
int main(int argc, char** argv)
{
......@@ -45,15 +46,27 @@ int main(int argc, char** argv)
if(d != NULL)
{
std::cout << "<<INFO>> will export " << d->size() << " elements" << std::endl ;
for(int i=0; i<d->size(); ++i)
{
vec v = d->get(i) ;
vec in(3), out(3) ;
in[0] = 0.0;
in[1] = 0.0;
in[2] = 1.0;
for(int i=0; i<90; ++i)
for(int j=0; j<90; ++j)
{
double phi = i * M_PI / 89 ;
double theta = j * M_PI / 89 * 0.5 ;
out[0] = cos(phi)*sin(theta);
out[1] = sin(phi)*sin(theta);
out[2] = cos(theta);
vec v = d->value(in, out) ;
for(int u=0; u<d->dimX()+d->dimY(); ++u)
file << v[u] << "\t" ;
file << phi << "\t" << theta << "\t" ;
for(int u=0; u<d->dimY(); ++u)
file << v[u] << "\t" ;
file << std::endl ;
}
file << std::endl ;
}
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment