| 110 | } |
| 111 | |
| 112 | void MiniMapDrawn::update(Ogre::Real timeSinceLastFrame, const std::vector<Ogre::Vector3>& cornerTiles) |
| 113 | { |
| 114 | Ogre::Vector3 vv = mCameraManager.getCameraViewTarget(); |
| 115 | double rotation = mCameraManager.getActiveCameraNode()->getOrientation().getRoll().valueRadians(); |
| 116 | mCamera_2dPosition = Ogre::Vector2(vv.x, vv.y); |
| 117 | mCosRotation = cos(rotation); |
| 118 | mSinRotation = sin(rotation); |
| 119 | |
| 120 | for (int ii = 0, mm = mCamera_2dPosition.x - mWidth / (2 * mGrainSize); ii < static_cast<int>(mWidth); ++mm, ii += mGrainSize) |
| 121 | { |
| 122 | //NOTE: (0,0) is in the bottom left in the game map, top left in textures, so we are reversing y order here. |
| 123 | for (int jj = static_cast<int>(mHeight) - static_cast<int>(mGrainSize), nn = mCamera_2dPosition.y - mHeight / (2 * mGrainSize); |
| 124 | jj >= 0; ++nn, jj -= mGrainSize) |
| 125 | { |
| 126 | // Applying rotation |
| 127 | int oo = mCamera_2dPosition.x + static_cast<int>((mm - mCamera_2dPosition.x) * mCosRotation - (nn - mCamera_2dPosition.y) * mSinRotation); |
| 128 | int pp = mCamera_2dPosition.y + static_cast<int>((mm - mCamera_2dPosition.x) * mSinRotation + (nn - mCamera_2dPosition.y) * mCosRotation); |
| 129 | |
| 130 | /*FIXME: even if we use a THREE byte pixel format (PF_R8G8B8), |
| 131 | * for some reason it only works if we have FOUR increments |
| 132 | * (the empty one is the unused alpha channel) |
| 133 | * this is not how it is intended/expected |
| 134 | */ |
| 135 | Tile* tile = mGameMap.getTile(oo, pp); |
| 136 | if(tile == nullptr) |
| 137 | { |
| 138 | drawPixel(ii, jj, 0x00, 0x00, 0x00); |
| 139 | continue; |
| 140 | } |
| 141 | |
| 142 | if (tile->getMarkedForDigging(mGameMap.getLocalPlayer())) |
| 143 | { |
| 144 | drawPixel(ii, jj, 0xFF, 0xA8, 0x00); |
| 145 | continue; |
| 146 | } |
| 147 | |
| 148 | switch (tile->getTileVisual()) |
| 149 | { |
| 150 | case TileVisual::claimedGround: |
| 151 | { |
| 152 | Seat* tempSeat = tile->getSeat(); |
| 153 | if (tempSeat != nullptr) |
| 154 | { |
| 155 | Ogre::ColourValue color = tempSeat->getColorValue(); |
| 156 | drawPixel(ii, jj, color.r*200.0, color.g*200.0, color.b*200.0); |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | drawPixel(ii, jj, 0x5C, 0x37, 0x1B); |
| 161 | } |
| 162 | break; |
| 163 | } |
| 164 | |
| 165 | case TileVisual::claimedFull: |
| 166 | { |
| 167 | Seat* tempSeat = tile->getSeat(); |
| 168 | if (tempSeat != nullptr) |
| 169 | { |
no test coverage detected