本文整理汇总了C++中LightPtr::Initilize方法的典型用法代码示例。如果您正苦于以下问题:C++ LightPtr::Initilize方法的具体用法?C++ LightPtr::Initilize怎么用?C++ LightPtr::Initilize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LightPtr
的用法示例。
在下文中一共展示了LightPtr::Initilize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MainLoop
void MainLoop()
{
static bool isInitilized = false;
static Transform objectTrans;
static Transform cameraTrans;
static TransformController objectCtrl;
static MeshWrapper<Vertex> meshW;
static ShaderPtr forwardBaseShader;
static ShaderPtr forwardAdditionShader;
static LightPtr lightRed;
static LightPtr lightBlue;
if (!isInitilized)
{
isInitilized = true;
auto camera = CameraPtr(new Camera());
camera->SetPerspective(60.f, 1.33333f, 0.3f, 2000.f);
camera->transform.position = Vector3(0.f, 0.f, -2.f);
SoftRender::camera = camera;
lightRed = LightPtr(new Light());
lightRed->type = Light::LightType_Point;
lightRed->color = Color::red;
lightRed->transform.position = Vector3(-0.5f, 1.f, 0.f);
lightRed->transform.rotation = Quaternion(Vector3(90.f,0.f, 0.f));
lightRed->intensity = 2.f;
lightRed->range = 5.f;
lightRed->atten0 = 0.1f;
lightRed->atten1 = 5.0f;
lightRed->atten2 = 2.0f;
lightRed->theta = 30.f;
lightRed->phi = 45.f;
lightRed->Initilize();
lightBlue = LightPtr(new Light());
lightBlue->type = Light::LightType_Point;
lightBlue->color = Color::blue;
lightBlue->transform.position = Vector3(0.5f, 1.f, 0.f);
lightBlue->transform.rotation = Quaternion(Vector3(90.f, 0.f, 0.f));
lightBlue->intensity = 3.f;
lightBlue->range = 5.f;
lightBlue->atten0 = 0.1f;
lightBlue->atten1 = 5.0f;
lightBlue->atten2 = 2.0f;
lightBlue->theta = 30.f;
lightBlue->phi = 45.f;
lightBlue->Initilize();
auto shader0 = std::make_shared<ForwardBaseShader>();
forwardBaseShader = shader0;
auto shader1 = std::make_shared<ForwardAdditionShader>();
forwardAdditionShader = shader1;
std::vector<MeshPtr> meshes;
meshes.push_back(CreatePlane());
objectTrans.position.y = 0.f;
meshW.vertices.clear();
meshW.indices.clear();
for (int meshID = 0; meshID < (int)meshes.size(); ++meshID)
{
auto& mesh = meshes[meshID];
int meshOffset = (int)meshW.vertices.size();
int vertexCount = mesh->GetVertexCount();
int indexCount = mesh->indices.size();
for (int i = 0; i < vertexCount; ++i)
{
meshW.vertices.emplace_back(Vertex{ mesh->vertices[i], mesh->normals[i] });
}
for (int i = 0; i < indexCount; ++i)
{
meshW.indices.emplace_back(mesh->indices[i] + meshOffset);
}
}
}
SoftRender::Clear(true, true, Color(1.f, 0.19f, 0.3f, 0.47f));
objectCtrl.MouseRotate(objectTrans, false);
SoftRender::modelMatrix = objectTrans.localToWorldMatrix();
SoftRender::renderData.AssignVertexBuffer(meshW.vertices);
SoftRender::renderData.AssignIndexBuffer(meshW.indices);
SoftRender::light = lightRed;
SoftRender::renderState.alphaBlend = false;
SoftRender::SetShader(forwardBaseShader);
SoftRender::Submit();
SoftRender::light = lightBlue;
SoftRender::renderState.alphaBlend = true;
SoftRender::renderState.srcFactor = RenderState::BlendFactor_One;
SoftRender::renderState.dstFactor = RenderState::BlendFactor_One;
SoftRender::SetShader(forwardAdditionShader);
SoftRender::Submit();
SoftRender::Present();
}