void Render(double time) { gl.Clear().ColorBuffer().DepthBuffer(); auto camera = CamMatrixf::Orbiting( Vec3f(), field.Radius()*(1.4 + SineWave(time / 6.0) * 0.2), FullCircles(time * 0.1), Degrees(SineWave(time / 30.0) * 90) ); auto light = CamMatrixf::Orbiting( Vec3f(), field.Radius()*1.6, FullCircles(0.33-time * 0.07), Degrees(SineWave(time / 31.0) * 80) ); prog.camera_matrix.Set(camera); prog.light_position.Set(light.Position()); GLfloat fade_coef = 1.1*(1.0-CosineWave01(time / 90.0)); prog.fade_coef.Set(fade_coef); field.Draw(); }
void Render(double time) { GLfloat bs_rad = shape.BoundingSphere().Radius()*1.2f; auto light = CamMatrixf::Orbiting( shape.BoundingSphere().Center(), shape.BoundingSphere().Radius()*10.0f, FullCircles(time / 23.0), Degrees(-CosineWave(time / 31.0) * 80) ); auto camera = CamMatrixf::Orbiting( shape.BoundingSphere().Center(), shape.BoundingSphere().Radius()* GLfloat(3.2+SineWave(time / 23.0)*0.8), FullCircles(time / 19.0), Degrees(SineWave(time / 21.0) * 80) ); GLfloat cam_tgt_dist = Distance( shape.BoundingSphere().Center(), camera.Position() ); auto cam_proj = CamMatrixf::PerspectiveX( Degrees(45), width, height, cam_tgt_dist-bs_rad, cam_tgt_dist+bs_rad ); auto model = ModelMatrixf::RotationZ(Degrees(SineWave(time / 21.0)*25))* ModelMatrixf::Translation(0.0f,-bs_rad*0.25f, 0.0f); data_prog.Use(); data_prog.camera_matrix.Set(cam_proj*camera); data_prog.model_matrix.Set(model); data_prog.camera_position.Set(camera.Position()); data_prog.light_position.Set(light.Position()); data_buffer.Bind(); gl.Enable(Capability::DepthTest); gl.Clear().ColorBuffer().DepthBuffer(); shape.Use(); shape.Draw(); draw_prog.Use(); draw_prog.slider.Set(GLfloat(CosineWave01(time / 11.0)*width)); DefaultFramebuffer().Bind(Framebuffer::Target::Draw); gl.Disable(Capability::DepthTest); gl.Clear().ColorBuffer(); screen.Use(); screen.Draw(); }