本文整理汇总了C++中std::shared_ptr::AddLight方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::AddLight方法的具体用法?C++ shared_ptr::AddLight怎么用?C++ shared_ptr::AddLight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::AddLight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRenderQuery
void OcTree::GetRenderQuery(const Collidable &collider, const std::shared_ptr<RenderQuery> &renderQuery) const
{
renderQuery->Clear();
WalkScene(collider, [&](const SceneNode::Ptr &sceneNode)
{
if (sceneNode->GetComponent<Light>() != nullptr)
renderQuery->AddLight(sceneNode);
if (auto render = sceneNode->GetComponent<MeshRender>())
{
if (render->GetRenderable())
renderQuery->AddRenderable(sceneNode);
}
});
}
示例2: GfxInitialize
HRESULT GfxInitialize()
{
UINT dxgiFlags = 0;
#ifdef _DEBUG
dxgiFlags |= DXGI_CREATE_FACTORY_DEBUG;
#endif
HRESULT hr = CreateDXGIFactory2(dxgiFlags, IID_PPV_ARGS(&Factory));
CHECKHR(hr);
bool createDebug = false;
#ifdef _DEBUG
createDebug = true;
#endif
Graphics = std::make_shared<GraphicsDevice>();
hr = Graphics->Initialize(Factory, nullptr, createDebug);
CHECKHR(hr);
Presenter = std::make_unique<DxgiPresenter>(Graphics, AppWindow);
hr = Presenter->Initialize();
CHECKHR(hr);
//Renderer = std::make_unique<LPFRenderer>(Graphics);
Renderer = std::make_unique<ForwardPlusRenderer>(Graphics);
hr = Renderer->Initialize();
CHECKHR(hr);
TheScene = std::make_shared<Scene>();
std::vector<std::shared_ptr<Visual>> visuals;
Assets = std::make_shared<AssetLoader>(Graphics, L"..\\ProcessedContent");
hr = Assets->LoadModel(L"crytek-sponza\\sponza.model", &visuals);
CHECKHR(hr);
for (auto& visual : visuals)
{
TheScene->AddVisual(visual);
}
#ifdef USE_HEADLIGHT
Headlight = std::make_shared<DirectionalLight>();
Headlight->SetColor(XMFLOAT3(1.f, 1.f, 1.f));
Headlight->SetOrientation(QuaternionFromViewDirection(XMVector3Normalize(XMVectorSet(1, -1, 1, 0)), XMVectorSet(0, 1, 0, 0)));
TheScene->AddLight(Headlight);
#else
// Add some lights
std::shared_ptr<Light> light = std::make_shared<DirectionalLight>();
light->SetColor(XMFLOAT3(0.6f, 0.6f, 0.4f));
light->SetOrientation(QuaternionFromViewDirection(XMVector3Normalize(XMVectorSet(-1, -1, -1, 0)), XMVectorSet(0, 1, 0, 0)));
//TheScene->AddLight(light);
light = std::make_shared<DirectionalLight>();
light->SetColor(XMFLOAT3(0.4f, 0.4f, 0.6f));
light->SetOrientation(QuaternionFromViewDirection(XMVector3Normalize(XMVectorSet(1, -1, 1, 0)), XMVectorSet(0, 1, 0, 0)));
//TheScene->AddLight(light);
srand(0);
for (float y = 50; y < 500; y +=100)
{
for (float x = -1000; x < 1000; x += 100)
{
for (float z = -500; z < 500; z += 100)
{
float r = (rand() % 256) / 256.f;
float g = (rand() % 256) / 256.f;
float b = (rand() % 256) / 256.f;
light = std::make_shared<PointLight>();
light->SetColor(XMFLOAT3(r, g, b));
light->SetPosition(XMFLOAT3(x, y, z));
((PointLight*)light.get())->SetRadius(100.f);
TheScene->AddLight(light);
}
}
}
#endif
Renderer->SetScene(TheScene);
BackBufferRT.Texture = Presenter->GetBackBuffer();
BackBufferRT.Viewport.Width = static_cast<float>(BackBufferRT.Texture->GetDesc().Width);
BackBufferRT.Viewport.Height = static_cast<float>(BackBufferRT.Texture->GetDesc().Height);
BackBufferRT.Viewport.MaxDepth = 1.f;
View.NearClipDistance = 1.f;
View.FarClipDistance = 5000.f;
XMStoreFloat4x4(&View.ViewToProjection,
XMMatrixPerspectiveFovLH(
XMConvertToRadians(60.f),
ClientWidth / (float)ClientHeight,
View.NearClipDistance,
View.FarClipDistance));
return hr;
}