本文整理汇总了C++中ogre::scenemanager::MovableObjectIterator类的典型用法代码示例。如果您正苦于以下问题:C++ MovableObjectIterator类的具体用法?C++ MovableObjectIterator怎么用?C++ MovableObjectIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MovableObjectIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintGL
/**
* @brief render a frame
* @author Kito Berg-Taylor
*/
void THIS::paintGL()
{
if (!initialised)
initializeOgre();
for (Ogre::SceneManager::MovableObjectIterator mit = mSceneMgr->getMovableObjectIterator("Entity");mit.hasMoreElements(); mit.moveNext() )
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
if (entity->hasSkeleton() )
{
for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator(); animIt.hasMoreElements(); animIt.moveNext() )
{
Ogre::AnimationState *animState = animIt.peekNextValue();
if ( animState->getEnabled() )
{
animState->addTime(mWindow->getBestFPS()/10000);
}
}
}
}
//Ogre::WindowEventUtilities::messagePump();
mRoot->renderOneFrame();
}
示例2: while
void RttManager::CDepthListener::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
Hydrax *mHydrax = mRttManager->mHydrax;
Ogre::SceneManager::MovableObjectIterator EntityIterator = mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
Ogre::Entity* CurrentEntity;
unsigned int k;
while (EntityIterator.hasMoreElements()) {
CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue());
for (k = 0; k < CurrentEntity->getNumSubEntities(); k++) {
CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front());
mMaterials.pop();
}
EntityIterator.moveNext();
}
mHydrax->getMesh()->getEntity()->setVisible(true);
mHydrax->getGodRaysManager()->setVisible(false);
mHydrax->getMesh()->getEntity()->setRenderQueueGroup(Ogre::RENDER_QUEUE_1);
if (Ogre::Math::Abs(mHydrax->getPosition().y - mHydrax->getCamera()->getPosition().y) > mHydrax->getPlanesError()) {
if (mHydrax->_isCurrentFrameUnderwater()) {
mRttManager->mPlanes[RTT_DEPTH]->normal = -mRttManager->mPlanes[RTT_DEPTH]->normal;
mRttManager->mPlanes[RTT_DEPTH]->getParentNode()->translate(0, +mHydrax->getPlanesError(), 0);
} else {
mRttManager->mPlanes[RTT_DEPTH]->getParentNode()->translate(0, -mHydrax->getPlanesError(), 0);
}
mHydrax->getCamera()->disableCustomNearClipPlane();
}
}
示例3: update
void DemoGameLogic::update(void)
{
mLastFrameTime = mCurrentTime;
mCurrentTime = mTime->elapsed();
float timeElapsedInSeconds = (mCurrentTime - mLastFrameTime) / 1000.0f;
for (Ogre::SceneManager::MovableObjectIterator moi = mSceneManager->getMovableObjectIterator("Entity"); moi.hasMoreElements(); moi.moveNext())
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(moi.peekNextValue());
Ogre::AnimationStateSet* animationStateSet = entity->getAllAnimationStates();
if(animationStateSet && animationStateSet->hasAnimationState("Walk"))
{
Ogre::AnimationState* walkAnimationState = animationStateSet->getAnimationState("Walk");
walkAnimationState->addTime(timeElapsedInSeconds);
}
}
float distance = mCameraSpeed * timeElapsedInSeconds;
if(mKeyStates[Qt::Key_W] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() + mCamera->getDirection() * distance);
}
if(mKeyStates[Qt::Key_S] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() - mCamera->getDirection() * distance);
}
if(mKeyStates[Qt::Key_A] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() - mCamera->getRight() * distance);
}
if(mKeyStates[Qt::Key_D] == KS_PRESSED)
{
mCamera->setPosition(mCamera->getPosition() + mCamera->getRight() * distance);
}
if(!mIsFirstFrame)
{
QPoint mouseDelta = mCurrentMousePos - mLastFrameMousePos;
mCamera->yaw(Ogre::Radian(-mouseDelta.x() * timeElapsedInSeconds));
mCamera->pitch(Ogre::Radian(-mouseDelta.y() * timeElapsedInSeconds));
int wheelDelta = mCurrentWheelPos - mLastFrameWheelPos;
Ogre::Radian fov = mCamera->getFOVy();
fov += Ogre::Radian(-wheelDelta * 0.001);
fov = (std::min)(fov, Ogre::Radian(2.0f));
fov = (std::max)(fov, Ogre::Radian(0.5f));
mCamera->setFOVy(fov);
}
mLastFrameMousePos = mCurrentMousePos;
mLastFrameWheelPos = mCurrentWheelPos;
mIsFirstFrame = false;
}
示例4: updateOnEveryRenderable
void ResourceGroupReloader::updateOnEveryRenderable()
{
//1/ get all the available object type (entity, light, user defined types ...)
std::vector<std::string> allAvailableTypes;
Ogre::Root::MovableObjectFactoryIterator iterFactory = Ogre::Root::getSingleton().getMovableObjectFactoryIterator();
for(;iterFactory.hasMoreElements();)
{
Ogre::MovableObjectFactory* factory = iterFactory.getNext();
allAvailableTypes.push_back(factory->getType());
}
UpdateMaterialRenderableVisitor lRenderableVisitor;
//2/ for each scene manager, lets visit renderables!
// unfortunately that does not cover all renderables type... (overlays...)
Ogre::SceneManagerEnumerator::SceneManagerIterator iterSceneManager = Ogre::Root::getSingleton().getSceneManagerIterator();
for(;iterSceneManager.hasMoreElements();)
{
Ogre::SceneManager * scMgr = iterSceneManager.getNext();
std::vector<std::string>::iterator iterMovableType = allAvailableTypes.begin();
std::vector<std::string>::iterator iterMovableTypeEnd = allAvailableTypes.end();
for(;iterMovableType!=iterMovableTypeEnd;iterMovableType++)
{
Ogre::SceneManager::MovableObjectIterator iterMovable = scMgr->getMovableObjectIterator(*iterMovableType);
for(;iterMovable.hasMoreElements();)
{
Ogre::MovableObject * movable = iterMovable.getNext();
movable->visitRenderables(&lRenderableVisitor,false);
}
}
}
// 3 / visit overlays!
{
Ogre::OverlayManager::OverlayMapIterator iterOverlay = Ogre::OverlayManager::getSingleton().getOverlayIterator();
for(;iterOverlay.hasMoreElements();)
{
Ogre::Overlay* lOverlay = iterOverlay.getNext();
// get the first level of OverlayContainer in the Overlay
Ogre::Overlay::Overlay2DElementsIterator iterOverlayElem = lOverlay->get2DElementsIterator();
for(;iterOverlayElem.hasMoreElements();)
{
Ogre::OverlayContainer * lOverlayCont = iterOverlayElem.getNext();
visitRecursivelyRenderablesFrom(lOverlayCont,lRenderableVisitor, false);
}
}
}
}
示例5: update
//-------------------------------------------------------------------------------
bool CSceneManagerEditor::update(float timePassed)
{
if(mShadowsEnabled->get())
{
Ogre::SceneManager::MovableObjectIterator mit = mHandle->getMovableObjectIterator("Light");
if(!(mit.hasMoreElements()))
mShadowsEnabled->set(false);
}
if(mHandle)
mAmbient->set(mHandle->getAmbientLight());
return false;
}
示例6: updateOGRE
void MainWindow::updateOGRE()
{
QMutexLocker locker(&mutex);
static bool updateGUI=true;
Ogre::Root* mRoot = Ogre::Root::getSingletonPtr();
mRoot->_fireFrameStarted();
// loop through ogre widgets and update animation
QList<OgreWidget*> rendlist = this->findChildren<OgreWidget*>();
foreach (OgreWidget* w, rendlist)
{
// update animation for OgreWidget's sceneManager
if (w->mRenderWindow && w->updatesEnabled())
{
// update OgreWidget
w->update();
//emit w->paintEvent(new QPaintEvent(w->rect()));
for (Ogre::SceneManager::MovableObjectIterator mit = w->getSceneManager()->getMovableObjectIterator("Entity");
mit.hasMoreElements(); mit.moveNext() )
{
Ogre::Entity *entity = static_cast<Ogre::Entity*>(mit.peekNextValue());
if (updateGUI) {
updateGUI = false;
}
// check has skeleton to avoid crash for non animable entities
if (entity->hasSkeleton())
{
for (Ogre::AnimationStateIterator animIt = entity->getAllAnimationStates()->getAnimationStateIterator();
animIt.hasMoreElements(); animIt.moveNext() )
{
Ogre::AnimationState *animState = animIt.peekNextValue();
if ( animState->getEnabled() )
{
//std::cout << entity->getName() << " ZZZZZZZZZZZ " << animState->getAnimationName();
animState->addTime(w->getRenderWindow()->getBestFPS()/10000);
}
}
}
}
}
}
mRoot->_fireFrameRenderingQueued();
mRoot->_fireFrameEnded();
}
示例7: while
void RttManager::CDepthReflectionListener::preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
Hydrax *mHydrax = mRttManager->mHydrax;
mHydrax->getMesh()->getEntity()->setVisible(false);
Ogre::SceneManager::MovableObjectIterator EntityIterator =
mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
Ogre::Entity* CurrentEntity;
unsigned int k;
mMaterials.empty();
while (EntityIterator.hasMoreElements())
{
CurrentEntity = static_cast<Ogre::Entity*>(EntityIterator.peekNextValue());
for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
{
mMaterials.push(CurrentEntity->getSubEntity(k)->getMaterialName());
CurrentEntity->getSubEntity(k)->setMaterialName(mHydrax->getMaterialManager()->getMaterial(MaterialManager::MAT_DEPTH)->getName());
}
EntityIterator.moveNext();
}
mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->translate(0,-mHydrax->getPlanesError(),0);
bool IsInUnderwaterError = false;
if (mHydrax->getCamera()->getDerivedPosition().y > mRttManager->mPlanes[RTT_DEPTH_REFLECTION]->getParentNode()->getPosition().y)
{
mCameraPlaneDiff = 0;
IsInUnderwaterError = true;
}
else
{
mCameraPlaneDiff = 0;
}
mHydrax->getCamera()->enableReflection(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]);
if (!IsInUnderwaterError)
{
mHydrax->getCamera()->enableCustomNearClipPlane(mRttManager->mPlanes[RTT_DEPTH_REFLECTION]);
}
}
示例8: SceneManager
void
Player::stopAnimation(std::string anim)
{
Ogre::SceneManager::MovableObjectIterator iterator = SceneManager()->getMovableObjectIterator("Entity");
while(iterator.hasMoreElements())
{
Ogre::Entity* e = static_cast<Ogre::Entity*>(iterator.getNext());
if (e->hasSkeleton())
{
Ogre::AnimationState *animation = e->getAnimationState(anim);
animation->setEnabled(false);
animation->setTimePosition(0);
}
}
}
示例9: mLightning
MapCameraLightningInstance::MapCameraLightningInstance(MapCameraLightning& lightning)
: mLightning(lightning)
{
Ogre::SceneManager::MovableObjectIterator iterator = lightning.getSceneManager().getMovableObjectIterator(Ogre::LightFactory::FACTORY_TYPE_NAME);
while (iterator.hasMoreElements()) {
Ogre::MovableObject* light = iterator.getNext();
if (light && light != mLightning.getLight()) {
if (light->getVisible()) {
mVisibleLights.push_back(light);
light->setVisible(false);
}
}
}
mLightning.getLight()->setVisible(true);
mAmbientColour = mLightning.getSceneManager().getAmbientLight();
mLightning.getSceneManager().setAmbientLight(mLightning.getLight()->getDiffuseColour());
}
示例10: loop
// Manage physics from this loop
// Please don't alter the Ogre scene manager directly. Instead use the designated methods (setPositionX, setPositionY, setPositionZ, setRoll, setPitch, setYaw, animate)
void loop(Ogre::SceneManager* smgr){
int dir = 1;
int timeStep = 10;
while(true){
// If the message array has any elements, the render loop is applying changes from physics loop
// If so, abort this timestep
if((*::message).size() == 1){
continue;
}
Sleep(timeStep);
Ogre::SceneManager::MovableObjectIterator iterator = smgr->getMovableObjectIterator("Entity");
while(iterator.hasMoreElements()){
// If the message array has any elements, the render loop is applying changes from physics loop
// If so, abort this timestep
if((*::message).size() == 1){
continue;
}
Ogre::Entity* entity = static_cast<Ogre::Entity*>(iterator.getNext());
// <>< <>< Make the cute fishy swim <>< <><
// This only moves fish
if(entity->hasAnimationState("swim")){
Ogre::SceneNode* sceneNode = entity->getParentSceneNode();
// Update position
Ogre::Vector3 pos = sceneNode->getPosition();
if(pos.x > 120){
dir = -1;
setYaw(entity, 180);
}
if(pos.x < -120){
dir = 1;
setYaw(entity, 180);
}
setPositionX(entity, sceneNode->getPosition().x + dir);
animate(entity, "swim");
}
}
}
}
示例11: while
void GodRaysManager::DepthMapListener::postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt)
{
Ogre::SceneManager::MovableObjectIterator EntityIterator = mGodRaysManager->mHydrax->getSceneManager()->getMovableObjectIterator("Entity");
Ogre::Entity * CurrentEntity = NULL;
unsigned int k = 0;
mGodRaysManager->mHydrax->getMesh()->getEntity()->setVisible(true);
while(EntityIterator.hasMoreElements())
{
CurrentEntity = static_cast<Ogre::Entity *>(EntityIterator.peekNextValue());
for(k = 0; k < CurrentEntity->getNumSubEntities(); k++)
{
CurrentEntity->getSubEntity(k)->setMaterialName(mMaterials.front());
mMaterials.pop();
}
EntityIterator.moveNext();
}
}
示例12: preRenderTargetUpdate
void ReflectionTextureListener::preRenderTargetUpdate(const RenderTargetEvent& evt)
{
// Hide plane and objects below the water
mWater->setVisible(false);
/*list<Ogre::Entity*> entList = Level::getSingleton()->getEntityList();
list<Ogre::Entity*>::iterator it;
for (it = entList.begin();it != entList.end();it++){
if ((*it)->isVisible()){
Ogre::AxisAlignedBox box = (*it)->getWorldBoundingBox();
if (box.getMinimum().y < mWater->getSceneNode()->_getDerivedPosition().y){
(*it)->setVisible(false);
belowWaterEnts.push_back((*it));
}
}
}*/
/*std::vector<Entity*>::iterator i, iend;
iend = belowWaterEnts.end();
for (i = belowWaterEnts.begin(); i != iend; ++i)
{
(*i)->setVisible(false);
}*/
Ogre::SceneManager::MovableObjectIterator it = Level::getSingleton()->getSceneManager()->getMovableObjectIterator("Entity");
while(it.hasMoreElements()){
Ogre::MovableObject *m = it.getNext();
if (m->isVisible() && m->getParentSceneNode()->_getDerivedPosition().y < mWater->getSceneNode()->_getDerivedPosition().y){
m->setVisible(false);
belowWaterEnts.push_back(m);
}
}
Ogre::Camera* cam = Level::getSingleton()->getCurrentSegment()->getActiveCamera()->getCamera();
cam->enableReflection(mWater->getReflectionPlane());
}
示例13: diagnose
void OgreInfo::diagnose(std::ostream& outputStream)
{
Ogre::SceneManagerEnumerator::SceneManagerIterator sceneManagerI = Ogre::Root::getSingleton().getSceneManagerIterator();
while (sceneManagerI.hasMoreElements()) {
Ogre::SceneManager* sceneManager = sceneManagerI.getNext();
outputStream << "Scenemanager(" << sceneManager->getTypeName() << ") " << sceneManager->getName() << std::endl;
outputStream << " Number of scene nodes: " << countNodes(sceneManager->getRootSceneNode()) << std::endl;
outputStream << " Movable objects:" << std::endl;
unsigned int movableObjectCounter = 0;
Ogre::Root::MovableObjectFactoryIterator movableObjectFactoryI = Ogre::Root::getSingleton().getMovableObjectFactoryIterator();
while (movableObjectFactoryI.hasMoreElements()) {
Ogre::MovableObjectFactory* factory = movableObjectFactoryI.getNext();
std::string type(factory->getType());
{
Ogre::SceneManager::MovableObjectIterator I = sceneManager->getMovableObjectIterator(type);
while (I.hasMoreElements()) {
movableObjectCounter++;
Ogre::MovableObject* movable = I.getNext();
if (movable->getMovableType() == "Light") {
Ogre::Light* light = static_cast<Ogre::Light*> (movable);
outputStream << " * Light " << light->getName() << "(" << (light->isInScene() ? "in scene" : "not in scene") << ")" << std::endl;
outputStream << " Pos: " << light->getDerivedPosition() << std::endl;
outputStream << " Direction: " << light->getDerivedDirection() << std::endl;
} else {
std::stringstream ssPosAndOrientation;
if (movable->getParentSceneNode() && movable->isInScene()) {
ssPosAndOrientation << " pos: " << movable->getParentSceneNode()->getPosition() << " orientation: " << movable->getParentSceneNode()->getOrientation();
}
outputStream << " * " << type << " " << movable->getName() << "(" << (movable->isInScene() ? "in scene" : "not in scene") << ")" << ssPosAndOrientation.str() << std::endl;
// outputStream << " Pos: " << light->getDerivedPosition() << std::endl;
// outputStream << " Direction: " << light->getDerivedDirection() << std::endl;
}
}
}
}
outputStream << " Number of movable objects: " << movableObjectCounter << std::endl;
outputStream << " Cameras:" << std::endl;
{
Ogre::SceneManager::CameraIterator I = sceneManager->getCameraIterator();
while (I.hasMoreElements()) {
Ogre::Camera* camera = I.getNext();
outputStream << " Camera " << camera->getName() << "(" << (camera->isInScene() ? "in scene" : "not in scene") << ")" << std::endl;
outputStream << " Pos: " << camera->getDerivedPosition() << std::endl;
outputStream << " Direction: " << camera->getDerivedDirection() << std::endl;
outputStream << " Clip distances: " << camera->getNearClipDistance() << " - " << camera->getFarClipDistance() << std::endl;
}
}
}
size_t resourceMemoryUsage = 0;
outputStream << "Resource Managers:" << std::endl;
Ogre::ResourceGroupManager::ResourceManagerIterator I = Ogre::ResourceGroupManager::getSingleton().getResourceManagerIterator();
while (I.hasMoreElements()) {
std::string name = I.peekNextKey();
Ogre::ResourceManager* manager = I.getNext();
outputStream << " Resource Manager: " << name << std::endl;
if (manager->getMemoryBudget() == std::numeric_limits<size_t>::max()) {
outputStream << " Memory budget: not set" << std::endl;
} else {
outputStream << " Memory budget: " << manager->getMemoryBudget() << " bytes" << std::endl;
}
outputStream << " Memory usage: " << manager->getMemoryUsage() << " bytes" << std::endl;
resourceMemoryUsage += manager->getMemoryUsage();
Ogre::ResourceManager::ResourceMapIterator resourceI = manager->getResourceIterator();
if (resourceI.hasMoreElements()) {
outputStream << " Resources: " << std::endl;
int resourceCount = 0;
int loadedResourceCount = 0;
while (resourceI.hasMoreElements()) {
Ogre::ResourcePtr resource = resourceI.getNext();
if (resource->isLoaded()) {
std::string reloadable = resource->isReloadable() ? " reloadable" : "";
outputStream << " " << resource->getName() << " ( " << resource->getSize() << " bytes)" << reloadable;
Ogre::Texture* texture = dynamic_cast<Ogre::Texture*>(resource.get());
if (texture) {
outputStream << texture->getWidth() << "x" << texture->getHeight() << " ";
}
outputStream << std::endl;
loadedResourceCount++;
}
resourceCount++;
}
outputStream << " Total number of resources: " << resourceCount << std::endl;
outputStream << " Number of loaded resources: " << loadedResourceCount << std::endl;
}
}
outputStream << "Total memory usage for all resource manager: " << resourceMemoryUsage << " bytes" << std::endl;
outputStream << std::flush;
}
示例14: outputTextures
bool MiniMapMaker::outputTextures(void)
{
// 如果需要(纹理大小改变了或第一次输出文件时),就重建render texture
if (mNeedRecreate)
{
destroy();
init();
}
mTempOutputFileNames.clear();
static const String TEMP_GROUP_NAME = "#TEMP#";
// 创建临时的资源组
Ogre::ResourceGroupManager& rgm = Ogre::ResourceGroupManager::getSingleton();
rgm.addResourceLocation(mPath, "FileSystem", TEMP_GROUP_NAME, false);
// 合并所有物体的包围盒
Ogre::AxisAlignedBox aabb;
Ogre::SceneManager::MovableObjectIterator itm =
mManipulator->getSceneManager()->getMovableObjectIterator(Ogre::EntityFactory::FACTORY_TYPE_NAME);
while (itm.hasMoreElements())
{
Ogre::MovableObject* movable = itm.getNext();
aabb.merge(movable->getWorldBoundingBox(true));
}
mCamera->setFarClipDistance(mCamera->getNearClipDistance() + 2 * (aabb.getMaximum().y - aabb.getMinimum().y ));
mCamera->setNearClipDistance(mTileSize/2);
// 设置摄像机的高度
Real yPos = mCamera->getNearClipDistance() + aabb.getMaximum().y;
TerrainData* terrainData = mManipulator->getTerrainData();
assert (terrainData);
float terrainHeight = terrainData->mMaxZ - terrainData->mMinZ;
float terrainWidth = terrainData->mMaxX - terrainData->mMinX;
// 投影的真正面积
Real projectSize = 0.0f;
// 最终切割成小块纹理的块数
int xIndex = 0;
int zIndex = 0;
Ogre::Vector3 originPoint(Ogre::Vector3::ZERO);
if (mUseRealCameraAngle)
{
float outerSquareWidth = 0.0f;
float outerSquareHeight = 0.0f;
Ogre::Radian alphaAngle = Ogre::Math::ATan( Ogre::Math::Abs(mMoveZDir.z / mMoveZDir.x) );
switch (mCameraDirQuadrant)
{
case WestNorth :
{
float leftWidth = Ogre::Math::Sin(alphaAngle) * terrainHeight;
float rightWidth = Ogre::Math::Cos(alphaAngle) * terrainWidth;
outerSquareWidth = leftWidth + rightWidth;
float topHeight = Ogre::Math::Cos(alphaAngle) * terrainHeight;
float bottomHeight = Ogre::Math::Sin(alphaAngle) * terrainWidth;
outerSquareHeight = topHeight + bottomHeight;
originPoint = Ogre::Vector3(terrainData->mMinX,0,terrainData->mMinZ) +
(-mMoveZDir * leftWidth);
float projectOffset = yPos / Ogre::Math::Tan(mCamDirAngle);
originPoint.x += (mInvertCameraDir * projectOffset ).x;
originPoint.z += (mInvertCameraDir * projectOffset ).z;
break;
}
case EastNorth :
{
float leftWidth = Ogre::Math::Cos(alphaAngle) * terrainWidth;
float rightWidth = Ogre::Math::Sin(alphaAngle) * terrainHeight;
outerSquareWidth = leftWidth + rightWidth;
float topHeight = Ogre::Math::Cos(alphaAngle) * terrainHeight;
float bottomHeight = Ogre::Math::Sin(alphaAngle) * terrainWidth;
outerSquareHeight = topHeight + bottomHeight;
originPoint = Ogre::Vector3(terrainData->mMaxX,0,terrainData->mMinZ) +
(-mMoveZDir * leftWidth);
float projectOffset = yPos / Ogre::Math::Tan(mCamDirAngle);
originPoint.x += (mInvertCameraDir * projectOffset ).x;
originPoint.z += (mInvertCameraDir * projectOffset ).z;
break;
}
case EastSouth :
//.........这里部分代码省略.........
示例15: renderTextures
void ImpostorTexture::renderTextures(bool force)
{
#ifdef IMPOSTOR_FILE_SAVE
TexturePtr renderTexture;
#else
TexturePtr renderTexture(texture);
//if we're not using a file image we need to set up a resource loader, so that the texture is regenerated if it's ever unloaded (such as switching between fullscreen and the desktop in win32)
loader = std::auto_ptr<ImpostorTextureResourceLoader>(new ImpostorTextureResourceLoader(*this));
#endif
RenderTexture *renderTarget;
Camera *renderCamera;
Viewport *renderViewport;
SceneNode *camNode;
//Set up RTT texture
uint32 textureSize = ImpostorPage::impostorResolution;
if (renderTexture.isNull()) {
renderTexture = TextureManager::getSingleton().createManual(getUniqueID("ImpostorTexture"), "Impostors",
TEX_TYPE_2D, textureSize * IMPOSTOR_YAW_ANGLES, textureSize * IMPOSTOR_PITCH_ANGLES, 0, PF_A8R8G8B8, TU_RENDERTARGET, loader.get());
}
renderTexture->setNumMipmaps(MIP_UNLIMITED);
//Set up render target
renderTarget = renderTexture->getBuffer()->getRenderTarget();
renderTarget->setAutoUpdated(false);
//Set up camera
camNode = sceneMgr->getSceneNode("ImpostorPage::cameraNode");
renderCamera = sceneMgr->createCamera(getUniqueID("ImpostorCam"));
camNode->attachObject(renderCamera);
renderCamera->setLodBias(1000.0f);
renderViewport = renderTarget->addViewport(renderCamera);
renderViewport->setOverlaysEnabled(false);
renderViewport->setClearEveryFrame(true);
renderViewport->setShadowsEnabled(false);
renderViewport->setBackgroundColour(ImpostorPage::impostorBackgroundColor);
//Set up scene node
SceneNode* node = sceneMgr->getSceneNode("ImpostorPage::renderNode");
Ogre::SceneNode* oldSceneNode = entity->getParentSceneNode();
if (oldSceneNode) {
oldSceneNode->detachObject(entity);
}
node->attachObject(entity);
node->setPosition(-entityCenter);
//Set up camera FOV
const Real objDist = entityRadius * 100;
const Real nearDist = objDist - (entityRadius + 1);
const Real farDist = objDist + (entityRadius + 1);
renderCamera->setAspectRatio(1.0f);
renderCamera->setFOVy(Math::ATan(entityDiameter / objDist));
renderCamera->setNearClipDistance(nearDist);
renderCamera->setFarClipDistance(farDist);
//Disable mipmapping (without this, masked textures look bad)
MaterialManager *mm = MaterialManager::getSingletonPtr();
FilterOptions oldMinFilter = mm->getDefaultTextureFiltering(FT_MIN);
FilterOptions oldMagFilter = mm->getDefaultTextureFiltering(FT_MAG);
FilterOptions oldMipFilter = mm->getDefaultTextureFiltering(FT_MIP);
mm->setDefaultTextureFiltering(FO_POINT, FO_LINEAR, FO_NONE);
//Disable fog
FogMode oldFogMode = sceneMgr->getFogMode();
ColourValue oldFogColor = sceneMgr->getFogColour();
Real oldFogDensity = sceneMgr->getFogDensity();
Real oldFogStart = sceneMgr->getFogStart();
Real oldFogEnd = sceneMgr->getFogEnd();
sceneMgr->setFog(Ogre::FOG_EXP2, Ogre::ColourValue(0,0,0,0), 0.0f, 0.0f, 0.0f); //Ember change
//We need to disable all lightning and render it full bright
Ogre::ColourValue oldAmbientColour = sceneMgr->getAmbientLight();
sceneMgr->setAmbientLight(ColourValue::White);
std::vector<Ogre::MovableObject*> lightStore;
Ogre::SceneManager::MovableObjectIterator lightIterator = sceneMgr->getMovableObjectIterator(Ogre::LightFactory::FACTORY_TYPE_NAME);
while (lightIterator.hasMoreElements()) {
Ogre::MovableObject* light = lightIterator.getNext();
if (light) {
if (light->getVisible()) {
lightStore.push_back(light);
light->setVisible(false);
}
}
}
// Get current status of the queue mode
Ogre::SceneManager::SpecialCaseRenderQueueMode OldSpecialCaseRenderQueueMode = sceneMgr->getSpecialCaseRenderQueueMode();
//Only render the entity
sceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE);
sceneMgr->addSpecialCaseRenderQueue(group->geom->getRenderQueue() + 1);
uint8 oldRenderQueueGroup = entity->getRenderQueueGroup();
entity->setRenderQueueGroup(group->geom->getRenderQueue() + 1);
bool oldVisible = entity->getVisible();
entity->setVisible(true);
float oldMaxDistance = entity->getRenderingDistance();
entity->setRenderingDistance(0);
//.........这里部分代码省略.........