| 218 | } |
| 219 | |
| 220 | void GuiTerrPreviewCtrl::onRender(Point2I offset, const RectI &updateRect) |
| 221 | { |
| 222 | CameraQuery query; |
| 223 | GameProcessCameraQuery(&query); |
| 224 | Point3F cameraRot; |
| 225 | TerrainBlock *terrBlock = NULL; |
| 226 | |
| 227 | MatrixF matrix = query.cameraMatrix; |
| 228 | matrix.getColumn(3,&cameraRot); // get Camera translation |
| 229 | mCamera.set(cameraRot.x, -cameraRot.y); |
| 230 | matrix.getRow(1,&cameraRot); // get camera rotation |
| 231 | |
| 232 | if (mTerrainEditor != NULL) |
| 233 | terrBlock = mTerrainEditor->getActiveTerrain(); |
| 234 | |
| 235 | if (!terrBlock) |
| 236 | return; |
| 237 | |
| 238 | for(U32 i = 0; i < GFX->getNumSamplers(); i++) |
| 239 | GFX->setTexture(i, NULL); |
| 240 | |
| 241 | GFX->setupGenericShaders(GFXDevice::GSModColorTexture); |
| 242 | |
| 243 | Point2F terrPos(terrBlock->getPosition().x, terrBlock->getPosition().y); |
| 244 | |
| 245 | mTerrainSize = terrBlock->getWorldBlockSize(); |
| 246 | |
| 247 | |
| 248 | //----------------------------------------- RENDER the Terrain Bitmap |
| 249 | if (mTextureHandle) |
| 250 | { |
| 251 | |
| 252 | GFXTextureObject *texture = (GFXTextureObject*)mTextureHandle; |
| 253 | if (texture) |
| 254 | { |
| 255 | //GFX->setLightingEnable(false); |
| 256 | GFX->setStateBlock(mTerrainBitmapStateBlock); |
| 257 | GFX->setTexture(0, texture); |
| 258 | |
| 259 | Point2F screenP1(offset.x - 0.5f, offset.y + 0.5f); |
| 260 | Point2F screenP2(offset.x + getWidth() - 0.5f, offset.y + getWidth() + 0.5f); |
| 261 | Point2F textureP1( worldToTexture( mCamera - terrPos ) - Point2F(0.5f, 0.5f)); |
| 262 | Point2F textureP2(textureP1 + Point2F(1.0f, 1.0f)); |
| 263 | |
| 264 | // the texture if flipped horz to reflect how the terrain is really drawn |
| 265 | PrimBuild::color3f(1.0f, 1.0f, 1.0f); |
| 266 | PrimBuild::begin(GFXTriangleStrip, 4); |
| 267 | PrimBuild::texCoord2f(textureP1.x, textureP1.y); |
| 268 | PrimBuild::vertex2f(screenP1.x, screenP1.y); // left top |
| 269 | |
| 270 | PrimBuild::texCoord2f(textureP2.x, textureP1.y); |
| 271 | PrimBuild::vertex2f(screenP2.x, screenP1.y); // right top |
| 272 | |
| 273 | PrimBuild::texCoord2f(textureP1.x, textureP2.y); |
| 274 | PrimBuild::vertex2f(screenP1.x, screenP2.y); // left bottom |
| 275 | |
| 276 | PrimBuild::texCoord2f(textureP2.x, textureP2.y); |
| 277 | PrimBuild::vertex2f(screenP2.x, screenP2.y); // right bottom |
nothing calls this directly
no test coverage detected