MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / MiniMapCamera

Method MiniMapCamera

source/gamemap/MiniMapCamera.cpp:56–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54static const Ogre::Real MIN_TIME_REFRESH_SECS = 0.5;
55
56MiniMapCamera::MiniMapCamera(CEGUI::Window* miniMapWindow) :
57 mMiniMapWindow(miniMapWindow),
58 mGameMap(*ODFrameListener::getSingleton().getClientGameMap()),
59 mCameraManager(*ODFrameListener::getSingleton().getCameraManager()),
60 mTopLeftCornerX(0),
61 mTopLeftCornerY(0),
62 mWidth(0),
63 mHeight(0),
64 mMapX(mGameMap.getMapSizeX()),
65 mMapY(mGameMap.getMapSizeY()),
66 mElapsedTime(MIN_TIME_REFRESH_SECS),
67 mMiniMapOgreTexture(Ogre::TextureManager::getSingletonPtr()->createManual(
68 "miniMapOgreTexture",
69 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
70 Ogre::TEX_TYPE_2D,
71 TEXTURE_SIZE, TEXTURE_SIZE, 0, Ogre::PF_R8G8B8,
72 Ogre::TU_RENDERTARGET)),
73 mCurCamPosX(-1),
74 mCurCamPosY(-1),
75 mMiniMapCam(RenderManager::getSingleton().getSceneManager()->createCamera("miniMapCam")),
76 mCullingManager(new CullingManager(&mGameMap, CullingType::SHOW_MINIMAP)),
77 mCameraTilesIntersections(std::vector<Ogre::Vector3>(4, Ogre::Vector3::ZERO))
78{
79 // We create a special camera that will look at the whole scene and render it in the minimap
80 mMiniMapCam->setNearClipDistance(0.02);
81 mMiniMapCam->setFarClipDistance(300.0);
82 mMiniMapCam->setFOVy(ANGLE_CAM);
83
84 Ogre::RenderTarget* rt = mMiniMapOgreTexture->getBuffer()->getRenderTarget();
85 rt->addListener(this);
86 rt->setAutoUpdated(false);
87 mMiniMapCam->setAspectRatio(1.0);
88 Ogre::Viewport* vp = rt->addViewport(mMiniMapCam);
89 vp->setClearEveryFrame(true);
90 vp->setOverlaysEnabled(false);
91 vp->setBackgroundColour(Ogre::ColourValue::Black);
92
93 CEGUI::Texture& miniMapTextureGui = static_cast<CEGUI::OgreRenderer*>(CEGUI::System::getSingletonPtr()
94 ->getRenderer())->createTexture("miniMapTextureGui", mMiniMapOgreTexture);
95
96 CEGUI::BasicImage& imageset = dynamic_cast<CEGUI::BasicImage&>(CEGUI::ImageManager::getSingletonPtr()->create("BasicImage", "MiniMapImageset"));
97 imageset.setArea(CEGUI::Rectf(CEGUI::Vector2f(0.0, 0.0),
98 CEGUI::Size<float>(static_cast<float>(TEXTURE_SIZE), static_cast<float>(TEXTURE_SIZE))));
99
100 // Link the image to the minimap
101 imageset.setTexture(&miniMapTextureGui);
102 mMiniMapWindow->setProperty("Image", CEGUI::PropertyHelper<CEGUI::Image*>::toString(&imageset));
103
104 mTopLeftCornerX = mMiniMapWindow->getUnclippedOuterRect().get().getPosition().d_x;
105 mTopLeftCornerY = mMiniMapWindow->getUnclippedOuterRect().get().getPosition().d_y;
106 mWidth = mMiniMapWindow->getUnclippedOuterRect().get().getSize().d_width;
107 mHeight = mMiniMapWindow->getUnclippedOuterRect().get().getSize().d_height;
108
109 updateMinimapCamera();
110 mCullingManager->computeIntersectionPoints(mMiniMapCam, mCameraTilesIntersections);
111 mCullingManager->startTileCulling(mMiniMapCam, mCameraTilesIntersections);
112}
113

Callers

nothing calls this directly

Calls 9

getClientGameMapMethod · 0.80
getCameraManagerMethod · 0.80
getMapSizeXMethod · 0.80
getMapSizeYMethod · 0.80
createCameraMethod · 0.80
getSceneManagerMethod · 0.80
startTileCullingMethod · 0.80
toStringFunction · 0.50

Tested by

no test coverage detected