本文整理汇总了C++中Body::Render方法的典型用法代码示例。如果您正苦于以下问题:C++ Body::Render方法的具体用法?C++ Body::Render怎么用?C++ Body::Render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Body
的用法示例。
在下文中一共展示了Body::Render方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void ObjectViewerView::Draw3D()
{
m_renderer->ClearScreen();
float znear, zfar;
m_renderer->GetNearFarRange(znear, zfar);
m_renderer->SetPerspectiveProjection(75.f, Pi::GetScrAspect(), znear, zfar);
m_renderer->SetTransform(matrix4x4f::Identity());
Graphics::Light light;
light.SetType(Graphics::Light::LIGHT_DIRECTIONAL);
if (Pi::MouseButtonState(SDL_BUTTON_RIGHT)) {
int m[2];
Pi::GetMouseMotion(m);
m_camRot = matrix4x4d::RotateXMatrix(-0.002*m[1]) *
matrix4x4d::RotateYMatrix(-0.002*m[0]) * m_camRot;
}
Body *body = Pi::player->GetNavTarget();
if (body) {
if (body->IsType(Object::STAR))
light.SetPosition(vector3f(0.f));
else {
light.SetPosition(vector3f(0.577f));
}
m_renderer->SetLights(1, &light);
body->Render(m_renderer, 0, vector3d(0,0,-viewingDist), m_camRot);
}
}
示例2:
void ObjectViewerView::Draw3D()
{
static float rot;
rot += 0.1;
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float znear, zfar;
Pi::worldView->GetNearFarClipPlane(&znear, &zfar);
float fracH = znear / Pi::GetScrAspect();
glFrustum(-znear, znear, -fracH, fracH, znear, zfar);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_LIGHT0);
Render::State::SetZnearZfar(znear, zfar);
if (Pi::MouseButtonState(SDL_BUTTON_RIGHT)) {
int m[2];
Pi::GetMouseMotion(m);
m_camRot = matrix4x4d::RotateXMatrix(-0.002*m[1]) *
matrix4x4d::RotateYMatrix(-0.002*m[0]) * m_camRot;
}
float lightPos[4] = { .577, .577, .577, 0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
Body *body = Pi::player->GetNavTarget();
if (body) {
body->Render(vector3d(0,0,-viewingDist), m_camRot);
}
}
示例3:
void ObjectViewerView::Draw3D()
{
PROFILE_SCOPED()
m_renderer->ClearScreen();
float znear, zfar;
m_renderer->GetNearFarRange(znear, zfar);
m_renderer->SetPerspectiveProjection(75.f, m_renderer->GetDisplayAspect(), znear, zfar);
m_renderer->SetTransform(matrix4x4f::Identity());
Graphics::Light light;
light.SetType(Graphics::Light::LIGHT_DIRECTIONAL);
const int btnState = Pi::MouseButtonState(SDL_BUTTON_RIGHT);
if (btnState) {
int m[2];
Pi::GetMouseMotion(m);
m_camRot = matrix4x4d::RotateXMatrix(-0.002*m[1]) *
matrix4x4d::RotateYMatrix(-0.002*m[0]) * m_camRot;
m_cameraContext->SetPosition(Pi::player->GetInterpPosition() + vector3d(0, 0, viewingDist));
m_cameraContext->BeginFrame();
m_camera->Update();
}
Body *body = Pi::player->GetNavTarget();
if (body) {
if (body->IsType(Object::STAR))
light.SetPosition(vector3f(0.f));
else {
light.SetPosition(vector3f(0.577f));
}
m_renderer->SetLights(1, &light);
body->Render(m_renderer, m_camera.get(), vector3d(0,0,-viewingDist), m_camRot);
}
UIView::Draw3D();
if (btnState) {
m_cameraContext->EndFrame();
}
}