本文整理汇总了C++中ogre::Light::getAttenuationConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ Light::getAttenuationConstant方法的具体用法?C++ Light::getAttenuationConstant怎么用?C++ Light::getAttenuationConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Light
的用法示例。
在下文中一共展示了Light::getAttenuationConstant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Start
void DLightEffect::Start()
{
if (!m_light && m_dlType != eDLightType_None)
{
assert(m_state == eEffectState_Uninit);
//创建光源
m_light = RenderManager.CreateDLight(m_dlType);
assert(m_light);
//设置参数
Ogre::Light* lightSrc = m_light->getParentLight();
lightSrc->setVisible(false);
lightSrc->setAttenuation(m_fRadius, m_dlPointParam.x, m_dlPointParam.y, m_dlPointParam.z);
m_light->setAttenuation(lightSrc->getAttenuationConstant(), lightSrc->getAttenuationLinear(), lightSrc->getAttenuationQuadric());
}
if(m_state == eEffectState_Uninit)
m_parent->attachObjectToBone(m_locator, m_light->getParentLight());
__super::Start();
}
示例2: while
//!
//! Clones an Ogre::MovableObject.
//!
//! Is needed because OGRE does not provide clone functions for cameras and
//! lights.
//!
//! \param movableObject The object to clone.
//! \param name The name to use for the object.
//! \param sceneManager The scene manager to use for creating the object.
//! \return The cloned object.
//!
Ogre::MovableObject * OgreTools::cloneMovableObject ( Ogre::MovableObject *movableObject, const QString &name, Ogre::SceneManager *sceneManager /* = 0 */ )
{
// make sure the given object is valid
if (!movableObject) {
Log::error("The given movable object is invalid.", "OgreTools::cloneMovableObject");
return 0;
}
// make sure a valid scene manager is available
if (!sceneManager)
sceneManager = movableObject->_getManager();
if (!sceneManager) {
Log::error("No valid scene manager available.", "OgreTools::cloneMovableObject");
return 0;
}
Ogre::MovableObject *result = 0;
Ogre::String typeName = movableObject->getMovableType();
if (typeName == "Entity") {
// clone entity
Ogre::Entity *entity = dynamic_cast<Ogre::Entity *>(movableObject);
//movableObjectCopy = entity->clone(name.toStdString());
Ogre::Entity *entityCopy = sceneManager->createEntity(name.toStdString(), entity->getMesh()->getName());
Ogre::AnimationStateSet *animationStateSet = entity->getAllAnimationStates();
Ogre::AnimationStateSet *animationStateSetCopy = entityCopy->getAllAnimationStates();
// set the same blend mode on entity copy
if (entity && entityCopy) {
if (entity->hasSkeleton() && entityCopy->hasSkeleton()) {
Ogre::Skeleton *skeleton = entity->getSkeleton();
Ogre::Skeleton *skeletonCopy = entityCopy->getSkeleton();
skeletonCopy->setBlendMode(skeleton->getBlendMode());
}
}
// copy all animation states
if (animationStateSet && animationStateSetCopy) {
Ogre::AnimationStateIterator animationStateIter = animationStateSet->getAnimationStateIterator();
Ogre::AnimationStateIterator animationStateCopyIter = animationStateSetCopy->getAnimationStateIterator();
while (animationStateIter.hasMoreElements()) {
if (!animationStateCopyIter.hasMoreElements())
break;
Ogre::AnimationState *animationState = animationStateIter.getNext();
Ogre::AnimationState *animationStateCopy = animationStateCopyIter.getNext();
animationStateCopy->setLoop(animationState->getLoop());
//bool enabled = animationState->getEnabled();
//animationStateCopy->setEnabled(animationState->getEnabled());
animationStateCopy->setEnabled(true);
animationStateCopy->setTimePosition(animationState->getTimePosition());
}
}
// create a new container for the cloned entity
OgreContainer *entityCopyContainer = new OgreContainer(entityCopy);
entityCopy->setUserAny(Ogre::Any(entityCopyContainer));
if (!entity->getUserAny().isEmpty()) {
OgreContainer *entityContainer = Ogre::any_cast<OgreContainer *>(entity->getUserAny());
if (entityContainer) {
QObject::connect(entityContainer, SIGNAL(animationStateUpdated(const QString &, double)), entityCopyContainer, SLOT(updateAnimationState(const QString &, double)));
QObject::connect(entityContainer, SIGNAL(boneTransformUpdated(const QString &, double, double, double, double, double, double)), entityCopyContainer, SLOT(updateBoneTransform(const QString &, double, double, double, double, double, double)));
}
}
result = dynamic_cast<Ogre::MovableObject *>(entityCopy);
} else if (typeName == "Light") {
// clone light
Ogre::Light *light = dynamic_cast<Ogre::Light *>(movableObject);
Ogre::Light *lightCopy = sceneManager->createLight(name.toStdString());
lightCopy->setType(light->getType());
lightCopy->setDiffuseColour(light->getDiffuseColour());
lightCopy->setSpecularColour(light->getSpecularColour());
lightCopy->setAttenuation(light->getAttenuationRange(), light->getAttenuationConstant(), light->getAttenuationLinear(), light->getAttenuationQuadric());
lightCopy->setPosition(light->getPosition());
lightCopy->setDirection(light->getDirection());
if (lightCopy->getType() == Ogre::Light::LT_SPOTLIGHT)
lightCopy->setSpotlightRange(light->getSpotlightInnerAngle(), light->getSpotlightOuterAngle(), light->getSpotlightFalloff());
lightCopy->setPowerScale(light->getPowerScale());
lightCopy->setCastShadows(light->getCastShadows());
// create a new container for the cloned light
OgreContainer *lightCopyContainer = new OgreContainer(lightCopy);
lightCopy->setUserAny(Ogre::Any(lightCopyContainer));
if (!light->getUserAny().isEmpty()) {
OgreContainer *lightContainer = Ogre::any_cast<OgreContainer *>(light->getUserAny());
if (lightContainer)
QObject::connect(lightContainer, SIGNAL(sceneNodeUpdated()), lightCopyContainer, SLOT(updateLight()));
}
result = dynamic_cast<Ogre::MovableObject *>(lightCopy);
} else if (typeName == "Camera") {
// clone camera
Ogre::Camera *camera = dynamic_cast<Ogre::Camera *>(movableObject);
Ogre::Camera *cameraCopy = sceneManager->createCamera(name.toStdString());
//.........这里部分代码省略.........