本文整理汇总了C++中RendererPtr::GetViewport方法的典型用法代码示例。如果您正苦于以下问题:C++ RendererPtr::GetViewport方法的具体用法?C++ RendererPtr::GetViewport怎么用?C++ RendererPtr::GetViewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RendererPtr
的用法示例。
在下文中一共展示了RendererPtr::GetViewport方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBackgoundColor
Color EC_OgreEnvironment::GetBackgoundColor() const
{
if (renderer_.expired())
return Color(0.0f, 0.0f, 0.0f, 0.0f);
RendererPtr renderer = renderer_.lock();
return ToCoreColor(renderer->GetViewport()->getBackgroundColour());
}
示例2: SetBackgoundColor
void EC_OgreEnvironment::SetBackgoundColor(const Color &color)
{
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
renderer->GetViewport()->setBackgroundColour(ToOgreColor(color));
}
示例3:
EC_OgreCamera::EC_OgreCamera(Foundation::ModuleInterface* module) :
Foundation::ComponentInterface(module->GetFramework()),
renderer_(checked_static_cast<OgreRenderingModule*>(module)->GetRenderer()),
attached_(false),
camera_(0)
{
RendererPtr renderer = renderer_.lock();
Ogre::SceneManager* scene_mgr = renderer->GetSceneManager();
Ogre::Viewport* viewport = renderer->GetViewport();
camera_ = scene_mgr->createCamera(renderer->GetUniqueObjectName());
// Set default values for the camera
camera_->setNearClipDistance(0.1f);
camera_->setFarClipDistance(2000.f);
camera_->setAspectRatio(Ogre::Real(viewport->getActualWidth() / Ogre::Real(viewport->getActualHeight())));
camera_->setAutoAspectRatio(true);
}
示例4: InitCaelum
void EC_OgreEnvironment::InitCaelum()
{
using namespace Caelum;
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
if (!renderer->GetViewport())
return; // Headless mode
caelumComponents_ = CaelumSystem::CAELUM_COMPONENTS_NONE;
caelumComponents_ = caelumComponents_ |
CaelumSystem::CAELUM_COMPONENT_SKY_DOME |
CaelumSystem::CAELUM_COMPONENT_MOON |
CaelumSystem::CAELUM_COMPONENT_SUN |
CaelumSystem::CAELUM_COMPONENT_POINT_STARFIELD |
CaelumSystem::CAELUM_COMPONENT_SCREEN_SPACE_FOG |
CaelumSystem::CAELUM_COMPONENT_GROUND_FOG;
// Caelum clouds are hidden, otherwise shadows get messed up.
caelumSystem_ = new CaelumSystem(renderer->GetRoot().get(),
renderer->GetSceneManager(), (CaelumSystem::CaelumComponent)caelumComponents_);
// Flip the Caelum camera and ground node orientations 90 degrees.
Ogre::Quaternion orientation(Ogre::Degree(90), Ogre::Vector3(1, 0, 0));
caelumSystem_->getCaelumCameraNode()->setOrientation(orientation);
caelumSystem_->getCaelumGroundNode()->setOrientation(orientation);
// We want to manage the fog ourself.
caelumSystem_->setManageSceneFog(false);
// Use just one light (the brightest one) at a time.
caelumSystem_->setEnsureSingleLightSource(true);
caelumSystem_->setEnsureSingleShadowSource(true);
caelumSystem_->getMoon()->setDiffuseMultiplier(Ogre::ColourValue(0.25f, 0.25f, 0.25f));
}
示例5: DisableFog
EC_OgreEnvironment::~EC_OgreEnvironment()
{
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
if (!renderer->GetViewport())
return; // headless
//SetBackgoundColor(Color(0, 0, 0));
DisableFog();
if (sunlight_)
{
Ogre::SceneManager *sceneManager = renderer->GetSceneManager();
sceneManager->destroyLight(sunlight_);
sunlight_ = 0;
}
#ifdef CAELUM
ShutdownCaelum();
#endif
#ifdef HYDRAX
ShutdownHydrax();
#endif
}
示例6: InitHydrax
void EC_OgreEnvironment::InitHydrax()
{
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
// Create Hydrax system.
hydraxSystem_ = new Hydrax::Hydrax(renderer->GetSceneManager(), renderer->GetCurrentCamera(),
renderer->GetViewport());
// Create noise module.
noiseModule_ = new Hydrax::Noise::Perlin(Hydrax::Noise::Perlin::Options(8, 1.15f, 0.49f, 1.14f, 1.27f));
/*Ogre::Plane(Ogre::Vector3::UNIT_Z, 0)*/
// Create water plane
// Ogre::Plane plane(Ogre::Vector3::NEGATIVE_UNIT_Z, 0);
/*Ogre::MeshManager::getSingleton().createPlane("HydraxWaterMesh",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
5000, 5000, 10, 10, true, 1, 1, 1, Ogre::Vector3::UNIT_X);*/
// Create our projected grid module (Rush)
/*module_ = new Hydrax::Module::ProjectedGrid(hydraxSystem_, // Hydrax parent pointer
noiseModule_, // Noise module
Ogre::Plane(Ogre::Vector3(0,1,0), Ogre::Vector3(0,0,0)), // Base plane
Hydrax::MaterialManager::NM_VERTEX, // Normal mode
Hydrax::Module::ProjectedGrid::Options(150)); // Projected grid options
*/
// Nature
module_ = new Hydrax::Module::ProjectedGrid(
hydraxSystem_, noiseModule_,
Ogre::Plane(Ogre::Vector3(0, 1, 0), Ogre::Vector3(0, 0, 0)),
Hydrax::MaterialManager::NM_VERTEX,
Hydrax::Module::ProjectedGrid::Options(256, 3.25f, 0.035f, true));
hydraxSystem_->setModule(static_cast<Hydrax::Module::Module*>(module_));
// hydraxSystem_->loadCfg("HydraxDemo.hdx");
hydraxSystem_->loadCfg("goodPreset.hdx"); // from "Rush" demo app
// hydraxSystem_->setPosition(Ogre::Vector3(0,0,0));
hydraxSystem_->create();
// Rotate the water plane.
Ogre::Quaternion orientation(Ogre::Degree(90), Ogre::Vector3(1, 0, 0));
hydraxSystem_->rotate(orientation);
// hydraxSystem_->getMesh()->getSceneNode()->setOrientation(orientation);
// hydraxSystem_->getRttManager()->getPlanesSceneNode()->setOrientation(orientation);
// hydraxSystem_->setPosition(Ogre::Vector3(-5000, -5000, 20));
// hydraxSystem_->setPolygonMode(Ogre::PM_WIREFRAME);
// hydraxSystem_->getMaterialManager()->getMaterial(Hydrax::MaterialManager::MAT_WATER)->getTechnique(0)->getPass(0)->setFog(true, Ogre::FOG_NONE);
/*hydraxSystem_->setPlanesError(4);
hydraxSystem_->setDepthLimit(5.2);
hydraxSystem_->setNormalDistortion(0.035);
//hydraxSystem_->setDepthColor(Ogre::Vector3(0.04,0.185,0.265));
hydraxSystem_->setSmoothPower(2.5);
hydraxSystem_->setCausticsScale(8);
hydraxSystem_->setCausticsEnd(0.65);
hydraxSystem_->setGlobalTransparency(0);
hydraxSystem_->setFullReflectionDistance(99999997952.0);
hydraxSystem_->setPolygonMode(Ogre::PM_SOLID/*0*//*);
hydraxSystem_->setFoamScale(0.1);
hydraxSystem_->getMaterialManager()->getMaterial(Hydrax::MaterialManager::MAT_WATER)->getTechnique(0)->getPass(0)->setFog(true, Ogre::FOG_NONE);
*/
}
示例7: UpdateVisualEffects
void EC_OgreEnvironment::UpdateVisualEffects(f64 frametime)
{
if (renderer_.expired())
return;
RendererPtr renderer = renderer_.lock();
Ogre::Camera *camera = renderer->GetCurrentCamera();
Ogre::Viewport *viewport = renderer->GetViewport();
Ogre::SceneManager *sceneManager = renderer->GetSceneManager();
#ifdef CAELUM
// Set sunlight attenuation using diffuse multiplier.
// Seems to be working ok, but feel free to fix if you find better logic and/or values.
Ogre::ColourValue diffuseMultiplier(sunColorMultiplier_, sunColorMultiplier_, sunColorMultiplier_, 1);
caelumSystem_->getSun()->setDiffuseMultiplier(diffuseMultiplier);
Ogre::Light* sun = caelumSystem_->getSun()->getMainLight();
Ogre::Light* moon = caelumSystem_->getMoon()->getMainLight();
float sunDirZaxis = caelumSystem_->getSun()->getMainLight()->getDirection().z;
if (sunDirZaxis > 0)
{
sunColorMultiplier_ -= 0.005f;
if (sunColorMultiplier_ <= 0.05f)
sunColorMultiplier_ = 0.05f;
}
else if(sunDirZaxis < 0)
{
sunColorMultiplier_ += 0.010f;
if (sunColorMultiplier_ >= MAX_SUNLIGHT_MULTIPLIER)
sunColorMultiplier_ = MAX_SUNLIGHT_MULTIPLIER;
}
if ( !fog_color_override_)
fogColor_ = caelumSystem_->getGroundFog()->getColour();
#endif
#ifdef CAELUM
// Update Caelum system.
caelumSystem_->notifyCameraChanged(camera);
caelumSystem_->updateSubcomponents(frametime);
// Disable specular from the sun & moon for now, because it easily leads to too strong results
sun->setSpecularColour(0.0f, 0.0f, 0.0f);
moon->setSpecularColour(0.0f, 0.0f, 0.0f);
#endif
#ifdef HYDRAX
// Update Hydrax system.
hydraxSystem_->update(frametime);
sunPos = camera->getPosition();
sunPos -= caelumSystem_->getSun()->getLightDirection() * 80000;
hydraxSystem_->setSunPosition(sunPos);
#endif
Ogre::Entity* water = 0;
cameraFarClip_ = renderer->GetViewDistance();
if ( sceneManager->hasEntity("WaterEntity") )
water = sceneManager->getEntity("WaterEntity");
if (!water)
{
// No water entity, set fog value.
Real fogStart = fogStart_;
Real fogEnd = fogEnd_;
ClampFog(fogStart, fogEnd, cameraFarClip_);
sceneManager->setFog(Ogre::FOG_LINEAR, fogColor_, 0.001, fogStart, fogEnd);
viewport->setBackgroundColour(fogColor_);
camera->setFarClipDistance(cameraFarClip_);
}
else
{
if(camera->getDerivedPosition().z >= water->getParentNode()->getPosition().z)
{
// We're above the water.
Real fogStart = fogStart_;
Real fogEnd = fogEnd_;
ClampFog(fogStart, fogEnd, cameraFarClip_);
#ifdef CAELUM
caelumSystem_->forceSubcomponentVisibilityFlags(caelumComponents_);
#endif
sceneManager->setFog(Ogre::FOG_LINEAR, fogColor_, 0.001, fogStart, fogEnd);
viewport->setBackgroundColour(fogColor_);
camera->setFarClipDistance(cameraFarClip_);
cameraUnderWater_ = false;
}
else
{
// We're below the water.
Real fogStart = waterFogStart_;
Real fogEnd = waterFogEnd_;
Real farClip = waterFogEnd_ + 10.f;
if (farClip > cameraFarClip_)
farClip = cameraFarClip_;
//.........这里部分代码省略.........