本文整理汇总了C++中Light::GetLightType方法的典型用法代码示例。如果您正苦于以下问题:C++ Light::GetLightType方法的具体用法?C++ Light::GetLightType怎么用?C++ Light::GetLightType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Light
的用法示例。
在下文中一共展示了Light::GetLightType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateGameObjectLight
void GameLightsUpdate::UpdateGameObjectLight(GameObject* gameObject)
{
AEAssert(gameObject != nullptr);
if (gameObject == nullptr)
{
return;
}
if (gameObject->HasLightGOC())
{
Light* light = gameObject->GetLightGOC()->GetLight();
if (light != nullptr && light->IsEnabled())
{
light->SetPosition(gameObject->GetWorldPosition());
if (light->GetLightType() == LightType::Spot || light->GetLightType() == LightType::Directional)
{
glm::vec3 direction = gameObject->GetDirection();
light->SetDirection(direction);
}
}
}
for (auto goIt : *gameObject)
{
UpdateGameObjectLight(goIt.second);
}
}
示例2: SetupDirectionalLight
void GLSLProgram<real>::SetupLights()
{
const std::vector<Light<real>*>* lights = RenderState<real>::Get()->GetLights();
// Setup enabled lights
for ( uint i=0 ; i<lights->size() && i<mLightLocations.size() ; ++i )
{
Light<real>* light = (*lights)[i];
glUniform1i( mLightLocations[i].enabled, true );
glUniform1i( mLightLocations[i].type, light->GetLightType() );
Vector3<float> position = light->GetLocalToGlobal() * Vector3<real>( 0, 0, 0 );
glUniform3fv( mLightLocations[i].position, 1, (float*)&position );
Color<float> intensity = light->GetIntensity();
glUniform4fv( mLightLocations[i].intensity, 1, (float*)&intensity );
Color<float> ambient = light->GetAmbient();
glUniform4fv( mLightLocations[i].ambient, 1, (float*)&ambient );
// Setup sub-parameters
switch( light->GetLightType() )
{
case Light<real>::TypeDirectional: SetupDirectionalLight( i, light ); break;
case Light<real>::TypePoint: SetupPointLight( i, light ); break;
case Light<real>::TypeSpot: SetupSpotLight( i, light ); break;
}
}
// Disabled lights
for ( uint i=lights->size() ; i<mLightLocations.size() ; ++i )
glUniform1i( mLightLocations[i].enabled, false );
// Nb of lights
glUniform1i( mNbLightsLocation, lights->size() );
}
示例3: ShadowDirLightRenderGameObject
AEResult GameLightsUpdate::ShadowDirLightRenderGameObject()
{
LightManager* lightManager = m_GameApp->GetLightManager();
GameObjectManager* gameObjectManager = m_GameApp->GetGameObjectManager();
if (lightManager->GetNumDirLightsWithShadows() == 0)
{
return AEResult::Ok;
}
Texture2DArray* shadowTextureArray = lightManager->GetDirLightShadowTextureArray();
AETODO("Check return");
RenderTarget* rtsDS[1] = { nullptr };
m_GraphicDevice->SetRenderTargetsAndDepthStencil(1, rtsDS, m_DirLightShadowTexturesDS);
for (auto lightIt : *lightManager)
{
Light* light = lightIt.second;
if (light->GetLightType() == LightType::Directional && light->IsShadowEnabled())
{
DirectionalLight* dirLight = reinterpret_cast<DirectionalLight*>(light);
uint32_t idxs[1] = { light->GetShadowTextureIndex() };
AETODO("Check return");
m_GraphicDevice->SetRenderTargets(1, idxs, shadowTextureArray);
m_GraphicDevice->Clear(true, 0, true, true, AEColors::Transparent);
for (uint32_t i = 0; i < AE_LIGHT_NUM_CASCADE_MAPS; i++)
{
AETODO("Check return");
m_GraphicDevice->SetViewport(m_DirLightShadowViewports[i]);
const LightCascadeInfo& lightCascadeInfo = dirLight->GetLightCascadeInfo();
for (auto goIt : *gameObjectManager)
{
AETODO("Check return");
ShadowLightRenderGameObject(goIt.second, lightCascadeInfo.m_CascadeViewMatrix[i], lightCascadeInfo.m_CascadeProjectionMatrix[i]);
}
}
}
}
AETODO("Check return");
m_GraphicDevice->ResetViewport();
AETODO("Check return");
m_GraphicDevice->ResetRenderTargetAndSetDepthStencil();
return AEResult::Ok;
}
示例4: finalColor
Color<real> BlinnPhongShader<real>::GetDiffuseAndSpecular( const Light<real>& light )
{
Color<real> finalColor( 0, 0, 0, 1 );
////////////////////////////////////////////
//////////////////IFT 3355//////////////////
////////////////////////////////////////////
//Ici, vous calculerez les composantes
//diffuse et spéculaire en vous servant des
//propriétés du matériau.
////////////////////////////////////////////
//////////////////IFT 3355//////////////////
////////////////////////////////////////////
Vector3<real> lightPos = light.GetGlobalPosition();
Vector3<real> lightDir = (lightPos - mIntersection.GetPosition()).Normalized();
real r2 = (mIntersection.GetPosition() - lightPos).SquaredLength();
Vector3<real> intersectionShifted = mIntersection.GetPosition() + EPS*mIntersection.GetNormal();
// Shadow+Diffuse
bool lightVisible = mRayTracer.IsLightVisible(intersectionShifted, &light);
if (!lightVisible)
return finalColor;
switch (light.GetLightType()) {
case Light<real>::TypeDirectional:
case Light<real>::TypeSpot:
case Light<real>::TypePoint:
finalColor += mMaterial.GetDiffuse() *
std::max<real>(0, lightDir * mIntersection.GetNormal()) *
GetMaterialSurfaceColor();
break;
}
// Specular
const Camera<real> *cam = mScene.GetActiveCamera();
Vector3<real> camDir = cam->GetFrontDirection();
Vector3<real> H = lightDir + camDir;
H.Normalize();
Vector3<real> N = mIntersection.GetNormal();
real n = mMaterial.GetShininess();
real cs = (n+2)/2;
Color<real> ks = mMaterial.GetSpecular();
Color<real> m = mMaterial.GetMetallic();
finalColor += cs * ks *
(m*GetMaterialSurfaceColor() + (Color<real>(1, 1, 1, 1) - m)) *
pow(N * H, n);
return finalColor * light.GetIntensity() / (r2 * PI);
}
示例5: InitComponent
void LightWidget::InitComponent(Component* pComponent)
{
BaseComponentEditor::InitComponent(pComponent);
BeginInit();
Light* pLight = (Light*)pComponent;
if(pLight != NULL)
{
selColor->setColor(pLight->GetColor());
lblSpeInden->SetText(QString::number(pLight->GetSpecularIntensity()).toStdString().c_str());
cboLightType->setCurrentIndex((int)pLight->GetLightType());
}
EndInit();
}
示例6: ShadowSpotLightRenderGameObject
AEResult GameLightsUpdate::ShadowSpotLightRenderGameObject()
{
LightManager* lightManager = m_GameApp->GetLightManager();
GameObjectManager* gameObjectManager = m_GameApp->GetGameObjectManager();
if (lightManager->GetNumSpotLightsWithShadows() == 0)
{
return AEResult::Ok;
}
Texture2DArray* shadowTextureArray = lightManager->GetSpotLightShadowTextureArray();
AETODO("Check return");
RenderTarget* rtsDS[1] = { nullptr };
m_GraphicDevice->SetRenderTargetsAndDepthStencil(1, rtsDS, m_SpotLightShadowTexturesDS);
AETODO("Check return");
m_GraphicDevice->SetViewport(m_SpotLightShadowViewport);
for (auto lightIt : *lightManager)
{
Light* light = lightIt.second;
if (light->GetLightType() == LightType::Spot && light->IsShadowEnabled())
{
uint32_t idxs[1] = { light->GetShadowTextureIndex() };
AETODO("Check return");
m_GraphicDevice->SetRenderTargets(1, idxs, shadowTextureArray);
m_GraphicDevice->Clear(true, 0, true, true, AEColors::Transparent);
for (auto goIt : *gameObjectManager)
{
AETODO("Check return");
ShadowLightRenderGameObject(goIt.second, light->GetViewMatrix(), light->GetProjectionMatrix());
}
}
}
AETODO("Check return");
m_GraphicDevice->ResetViewport();
AETODO("Check return");
m_GraphicDevice->ResetRenderTargetAndSetDepthStencil();
return AEResult::Ok;
}
示例7: on_m_FalloffAngleSB_editingFinished
void GameObjectLightComponentWidget::on_m_FalloffAngleSB_editingFinished()
{
if (!m_IsReady)
{
return;
}
Light* light = nullptr;
////////////////////////////////////////
// Verify LOC and Get Light Object
light = GetLight();
if(light == nullptr)
{
AETODO("Add log");
return;
}
////////////////////////////////////////
// Verify that it is Spot Light
if(light->GetLightType() != LightType::Spot)
{
return;
}
////////////////////////////////////////
// Get Spot Light
SpotLight* spotLight = reinterpret_cast<SpotLight*>(light);
float newFalloffAngle = static_cast<float>(m_GameObjectLightComponentWidgetQtUI.m_FalloffAngleSB->value());
float angle = spotLight->GetFallOffAngle();
if (newFalloffAngle < angle)
{
spotLight->SetAngle(newFalloffAngle);
m_GameObjectLightComponentWidgetQtUI.m_AngleSB->setValue(newFalloffAngle);
}
spotLight->SetFallOffAngle(newFalloffAngle);
}
示例8: Prepare
//.........这里部分代码省略.........
graphics->SetShaderParameter(PSP_FOGCOLOR, overrideFogColorToBlack ? Color::BLACK : zone_->GetFogColor());
float farClip = camera_->GetFarClip();
float fogStart = Min(zone_->GetFogStart(), farClip);
float fogEnd = Min(zone_->GetFogEnd(), farClip);
if (fogStart >= fogEnd * (1.0f - M_LARGE_EPSILON))
fogStart = fogEnd * (1.0f - M_LARGE_EPSILON);
float fogRange = Max(fogEnd - fogStart, M_EPSILON);
Vector4 fogParams(fogEnd / farClip, farClip / fogRange, 0.0f, 0.0f);
Node* zoneNode = zone_->GetNode();
if (zone_->GetHeightFog() && zoneNode)
{
Vector3 worldFogHeightVec = zoneNode->GetWorldTransform() * Vector3(0.0f, zone_->GetFogHeight(), 0.0f);
fogParams.z_ = worldFogHeightVec.y_;
fogParams.w_ = zone_->GetFogHeightScale() / Max(zoneNode->GetWorldScale().y_, M_EPSILON);
}
graphics->SetShaderParameter(PSP_FOGPARAMS, fogParams);
}
// Set light-related shader parameters
if (lightQueue_)
{
if (graphics->NeedParameterUpdate(SP_VERTEXLIGHTS, lightQueue_) && graphics->HasShaderParameter(VS, VSP_VERTEXLIGHTS))
{
Vector4 vertexLights[MAX_VERTEX_LIGHTS * 3];
const PODVector<Light*>& lights = lightQueue_->vertexLights_;
for (unsigned i = 0; i < lights.Size(); ++i)
{
Light* vertexLight = lights[i];
Node* vertexLightNode = vertexLight->GetNode();
LightType type = vertexLight->GetLightType();
// Attenuation
float invRange, cutoff, invCutoff;
if (type == LIGHT_DIRECTIONAL)
invRange = 0.0f;
else
invRange = 1.0f / Max(vertexLight->GetRange(), M_EPSILON);
if (type == LIGHT_SPOT)
{
cutoff = Cos(vertexLight->GetFov() * 0.5f);
invCutoff = 1.0f / (1.0f - cutoff);
}
else
{
cutoff = -1.0f;
invCutoff = 1.0f;
}
// Color
float fade = 1.0f;
float fadeEnd = vertexLight->GetDrawDistance();
float fadeStart = vertexLight->GetFadeDistance();
// Do fade calculation for light if both fade & draw distance defined
if (vertexLight->GetLightType() != LIGHT_DIRECTIONAL && fadeEnd > 0.0f && fadeStart > 0.0f && fadeStart < fadeEnd)
fade = Min(1.0f - (vertexLight->GetDistance() - fadeStart) / (fadeEnd - fadeStart), 1.0f);
Color color = vertexLight->GetEffectiveColor() * fade;
vertexLights[i * 3] = Vector4(color.r_, color.g_, color.b_, invRange);
// Direction
vertexLights[i * 3 + 1] = Vector4(-(vertexLightNode->GetWorldDirection()), cutoff);
示例9: InitFields
void GameObjectLightComponentWidget::InitFields()
{
Light* light = nullptr;
////////////////////////////////////////
// Set Ready to false, so Light cannot change
// properties while been initialized
m_IsReady = false;
////////////////////////////////////////
// Check Engine Viewer
AEAssert(m_EngineViewer != nullptr);
if (m_EngineViewer == nullptr)
{
return;
}
////////////////////////////////////////
// Verify LOC and Get Light Object
light = GetLight();
if(light == nullptr)
{
AETODO("Add log");
return;
}
////////////////////////////////////////
// Set Light Type
SetLightTypeComboBoxIndex(light->GetLightType());
////////////////////////////////////////
// Set Enabled
m_GameObjectLightComponentWidgetQtUI.m_Enabled->setChecked(light->IsEnabled());
////////////////////////////////////////
// Set Intensity
m_GameObjectLightComponentWidgetQtUI.m_IntensitySB->setValue(static_cast<double>(light->GetIntensity()));
////////////////////////////////////////
// Set Color
QColor qColor = AEQTHelpers::GetQColorFromColor(light->GetColor());
SetColorToColorWidget(qColor);
////////////////////////////////////////
// Set Near and Far Attenuation
m_GameObjectLightComponentWidgetQtUI.m_NearAttSB->setValue(static_cast<double>(light->GetNearAttenuation()));
m_GameObjectLightComponentWidgetQtUI.m_FarAttSB->setValue(static_cast<double>(light->GetFarAttenuation()));
////////////////////////////////////////
// Set Shadow Enabled
m_GameObjectLightComponentWidgetQtUI.m_ShadowEnabled->setChecked(light->IsShadowEnabled());
m_GameObjectLightComponentWidgetQtUI.m_DrawFrustum->setEnabled(light->IsShadowEnabled());
////////////////////////////////////////
// Enable/Visibility of Angle options
if(light->GetLightType() == LightType::Spot)
{
m_GameObjectLightComponentWidgetQtUI.m_LabelAngle->setVisible(true);
m_GameObjectLightComponentWidgetQtUI.m_LabelFalloffAngle->setVisible(true);
m_GameObjectLightComponentWidgetQtUI.m_AngleSB->setVisible(true);
m_GameObjectLightComponentWidgetQtUI.m_FalloffAngleSB->setVisible(true);
////////////////////////////////////////
// Get Spot Light
SpotLight* spotLight = reinterpret_cast<SpotLight*>(light);
////////////////////////////////////////
// Set Angle and Fall out Angle
m_GameObjectLightComponentWidgetQtUI.m_AngleSB->setValue(static_cast<double>(spotLight->GetAngle()));
m_GameObjectLightComponentWidgetQtUI.m_FalloffAngleSB->setValue(static_cast<double>(spotLight->GetFallOffAngle()));
}
else
{
m_GameObjectLightComponentWidgetQtUI.m_LabelAngle->setVisible(false);
m_GameObjectLightComponentWidgetQtUI.m_LabelFalloffAngle->setVisible(false);
m_GameObjectLightComponentWidgetQtUI.m_AngleSB->setVisible(false);
m_GameObjectLightComponentWidgetQtUI.m_FalloffAngleSB->setVisible(false);
}
////////////////////////////////////////
// Enable/Visibility of Draw Frustum Cascades
if (light->GetLightType() == LightType::Directional)
{
m_GameObjectLightComponentWidgetQtUI.m_DrawCascadeFrustums->setVisible(true);
}
else
{
m_GameObjectLightComponentWidgetQtUI.m_DrawCascadeFrustums->setVisible(false);
}
////////////////////////////////////////
// Light is Ready to change properties
m_IsReady = true;
}
示例10: Prepare
//.........这里部分代码省略.........
float fogStart = Min(zone_->GetFogStart(), farClip);
float fogEnd = Min(zone_->GetFogEnd(), farClip);
if (fogStart >= fogEnd * (1.0f - M_LARGE_EPSILON))
fogStart = fogEnd * (1.0f - M_LARGE_EPSILON);
float fogRange = Max(fogEnd - fogStart, M_EPSILON);
Vector4 fogParams(fogEnd / farClip, farClip / fogRange, 0.0f, 0.0f);
Node* zoneNode = zone_->GetNode();
if (zone_->GetHeightFog() && zoneNode)
{
Vector3 worldFogHeightVec = zoneNode->GetWorldTransform() * Vector3(0.0f, zone_->GetFogHeight(), 0.0f);
fogParams.z_ = worldFogHeightVec.y_;
fogParams.w_ = zone_->GetFogHeightScale() / Max(zoneNode->GetWorldScale().y_, M_EPSILON);
}
graphics->SetShaderParameter(PSP_FOGPARAMS, fogParams);
}
// Set light-related shader parameters
if (lightQueue_)
{
if (light && graphics->NeedParameterUpdate(SP_LIGHT, lightQueue_))
{
Node* lightNode = light->GetNode();
float atten = 1.0f / Max(light->GetRange(), M_EPSILON);
Vector3 lightDir(lightNode->GetWorldRotation() * Vector3::BACK);
Vector4 lightPos(lightNode->GetWorldPosition(), atten);
graphics->SetShaderParameter(VSP_LIGHTDIR, lightDir);
graphics->SetShaderParameter(VSP_LIGHTPOS, lightPos);
if (graphics->HasShaderParameter(VSP_LIGHTMATRICES))
{
switch (light->GetLightType())
{
case LIGHT_DIRECTIONAL:
{
Matrix4 shadowMatrices[MAX_CASCADE_SPLITS];
unsigned numSplits = Min(MAX_CASCADE_SPLITS, lightQueue_->shadowSplits_.Size());
for (unsigned i = 0; i < numSplits; ++i)
CalculateShadowMatrix(shadowMatrices[i], lightQueue_, i, renderer);
graphics->SetShaderParameter(VSP_LIGHTMATRICES, shadowMatrices[0].Data(), 16 * numSplits);
}
break;
case LIGHT_SPOT:
{
Matrix4 shadowMatrices[2];
CalculateSpotMatrix(shadowMatrices[0], light);
bool isShadowed = shadowMap && graphics->HasTextureUnit(TU_SHADOWMAP);
if (isShadowed)
CalculateShadowMatrix(shadowMatrices[1], lightQueue_, 0, renderer);
graphics->SetShaderParameter(VSP_LIGHTMATRICES, shadowMatrices[0].Data(), isShadowed ? 32 : 16);
}
break;
case LIGHT_POINT:
{
Matrix4 lightVecRot(lightNode->GetWorldRotation().RotationMatrix());
// HLSL compiler will pack the parameters as if the matrix is only 3x4, so must be careful to not overwrite
// the next parameter
#ifdef ATOMIC_OPENGL