| 106 | } |
| 107 | |
| 108 | void RenderManager::initGameRenderer(GameMap* gameMap) |
| 109 | { |
| 110 | mCreatureTextOverlayDisplayed = false; |
| 111 | |
| 112 | // Create the light which follows the single tile selection mesh |
| 113 | if(mHandLight == nullptr) |
| 114 | { |
| 115 | mHandLight = mSceneManager->createLight("MouseLight"); |
| 116 | mHandLight->setType(Ogre::Light::LT_POINT); |
| 117 | mHandLight->setDiffuseColour(Ogre::ColourValue(0.65, 0.65, 0.45)); |
| 118 | mHandLight->setSpecularColour(Ogre::ColourValue(0.65, 0.65, 0.45)); |
| 119 | mHandLight->setAttenuation(7, 1.0, 0.00, 0.3); |
| 120 | } |
| 121 | |
| 122 | //Add a too small to be visible dummy dirt tile to the hand node |
| 123 | //so that there will always be a dirt tile "visible" |
| 124 | //This is an ugly workaround for issue where destroying some entities messes |
| 125 | //up the lighing for some of the rtshader materials. |
| 126 | const std::string& defaultTileMesh = gameMap->getMeshForDefaultTile(); |
| 127 | if(!mSceneManager->hasEntity(defaultTileMesh + "_dummyEnt")) |
| 128 | { |
| 129 | Ogre::SceneNode* dummyNode = mHandKeeperNode->createChildSceneNode(defaultTileMesh + "_dummyNode"); |
| 130 | dummyNode->setScale(Ogre::Vector3(0.00000001f, 0.00000001f, 0.00000001f)); |
| 131 | Ogre::Entity* dummyEnt = mSceneManager->createEntity(defaultTileMesh + "_dummyEnt", defaultTileMesh); |
| 132 | dummyEnt->setLightMask(0); |
| 133 | dummyEnt->setCastShadows(false); |
| 134 | dummyNode->attachObject(dummyEnt); |
| 135 | mDummyEntities.push_back(dummyNode); |
| 136 | } |
| 137 | |
| 138 | // We load every creature class and attach them to the keeper hand. |
| 139 | // That's an ugly workaround to avoid a crash that occurs when CEGUI refreshes |
| 140 | // ogre open gl renderer after removing some creatures |
| 141 | // Note that from what I've seen, loading only one creature like "Troll.mesh" should be |
| 142 | // enough. However, it doesn't work with other creatures (like "Kobold.mesh"). Since we |
| 143 | // don't really know why, it is safer to load every creature |
| 144 | for(uint32_t i = 0; i < gameMap->numClassDescriptions(); ++i) |
| 145 | { |
| 146 | const CreatureDefinition* def = gameMap->getClassDescription(i); |
| 147 | // We check if the mesh is already loaded. If not, we load it |
| 148 | if(mSceneManager->hasEntity(def->getClassName() + "_dummyEnt")) |
| 149 | continue; |
| 150 | |
| 151 | Ogre::SceneNode* dummyNode = mHandKeeperNode->createChildSceneNode(def->getClassName() + "_dummyNode"); |
| 152 | dummyNode->setScale(Ogre::Vector3(0.00000001f, 0.00000001f, 0.00000001f)); |
| 153 | Ogre::Entity* dummyEnt = mSceneManager->createEntity(def->getClassName() + "_dummyEnt", def->getMeshName()); |
| 154 | dummyEnt->setLightMask(0); |
| 155 | dummyEnt->setCastShadows(false); |
| 156 | dummyNode->attachObject(dummyEnt); |
| 157 | mDummyEntities.push_back(dummyNode); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | void RenderManager::stopGameRenderer(GameMap* gameMap) |
| 162 | { |
no test coverage detected