本文整理汇总了C++中PointLight::getQuadraticAtt方法的典型用法代码示例。如果您正苦于以下问题:C++ PointLight::getQuadraticAtt方法的具体用法?C++ PointLight::getQuadraticAtt怎么用?C++ PointLight::getQuadraticAtt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointLight
的用法示例。
在下文中一共展示了PointLight::getQuadraticAtt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildLightData
void RenderLists::buildLightData(
Camera* camera,
Light* shadowCaster,
LightData& lightData )
{
unsigned i = 0;
for ( std::vector<Light*>::iterator it = m_lights.begin();
it != m_lights.end(); ++it )
{
Light* light = *it;
// TODO: FIX THIS SHIT
glm::vec3 pos( light->getTransform()->translation );
if ( light->getTransform()->parent != NULL )
{
glm::mat4 lightMatrix( 1.0f );
light->getTransform()->parent->apply( lightMatrix );
pos = ( lightMatrix * glm::vec4( pos, 1.0f ) ).xyz();
}
// glm::vec3 pos( light->getTransform()->translation );
// calculate rotation
glm::mat4 rotMat = glm::mat4( 1.0f );
rotMat *= glm::rotate(
light->getTransform()->rotation.z * util::math::DEGREES_TO_RADIANS,
glm::vec3( 0.0f, 0.0f, 1.0f )
);
rotMat *= glm::rotate(
light->getTransform()->rotation.y * util::math::DEGREES_TO_RADIANS,
glm::vec3( 0.0f, 1.0f, 0.0f )
);
rotMat *= glm::rotate(
light->getTransform()->rotation.x * util::math::DEGREES_TO_RADIANS,
glm::vec3( 1.0f, 0.0f, 0.0f )
);
glm::vec3 rot( 0.0f, 0.0f, -1.0f );
rot = glm::vec3( rotMat * glm::vec4( rot, 0.0f ) );
// add generic data
lightData.names.push_back( light->getId() );
lightData.types.push_back(
static_cast<int>( light->getLightType() ) );
lightData.colours.push_back( light->getValue().r );
lightData.colours.push_back( light->getValue().g );
lightData.colours.push_back( light->getValue().b );
// light type specific data
switch ( light->getLightType() )
{
case light::DIRECTIONAL:
{
pos = glm::vec3(
camera->getViewMatrix() * glm::vec4( pos, 0.0f ) );
rot = glm::vec3(
camera->getViewMatrix()* glm::vec4( rot, 0.0f ) );
lightData.attenuations.push_back( 1.0f );
lightData.attenuations.push_back( 0.0f );
lightData.attenuations.push_back( 0.0f );
lightData.arcs.push_back( 0.0f );
lightData.arcs.push_back( 0.0f );
break;
}
case light::POINT:
{
PointLight* point = dynamic_cast<PointLight*>( light );
pos = glm::vec3(
camera->getViewMatrix() * glm::vec4( pos, 1.0f ) );
rot = glm::vec3(
camera->getViewMatrix() * glm::vec4( rot, 1.0f ) );
lightData.attenuations.push_back( point->getConstantAtt() );
lightData.attenuations.push_back( point->getLinearAtt() );
lightData.attenuations.push_back( point->getQuadraticAtt() );
lightData.arcs.push_back( 0.0f );
lightData.arcs.push_back( 0.0f );
break;
}
case light::SPOT:
{
SpotLight* spot = dynamic_cast<SpotLight*>( light );
pos = glm::vec3(
camera->getViewMatrix() * glm::vec4( pos, 1.0f ) );
rot = glm::vec3(
camera->getViewMatrix() * glm::vec4( rot, 0.0f ) );
lightData.attenuations.push_back( spot->getConstantAtt() );
lightData.attenuations.push_back( spot->getLinearAtt() );
lightData.attenuations.push_back( spot->getQuadraticAtt() );
lightData.arcs.push_back(
util::math::cosd( spot->getOuterArc() ) );
lightData.arcs.push_back(
util::math::cosd( spot->getInnerArc() ) );
break;
}
}
// positions
lightData.positions.push_back( pos.x );
lightData.positions.push_back( pos.y );
lightData.positions.push_back( pos.z );
// rotations
lightData.rotations.push_back( rot.x );
//.........这里部分代码省略.........