Beispiel #1
0
void Scene::load_media(const string& filename)
{
  Medium air;
  air.get_ior(mono).resize(1);
  air.get_ior(mono)[0] = complex<double>(1.0, 0.0);
  air.fill_rgb_data();
  air.name = "default";
  set_medium(air);

  for(unsigned int i = 0; i < planes.size(); ++i)
    meshes.push_back(planes[i]->get_mesh());
  load_mpml(filename, media, interfaces);
  for(unsigned int i = 0; i < meshes.size(); ++i)
    for(unsigned int j = 0; j < meshes[i]->materials.size(); ++j)
    {
      const ObjMaterial& mat = meshes[i]->materials[j];
      string name = mat.name;
      Interface& iface = interfaces[name];
      if(!iface.med_in)
      {
        iface.name = name;
        iface.med_in = &media[name];
        iface.med_in->name = name;
        Color< complex<double> >& ior = iface.med_in->get_ior(mono);
        ior.resize(1);
        ior[0] = complex<double>(mat.ior, 0.0);
        float emissive = 0.0f;
        for(unsigned int k = 0; k < 3; ++k)
          emissive += mat.ambient[k];
        if(emissive > 0.0)
        {
          iface.med_in->emissive = true;
          Color<double>& emission = iface.med_in->get_emission(rgb);
          emission.resize(3);
          for(unsigned int k = 0; k < emission.size(); ++k)
            emission[k] = mat.ambient[k];
        }
      }
      iface.med_in->fill_rgb_data();
      iface.med_in->fill_mono_data();
      if(iface.med_out)
      {
        iface.med_out->fill_rgb_data();
        iface.med_out->fill_mono_data();
      }
      if(mat.has_texture)
      {
        Texture*& tex = textures[mat.tex_name];
        tex = new Texture;
        string path_and_name = mat.tex_path + mat.tex_name;
        tex->load(path_and_name.c_str());
      }
    }
  for(unsigned int i = 0; i < planes.size(); ++i)
    meshes.pop_back();
}
Beispiel #2
0
Medium water(double T, double S)
{
  static const double M_4PI = 4.0*M_PI;

  Medium m;
  Color< complex<double> >& ior = m.get_ior(spectrum);
  ior.resize(no_of_samples);
  ior.wavelength = first_wavelength;
  ior.step_size = wavelength_step_size;

  for(unsigned int i = 0; i < ior.size(); ++i)
  {
    double lambda = ior.wavelength + i*ior.step_size;
    double Psi_T = TS_correction[i][0];
    double Psi_S = TS_correction[i][1];
    double ior_imag = ior_imag_part[i] + lambda*((T - 22)*Psi_T + S*Psi_S)/M_4PI;
    ior[i] = complex<double>(water_ior_real_part(lambda, T, S), ior_imag);
  }

  m.name = "water";
  return m;  
}