本文整理匯總了C++中GetAspectRatio函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetAspectRatio函數的具體用法?C++ GetAspectRatio怎麽用?C++ GetAspectRatio使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetAspectRatio函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: glClearColor
void VimridViewer::Render()
{
this->GlutApplication::Render();
// Use dark gray which is good for stereo.
glClearColor(0.2, 0.2, 0.2, 1.0);
if (IsStereoEnabled())
{
RenderStereoBuffer(GL_BACK_LEFT);
RenderStereoBuffer(GL_BACK_RIGHT);
}
else
{
glDrawBuffer(GL_BACK);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set a normal frustum for non-stereo viewers.
glFrustum(
-1.0, 1.0,
-GetAspectRatio(),
GetAspectRatio(),
GetFrustumNearClip(),
GetFrustumFarClip());
RenderDelegate();
}
FinishRender();
}
示例2: Window3
GeometryShadersWindow::GeometryShadersWindow(Parameters& parameters)
:
Window3(parameters)
{
if (!SetEnvironment() || !CreateScene())
{
parameters.created = false;
return;
}
mEngine->SetClearColor({ 1.0f, 1.0f, 1.0f, 1.0f });
InitializeCamera();
mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f);
Vector4<float> camPosition{ 2.8f, 0.0f, 0.0f, 1.0f };
Vector4<float> camDVector{ -1.0f, 0.0f, 0.0f, 0.0f };
Vector4<float> camUVector{ 0.0f, 0.0f, 1.0f, 0.0f };
Vector4<float> camRVector = Cross(camDVector, camUVector);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
#if defined(SAVE_RENDERING_TO_DISK)
mTarget = std::make_shared<DrawTarget>(1, DF_R8G8B8A8_UNORM, mXSize,
mYSize);
mTarget->GetRTTexture(0)->SetCopyType(Resource::COPY_STAGING_TO_CPU);
#endif
}
示例3: CreateScene
//----------------------------------------------------------------------------
bool GelatinCube::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
CreateScene();
// Center-and-fit for camera viewing.
mScene->Update();
mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f);
AVector camDVector(0.0f, 1.0f, 0.0f);
AVector camUVector(0.0f, 0.0f, 1.0f);
AVector camRVector = camDVector.Cross(camUVector);
APoint camPosition = APoint::ORIGIN -
2.0f*mScene->WorldBound.GetRadius()*camDVector;
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
// Initial update of objects.
mScene->Update();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
// Sort the box faces based on current camera parameters.
mBox->SortFaces(mCamera->GetDVector());
InitializeCameraMotion(0.01f, 0.001f);
InitializeObjectMotion(mScene);
return true;
}
示例4: XMMatrixPerspectiveFovLH
void WavesApp::OnResize()
{
D3DApp::OnResize();
// The window resized, so update the aspect ratio and recompute the projection matrix.
XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::PI/* 90度視角 */, GetAspectRatio(), 1.0f, 1000.0f);
XMStoreFloat4x4(&m_projMaxtrix, P);
}
示例5: GetAspectRatio
//----------------------------------------------------------------------------
bool Terrains::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the camera. Position the camera in the middle of page[0][0].
// Orient it to look diagonally across the terrain pages.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1500.0f);
APoint camPosition(64.0f, 64.0f, mHeightAboveTerrain);
AVector camDVector(Mathf::INV_SQRT_2, Mathf::INV_SQRT_2, 0.0f);
AVector camUVector(0.0f, 0.0f, 1.0f);
AVector camRVector = camDVector.Cross(camUVector);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
CreateScene();
// Initial update of objects.
mScene->Update();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(1.0f, 0.01f);
MoveForward();
return true;
}
示例6: GetAspectRatio
//----------------------------------------------------------------------------
bool NonuniformScale::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the camera.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 100.0f);
float cs = 0.866025f, sn = 0.5f;
APoint camPosition(0.0f, -4.0f, 2.0f);
AVector camDVector(0.0f, cs, -sn);
AVector camUVector(0.0f, sn, cs);
AVector camRVector = camDVector.Cross(camUVector);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
CreateScene();
// Initial update of objects.
mScene->Update();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.01f, 0.001f);
InitializeObjectMotion(mScene);
return true;
}
示例7: GetAspectRatio
void TopicApp::OnResize()
{
DXApp::OnResize();
// The window resized, so update the aspect ratio and recompute the projection matrix.
m_cam.setLens(0.25f*MathHelper::Pi, GetAspectRatio(), 1.0f, 1000.0f);
}
示例8: GetAspectRatio
//----------------------------------------------------------------------------
bool ReflectionsAndShadows::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the camera.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
APoint camPosition(180.0f, 0.0f, 23.0f);
AVector camDVector(-1.0f, 0.0f, 0.0f);
AVector camUVector(0.0f, 0.0f, 1.0f);
AVector camRVector = camDVector.Cross(camUVector);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
CreateScene ();
// Initial update of objects.
mScene->Update();
mBiped->Update(mUpdateTime);
// Initial culling of scene,
mSceneCuller.SetCamera(mCamera);
mSceneCuller.ComputeVisibleSet(mScene);
mBipedCuller.SetCamera(mCamera);
mBipedCuller.ComputeVisibleSet(mBiped);
InitializeCameraMotion(0.1f, 0.01f);
InitializeObjectMotion(mScene);
return true;
}
示例9: CreateScene
//----------------------------------------------------------------------------
bool BlendedAnimations::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
CreateScene();
// Center-and-fit for camera viewing.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
APoint camPosition(-60.0f, -60.0f, 90.0f);
AVector camDVector(1.0f, 1.0f, -1.0f);
camDVector.Normalize();
AVector camUVector(0.5f, 0.5f, 1.0f);
camUVector.Normalize();
AVector camRVector = camDVector.Cross(camUVector);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
// Initial update of objects.
mScene->Update(mAnimTime);
InitializeCameraMotion(0.01f, 0.01f);
InitializeObjectMotion(mScene);
return true;
}
示例10: CreateScene
//----------------------------------------------------------------------------
bool SphereMaps::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
CreateScene();
// Center-and-fit for camera viewing.
mScene->Update();
mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
AVector camDVector(0.0f, 1.0f, 0.0f);
AVector camUVector(0.0f, 0.0f, 1.0f);
AVector camRVector = camDVector.Cross(camUVector);
APoint camPosition = APoint::ORIGIN -
3.0f*mScene->WorldBound.GetRadius()*camDVector;
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
// Initial update of objects.
mScene->Update();
CopyNormalToTCoord1(mScene);
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.001f, 0.001f);
InitializeObjectMotion(mScene);
return true;
}
示例11: CreateScene
//----------------------------------------------------------------------------
bool FreeFormDeformation::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the scene graph.
CreateScene();
// Center-and-fit mesh for viewing by camera
mMesh->Update();
mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f);
AVector camDVector(0.0f, 0.0f, 1.0f);
AVector camUVector(0.0f, 1.0f, 0.0f);
AVector camRVector = camDVector.Cross(camUVector);
APoint camPosition = APoint::ORIGIN -
2.5f*mScene->WorldBound.GetRadius()*camDVector;
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
// Initial update of objects.
mScene->Update();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.01f, 0.02f);
InitializeObjectMotion(mScene);
return true;
}
示例12: CreateScene
//----------------------------------------------------------------------------
bool WaterDropFormation::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
CreateScene();
// Center-and-fit for camera viewing.
mScene->Update();
mTrnNode->LocalTransform.SetTranslate(-mScene->WorldBound.GetCenter());
mCamera->SetFrustum(60.0f, GetAspectRatio(), 0.1f, 1000.0f);
float angle = 0.01f*Mathf::PI;
float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle);
AVector camDVector(-cs, 0.0f, -sn);
AVector camUVector(sn, 0.0f, -cs);
AVector camRVector = camDVector.Cross(camUVector);
APoint camPosition = APoint::ORIGIN -
0.9f*mScene->WorldBound.GetRadius()*camDVector;
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
// Initial update of objects.
mScene->Update();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.01f, 0.001f);
InitializeObjectMotion(mScene);
mLastSeconds = (float)GetTimeInSeconds();
return true;
}
示例13: GetAspectRatio
//----------------------------------------------------------------------------
bool BouncingSpheres::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the camera.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 1000.0f);
float angle = 0.02f*Mathf::PI;
float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle);
APoint camPosition(27.5f, 8.0f, 8.9f);
AVector camDVector(-cs, 0.0f, -sn);
AVector camUVector(-sn, 0.0f, cs);
AVector camRVector = camDVector.Cross(camUVector);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
CreateScene();
// Initial update of objects.
mScene->Update();
// Initialize balls with correct transformations.
PhysicsTick();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
return true;
}
示例14: GetAspectRatio
//----------------------------------------------------------------------------
bool RoughPlaneSolidBox::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the camera.
mCamera->SetFrustum(60.0f, GetAspectRatio(), 1.0f, 100.0f);
float angle = 0.1f*Mathf::PI;
float cs = Mathf::Cos(angle), sn = Mathf::Sin(angle);
APoint camPosition(17.695415f, 0.0f, 6.4494629f);
AVector camDVector(-cs, 0.0f, -sn);
AVector camUVector(-sn, 0.0f, cs);
AVector camRVector = camDVector.Cross(camUVector);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
InitializeModule();
CreateScene();
// Initial update of objects.
mScene->Update();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.001f, 0.001f);
InitializeObjectMotion(mScene);
return true;
}
示例15: pos
bool Camera::ObjectFrustumCulling( const RenderObject& obj )
{
const AABB& aabb = obj.m_worldAABB;
//物體坐標轉換到相機空間進行裁減
VEC4 pos(aabb.GetCenter(), 1.0f);
Common::Transform_Vec4_By_Mat44(pos, pos, GetViewMatrix());
float n = GetNearClip();
float f = GetFarClip();
float fov = GetFov();
float half_w = n * std::tan(fov/2);
float half_h = half_w / GetAspectRatio();
//檢測前後麵
if(-pos.z+aabb.m_boundingRadius <= n || -pos.z-aabb.m_boundingRadius >= f)
return true;
//檢測左右麵
float planeX = half_w * pos.z / -n;
if(pos.x - planeX >= aabb.m_boundingRadius ||
pos.x + aabb.m_boundingRadius <= -planeX)
return true;
//檢測上下麵
float planeY = half_h * pos.z / -n;
if(pos.y - planeY >= aabb.m_boundingRadius ||
pos.y + aabb.m_boundingRadius <= -planeY)
return true;
return false;
}