| 263 | } |
| 264 | |
| 265 | void RenderMeshExample::prepRenderImage( SceneRenderState *state ) |
| 266 | { |
| 267 | // Do a little prep work if needed |
| 268 | if ( mVertexBuffer.isNull() ) |
| 269 | createGeometry(); |
| 270 | |
| 271 | // If we have no material then skip out. |
| 272 | if ( !mMaterialInst || !state) |
| 273 | return; |
| 274 | |
| 275 | // If we don't have a material instance after the override then |
| 276 | // we can skip rendering all together. |
| 277 | BaseMatInstance *matInst = state->getOverrideMaterial( mMaterialInst ); |
| 278 | if ( !matInst ) |
| 279 | return; |
| 280 | |
| 281 | // Get a handy pointer to our RenderPassmanager |
| 282 | RenderPassManager *renderPass = state->getRenderPass(); |
| 283 | |
| 284 | // Allocate an MeshRenderInst so that we can submit it to the RenderPassManager |
| 285 | MeshRenderInst *ri = renderPass->allocInst<MeshRenderInst>(); |
| 286 | |
| 287 | // Set our RenderInst as a standard mesh render |
| 288 | ri->type = RenderPassManager::RIT_Mesh; |
| 289 | |
| 290 | //If our material has transparency set on this will redirect it to proper render bin |
| 291 | if ( matInst->getMaterial()->isTranslucent() ) |
| 292 | { |
| 293 | ri->type = RenderPassManager::RIT_Translucent; |
| 294 | ri->translucentSort = true; |
| 295 | } |
| 296 | |
| 297 | // Calculate our sorting point |
| 298 | if ( state ) |
| 299 | { |
| 300 | // Calculate our sort point manually. |
| 301 | const Box3F& rBox = getRenderWorldBox(); |
| 302 | ri->sortDistSq = rBox.getSqDistanceToPoint( state->getCameraPosition() ); |
| 303 | } |
| 304 | else |
| 305 | ri->sortDistSq = 0.0f; |
| 306 | |
| 307 | // Set up our transforms |
| 308 | MatrixF objectToWorld = getRenderTransform(); |
| 309 | objectToWorld.scale( getScale() ); |
| 310 | |
| 311 | ri->objectToWorld = renderPass->allocUniqueXform( objectToWorld ); |
| 312 | ri->worldToCamera = renderPass->allocSharedXform(RenderPassManager::View); |
| 313 | ri->projection = renderPass->allocSharedXform(RenderPassManager::Projection); |
| 314 | |
| 315 | // If our material needs lights then fill the RIs |
| 316 | // light vector with the best lights. |
| 317 | if ( matInst->isForwardLit() ) |
| 318 | { |
| 319 | LightQuery query; |
| 320 | query.init( getWorldSphere() ); |
| 321 | query.getLights( ri->lights, 8 ); |
| 322 | } |
nothing calls this directly
no test coverage detected