height(h),
pipeline(w, h),
sky(layout.get_catalogue()),
- shadow(4096, layout.get_scene(), layout.get_sun()),
- ambient_occlusion(w, h, 100)
+ shadow(4096, layout.get_scene(), layout.get_sun())
{
pipeline.set_hdr(true);
pipeline.set_camera(&camera);
pipeline.add_renderable_for_pass(layout.get_scene(), "translucent");
GL::Pipeline::Pass *pass = &pipeline.add_pass("sky");
+ pass->set_lighting(&layout.get_lighting());
pass = &pipeline.add_pass(0);
pass->set_lighting(&layout.get_lighting());
pass->set_depth_test(&GL::DepthTest::lequal());
pass->set_blend(&GL::Blend::alpha());
- pipeline.add_postprocessor(ambient_occlusion);
- colorcurve.set_srgb();
- pipeline.add_postprocessor(colorcurve);
+ try
+ {
+ ambient_occlusion = new GL::AmbientOcclusion(w, h, 100);
+ pipeline.add_postprocessor(*ambient_occlusion);
+ }
+ catch(...)
+ {
+ delete ambient_occlusion;
+ ambient_occlusion = 0;
+ }
+
+ try
+ {
+ colorcurve = new GL::ColorCurve;
+ colorcurve->set_srgb();
+ pipeline.add_postprocessor(*colorcurve);
+ }
+ catch(...)
+ {
+ delete colorcurve;
+ colorcurve = 0;
+ }
update_shadow_area();
layout.get_layout().signal_object_added.connect(sigc::hide(sigc::mem_fun(this, &View3D::update_shadow_area)));
view_all();
}
+View3D::~View3D()
+{
+ delete colorcurve;
+ delete ambient_occlusion;
+}
+
Ray View3D::create_ray(int x, int y) const
{
return create_ray(x*2.0f/width-1.0f, y*2.0f/height-1.0f);
{
const GL::Vector3 &start = camera.get_position();
GL::Vector4 ray = camera.unproject(GL::Vector4(x, y, 0, 0));
- return Ray(start, Vector(ray));
+ return Ray(start, ray.slice<3>(0));
}
void View3D::compute_bounds(Vector &minp, Vector &maxp)
{
Vector minp, maxp;
compute_bounds(minp, maxp);
- shadow.set_target((minp+maxp)/2.0f, (maxp-minp).norm()/2.0f);
+ shadow.set_target((minp+maxp)/2.0f, max((maxp-minp).norm()/2.0f, 0.1f));
}
} // namespace R2C2