| 284 | } |
| 285 | |
| 286 | void CoverPoint::render(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat) |
| 287 | { |
| 288 | initGFXResources(); |
| 289 | |
| 290 | if(overrideMat) |
| 291 | return; |
| 292 | |
| 293 | if(smVertexBuffer[mSize].isNull()) |
| 294 | return; |
| 295 | |
| 296 | PROFILE_SCOPE(CoverPoint_Render); |
| 297 | |
| 298 | // Set up a GFX debug event (this helps with debugging rendering events in external tools) |
| 299 | GFXDEBUGEVENT_SCOPE(CoverPoint_Render, ColorI::RED); |
| 300 | |
| 301 | // GFXTransformSaver is a handy helper class that restores |
| 302 | // the current GFX matrices to their original values when |
| 303 | // it goes out of scope at the end of the function |
| 304 | GFXTransformSaver saver; |
| 305 | |
| 306 | // Calculate our object to world transform matrix |
| 307 | MatrixF objectToWorld = getRenderTransform(); |
| 308 | objectToWorld.scale(getScale()); |
| 309 | |
| 310 | // Apply our object transform |
| 311 | GFX->multWorld(objectToWorld); |
| 312 | |
| 313 | // Set the state block |
| 314 | GFX->setStateBlock(smNormalSB); |
| 315 | |
| 316 | // Set up the "generic" shaders |
| 317 | // These handle rendering on GFX layers that don't support |
| 318 | // fixed function. Otherwise they disable shaders. |
| 319 | GFX->setupGenericShaders(GFXDevice::GSModColorTexture); |
| 320 | |
| 321 | // Set the vertex buffer |
| 322 | GFX->setVertexBuffer(smVertexBuffer[mSize]); |
| 323 | |
| 324 | // Draw our triangles |
| 325 | GFX->drawPrimitive(GFXTriangleList, 0, 2); |
| 326 | |
| 327 | // Data for decorations. |
| 328 | GFXStateBlockDesc desc; |
| 329 | F32 height = (float)(mSize + 1) / NumSizes * 2.0f; |
| 330 | |
| 331 | // Draw an X if we're occupied. |
| 332 | if(isOccupied()) |
| 333 | { |
| 334 | GFX->getDrawUtil()->drawArrow(desc, Point3F(-0.5, 0, 0), Point3F(0.5, 0, height), ColorI::RED); |
| 335 | GFX->getDrawUtil()->drawArrow(desc, Point3F(0.5, 0, 0), Point3F(-0.5, 0, height), ColorI::RED); |
| 336 | } |
| 337 | |
| 338 | // Draw arrows to represent peek directions. |
| 339 | if(peekLeft()) |
| 340 | GFX->getDrawUtil()->drawArrow(desc, Point3F(0, 0, height * 0.5), Point3F(-0.5, 0, height * 0.5), ColorI::GREEN); |
| 341 | if(peekRight()) |
| 342 | GFX->getDrawUtil()->drawArrow(desc, Point3F(0, 0, height * 0.5), Point3F(0.5, 0, height * 0.5), ColorI::GREEN); |
| 343 | if(peekOver()) |
nothing calls this directly
no test coverage detected