本文整理汇总了C++中Matrix4f::MakeIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix4f::MakeIdentity方法的具体用法?C++ Matrix4f::MakeIdentity怎么用?C++ Matrix4f::MakeIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4f
的用法示例。
在下文中一共展示了Matrix4f::MakeIdentity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawCone
void DebugDrawer::DrawCone(const Vector3f& origin, const Quaternionf& rotation, float angle, float length)
{
if (!Initialize())
{
NazaraError("Failed to initialize Debug Drawer");
return;
}
Matrix4f transformMatrix;
transformMatrix.MakeIdentity();
transformMatrix.SetRotation(rotation);
transformMatrix.SetTranslation(origin);
BufferMapper<VertexBuffer> mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 16);
VertexStruct_XYZ* vertex = reinterpret_cast<VertexStruct_XYZ*>(mapper.GetPointer());
// On calcule le reste des points
Vector3f base(Vector3f::Forward()*length);
// Il nous faut maintenant le rayon du cercle projeté à cette distance
// Tangente = Opposé/Adjaçent <=> Opposé = Adjaçent*Tangente
float radius = length*std::tan(DegreeToRadian(angle));
Vector3f lExtend = Vector3f::Left()*radius;
Vector3f uExtend = Vector3f::Up()*radius;
vertex->position.Set(transformMatrix * Vector3f::Zero());
vertex++;
vertex->position.Set(transformMatrix * (base + lExtend + uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base + lExtend + uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base + lExtend - uExtend));
vertex++;
vertex->position.Set(transformMatrix * Vector3f::Zero());
vertex++;
vertex->position.Set(transformMatrix * (base + lExtend - uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base + lExtend - uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base - lExtend - uExtend));
vertex++;
vertex->position.Set(transformMatrix * Vector3f::Zero());
vertex++;
vertex->position.Set(transformMatrix * (base - lExtend + uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base - lExtend + uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base - lExtend - uExtend));
vertex++;
vertex->position.Set(transformMatrix * Vector3f::Zero());
vertex++;
vertex->position.Set(transformMatrix * (base - lExtend - uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base - lExtend + uExtend));
vertex++;
vertex->position.Set(transformMatrix * (base + lExtend + uExtend));
vertex++;
mapper.Unmap();
Renderer::SetRenderStates(s_renderStates);
Renderer::SetShader(s_shader);
Renderer::SetVertexBuffer(&s_vertexBuffer);
s_shader->SendColor(s_colorLocation, s_primaryColor);
Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, 16);
}
示例2: Process
bool DeferredPhongLightingPass::Process(const SceneData& sceneData, unsigned int firstWorkTexture, unsigned secondWorkTexture) const
{
NazaraAssert(sceneData.viewer, "Invalid viewer");
NazaraUnused(secondWorkTexture);
m_workRTT->SetColorTarget(firstWorkTexture);
Renderer::SetTarget(m_workRTT);
Renderer::SetViewport(Recti(0, 0, m_dimensions.x, m_dimensions.y));
Renderer::SetTexture(0, m_GBuffer[0]);
Renderer::SetTextureSampler(0, m_pointSampler);
Renderer::SetTexture(1, m_GBuffer[1]);
Renderer::SetTextureSampler(1, m_pointSampler);
Renderer::SetTexture(2, m_GBuffer[2]);
Renderer::SetTextureSampler(2, m_pointSampler);
Renderer::SetClearColor(Color::Black);
Renderer::Clear(RendererBuffer_Color);
RenderStates lightStates;
lightStates.dstBlend = BlendFunc_One;
lightStates.srcBlend = BlendFunc_One;
lightStates.parameters[RendererParameter_Blend] = true;
lightStates.parameters[RendererParameter_DepthBuffer] = false;
lightStates.parameters[RendererParameter_DepthWrite] = false;
// Directional lights
if (!m_renderQueue->directionalLights.empty())
{
Renderer::SetRenderStates(lightStates);
Renderer::SetShader(m_directionalLightShader);
m_directionalLightShader->SendColor(m_directionalLightShaderSceneAmbientLocation, sceneData.ambientColor);
m_directionalLightShader->SendVector(m_directionalLightShaderEyePositionLocation, sceneData.viewer->GetEyePosition());
for (auto& light : m_renderQueue->directionalLights)
{
m_directionalLightShader->SendColor(m_directionalLightUniforms.locations.color, light.color);
m_directionalLightShader->SendVector(m_directionalLightUniforms.locations.factors, Vector2f(light.ambientFactor, light.diffuseFactor));
m_directionalLightShader->SendVector(m_directionalLightUniforms.locations.parameters1, Vector4f(light.direction));
Renderer::DrawFullscreenQuad();
}
}
// Point lights/Spot lights
if (!m_renderQueue->pointLights.empty() || !m_renderQueue->spotLights.empty())
{
// http://www.altdevblogaday.com/2011/08/08/stencil-buffer-optimisation-for-deferred-lights/
lightStates.parameters[RendererParameter_StencilTest] = true;
lightStates.faceCulling = FaceSide_Front;
lightStates.backFace.stencilMask = 0xFF;
lightStates.backFace.stencilReference = 0;
lightStates.backFace.stencilFail = StencilOperation_Keep;
lightStates.backFace.stencilPass = StencilOperation_Keep;
lightStates.backFace.stencilZFail = StencilOperation_Invert;
lightStates.frontFace.stencilMask = 0xFF;
lightStates.frontFace.stencilReference = 0;
lightStates.frontFace.stencilFail = StencilOperation_Keep;
lightStates.frontFace.stencilPass = StencilOperation_Keep;
lightStates.frontFace.stencilZFail = StencilOperation_Invert;
Renderer::SetRenderStates(lightStates);
Renderer::SetShader(m_pointSpotLightShader);
m_pointSpotLightShader->SendColor(m_pointSpotLightShaderSceneAmbientLocation, sceneData.ambientColor);
m_pointSpotLightShader->SendVector(m_pointSpotLightShaderEyePositionLocation, sceneData.viewer->GetEyePosition());
Matrix4f lightMatrix;
lightMatrix.MakeIdentity();
if (!m_renderQueue->pointLights.empty())
{
const IndexBuffer* indexBuffer = m_sphereMesh->GetIndexBuffer();
Renderer::SetIndexBuffer(indexBuffer);
Renderer::SetVertexBuffer(m_sphereMesh->GetVertexBuffer());
m_pointSpotLightShader->SendInteger(m_pointSpotLightUniforms.locations.type, LightType_Point);
for (const auto& light : m_renderQueue->pointLights)
{
m_pointSpotLightShader->SendColor(m_pointSpotLightUniforms.locations.color, light.color);
m_pointSpotLightShader->SendVector(m_pointSpotLightUniforms.locations.factors, Vector2f(light.ambientFactor, light.diffuseFactor));
m_pointSpotLightShader->SendVector(m_pointSpotLightUniforms.locations.parameters1, Vector4f(light.position, light.attenuation));
m_pointSpotLightShader->SendVector(m_pointSpotLightUniforms.locations.parameters2, Vector4f(0.f, 0.f, 0.f, light.invRadius));
lightMatrix.SetScale(Vector3f(light.radius * 1.1f)); // Pour corriger les imperfections liées à la sphère
lightMatrix.SetTranslation(light.position);
Renderer::SetMatrix(MatrixType_World, lightMatrix);
// Rendu de la sphère dans le stencil buffer
Renderer::Enable(RendererParameter_ColorWrite, false);
Renderer::Enable(RendererParameter_DepthBuffer, true);
Renderer::Enable(RendererParameter_FaceCulling, false);
Renderer::SetStencilCompareFunction(RendererComparison_Always);
m_pointSpotLightShader->SendBoolean(m_pointSpotLightShaderDiscardLocation, true);
Renderer::DrawIndexedPrimitives(PrimitiveMode_TriangleList, 0, indexBuffer->GetIndexCount());
//.........这里部分代码省略.........