+ sl.type = type;
+ sl.view_index = views.size();
+ sl.shadow_caster = &c;
+
+ views.resize(views.size()+n_views);
+ for(unsigned i=0; i<n_views; ++i)
+ {
+ ShadowView &view = views[sl.view_index+i];
+ view.light_index = lights.size()-1;
+ view.face = i;
+
+ if(type==TETRAHEDRON)
+ {
+ if(i>0)
+ view.face_matrix = Matrix().rotate(Geometry::Angle<float>::from_turns((i-0.5f)/3.0f), Vector3(0, 0, 1))
+ .rotate(Geometry::Angle<float>::straight()-Geometry::acos<float>(1.0f/3.0f), Vector3(1, 0, 0));
+
+ float triangle_h = sqrt(0.75f)*2.0f;
+ float bottom = 0.5f/sqrt(0.75f);
+ float distance = (sqrt(2.0f/3.0f)-sqrt(3.0f/8.0f))*2.0f;
+ view.camera.set_field_of_view(Geometry::atan<float>(triangle_h/distance)*2.0f);
+ view.camera.set_aspect_ratio(1.0f/triangle_h);
+ view.camera.set_frustum_axis(0.0f, 1.0f-bottom/triangle_h);
+ view.camera.set_frustum_rotation(-Geometry::Angle<float>::from_turns(i/4.0f));
+ }
+ }