| 459 | } |
| 460 | |
| 461 | void Sun::_renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat ) |
| 462 | { |
| 463 | // Calculate Billboard Radius (in world units) to be constant, independent of distance. |
| 464 | // Takes into account distance, viewport size, and specified size in editor |
| 465 | F32 BBRadius = mCoronaWorldRadius; |
| 466 | |
| 467 | mMatrixSet->restoreSceneViewProjection(); |
| 468 | |
| 469 | if ( state->isReflectPass() ) |
| 470 | mMatrixSet->setProjection( state->getSceneManager()->getNonClipProjection() ); |
| 471 | |
| 472 | //mMatrixSet->setWorld( MatrixF::Identity ); |
| 473 | |
| 474 | // Initialize points with basic info |
| 475 | Point3F points[4]; |
| 476 | points[0] = Point3F(-BBRadius, 0.0, -BBRadius); |
| 477 | points[1] = Point3F( -BBRadius, 0.0, BBRadius); |
| 478 | points[2] = Point3F( BBRadius, 0.0, -BBRadius); |
| 479 | points[3] = Point3F(BBRadius, 0.0, BBRadius); |
| 480 | |
| 481 | static const Point2F sCoords[4] = |
| 482 | { |
| 483 | Point2F( 0.0f, 0.0f ), |
| 484 | Point2F( 0.0f, 1.0f ), |
| 485 | Point2F( 1.0f, 0.0f ), |
| 486 | Point2F(1.0f, 1.0f) |
| 487 | }; |
| 488 | |
| 489 | // Get info we need to adjust points |
| 490 | const MatrixF &camView = state->getCameraTransform(); |
| 491 | |
| 492 | // Finalize points |
| 493 | for(S32 i = 0; i < 4; i++) |
| 494 | { |
| 495 | // align with camera |
| 496 | camView.mulV(points[i]); |
| 497 | // offset |
| 498 | points[i] += mLightWorldPos; |
| 499 | } |
| 500 | |
| 501 | LinearColorF vertColor; |
| 502 | if ( mCoronaUseLightColor ) |
| 503 | vertColor = mLightColor; |
| 504 | else |
| 505 | vertColor = mCoronaTint; |
| 506 | |
| 507 | GFXVertexBufferHandle< GFXVertexPCT > vb; |
| 508 | vb.set( GFX, 4, GFXBufferTypeVolatile ); |
| 509 | GFXVertexPCT *pVert = vb.lock(); |
| 510 | if(!pVert) return; |
| 511 | |
| 512 | for ( S32 i = 0; i < 4; i++ ) |
| 513 | { |
| 514 | pVert->color.set( vertColor.toColorI()); |
| 515 | pVert->point.set( points[i] ); |
| 516 | pVert->texCoord.set( sCoords[i].x, sCoords[i].y ); |
| 517 | pVert++; |
| 518 | } |
nothing calls this directly
no test coverage detected