本文整理汇总了C++中Shape::BoundingSphere方法的典型用法代码示例。如果您正苦于以下问题:C++ Shape::BoundingSphere方法的具体用法?C++ Shape::BoundingSphere怎么用?C++ Shape::BoundingSphere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape::BoundingSphere方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
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();
}
示例2: Render
void Render(double time)
{
GLfloat bs_rad = shape.BoundingSphere().Radius()*1.2f;
auto light =
CamMatrixf::Orbiting(
shape.BoundingSphere().Center(),
shape.BoundingSphere().Radius()*10.0,
FullCircles(time / 23.0),
Degrees(35 + SineWave(time / 31.0) * 50)
);
GLfloat lgt_tgt_dist = Distance(
shape.BoundingSphere().Center(),
light.Position()
);
auto lgt_proj =
CamMatrixf::PerspectiveX(
ArcSin(bs_rad/lgt_tgt_dist)*2,
1.0f,
lgt_tgt_dist-bs_rad,
lgt_tgt_dist+bs_rad
);
auto camera =
CamMatrixf::Orbiting(
shape.BoundingSphere().Center(),
shape.BoundingSphere().Radius()*2.8,
FullCircles(time / 17.0),
Degrees(SineWave(time / 19.0) * 80)
);
GLfloat cam_tgt_dist = Distance(
shape.BoundingSphere().Center(),
camera.Position()
);
auto cam_proj =
CamMatrixf::PerspectiveX(
ArcSin(bs_rad/cam_tgt_dist)*2,
double(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);
depth_vao.Bind();
depth_prog.Use();
depth_prog.camera_matrix.Set(lgt_proj*light);
depth_prog.model_matrix.Set(model);
depth_buffer.SetupViewport();
depth_buffer.Bind();
gl.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.ClearDepth(1.0f);
gl.Clear().ColorBuffer().DepthBuffer();
gl.Enable(Capability::PolygonOffsetFill);
shape.Draw();
//
draw_vao.Bind();
draw_prog.Use();
draw_prog.camera_matrix.Set(cam_proj*camera);
draw_prog.light_matrix.Set(lgt_proj*light);
draw_prog.model_matrix.Set(model);
draw_prog.camera_position.Set(camera.Position());
draw_prog.light_position.Set(light.Position());
DefaultFramebuffer::Bind(Framebuffer::Target::Draw);
gl.Viewport(width, height);
gl.ClearColor(0.2f, 0.2f, 0.2f, 0.0f);
gl.ClearDepth(1.0f);
gl.Clear().ColorBuffer().DepthBuffer();
gl.Disable(Capability::PolygonOffsetFill);
shape.Draw();
}