| 361 | } |
| 362 | |
| 363 | void ImposterCapture::begin( TSShapeInstance *shapeInst, |
| 364 | S32 dl, |
| 365 | S32 dim, |
| 366 | F32 radius, |
| 367 | const Point3F ¢er ) |
| 368 | { |
| 369 | mShapeInstance = shapeInst; |
| 370 | mDl = dl; |
| 371 | mDim = dim; |
| 372 | mRadius = radius; |
| 373 | mCenter = center; |
| 374 | |
| 375 | mBlackTex.set( mDim, mDim, GFXFormatR8G8B8A8_SRGB, &GFXRenderTargetSRGBProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ) ); |
| 376 | mWhiteTex.set( mDim, mDim, GFXFormatR8G8B8A8_SRGB, &GFXRenderTargetSRGBProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ) ); |
| 377 | mNormalTex.set( mDim, mDim, GFXFormatR8G8B8A8, &GFXRenderTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ) ); |
| 378 | mDepthBuffer.set( mDim, mDim, GFXFormatD24S8, &GFXZTargetProfile, avar( "%s() - (line %d)", __FUNCTION__, __LINE__ ) ); |
| 379 | |
| 380 | // copy the black render target data into a bitmap |
| 381 | mBlackBmp = new GBitmap; |
| 382 | mBlackBmp->allocateBitmap(mDim, mDim, false, GFXFormatR8G8B8); |
| 383 | |
| 384 | // copy the white target data into a bitmap |
| 385 | mWhiteBmp = new GBitmap; |
| 386 | mWhiteBmp->allocateBitmap(mDim, mDim, false, GFXFormatR8G8B8); |
| 387 | |
| 388 | // Setup viewport and frustrum to do orthographic projection. |
| 389 | RectI viewport( 0, 0, mDim, mDim ); |
| 390 | GFX->setViewport( viewport ); |
| 391 | GFX->setOrtho( -mRadius, mRadius, -mRadius, mRadius, 1, 20.0f * mRadius ); |
| 392 | |
| 393 | // Position camera looking out the X axis. |
| 394 | MatrixF cameraMatrix( true ); |
| 395 | cameraMatrix.setColumn( 0, Point3F( 0, 0, 1 ) ); |
| 396 | cameraMatrix.setColumn( 1, Point3F( 1, 0, 0 ) ); |
| 397 | cameraMatrix.setColumn( 2, Point3F( 0, 1, 0 ) ); |
| 398 | |
| 399 | // setup scene state required for TS mesh render...this is messy and inefficient; |
| 400 | // should have a mode where most of this is done just once (and then |
| 401 | // only the camera matrix changes between snapshots). |
| 402 | // note that we use getFrustum here, but we set up an ortho projection above. |
| 403 | // it doesn't seem like the scene state object pays attention to whether the projection is |
| 404 | // ortho or not. this could become a problem if some code downstream tries to |
| 405 | // reconstruct the projection matrix using the dimensions and doesn't |
| 406 | // realize it should be ortho. at the moment no code is doing that. |
| 407 | F32 left, right, top, bottom, nearPlane, farPlane; |
| 408 | bool isOrtho; |
| 409 | GFX->getFrustum( &left, &right, &bottom, &top, &nearPlane, &farPlane, &isOrtho ); |
| 410 | Frustum frust( isOrtho, left, right, top, bottom, nearPlane, farPlane, cameraMatrix ); |
| 411 | |
| 412 | // Set up render pass. |
| 413 | |
| 414 | mRenderPass = new RenderPassManager(); |
| 415 | mRenderPass->assignName( "DiffuseRenderPass" ); |
| 416 | mMeshRenderBin = new RenderMeshMgr(); |
| 417 | mRenderPass->addManager( mMeshRenderBin ); |
| 418 | |
| 419 | // Set up scene state. |
| 420 |
no test coverage detected