本文整理汇总了C++中TSRenderState类的典型用法代码示例。如果您正苦于以下问题:C++ TSRenderState类的具体用法?C++ TSRenderState怎么用?C++ TSRenderState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TSRenderState类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: render
void TSShapeInstance::render( const TSRenderState &rdata, S32 dl, F32 intraDL )
{
AssertFatal( dl >= 0 && dl < mShape->details.size(),"TSShapeInstance::render" );
S32 i;
const TSDetail * detail = &mShape->details[dl];
S32 ss = detail->subShapeNum;
S32 od = detail->objectDetailNum;
// if we're a billboard detail, draw it and exit
if ( ss < 0 )
{
PROFILE_SCOPE( TSShapeInstance_RenderBillboards );
if ( !rdata.isNoRenderTranslucent() && ( TSLastDetail::smCanShadow || !rdata.getSceneState()->isShadowPass() ) )
mShape->billboardDetails[ dl ]->render( rdata, mAlphaAlways ? mAlphaAlwaysValue : 1.0f );
return;
}
// run through the meshes
S32 start = rdata.isNoRenderNonTranslucent() ? mShape->subShapeFirstTranslucentObject[ss] : mShape->subShapeFirstObject[ss];
S32 end = rdata.isNoRenderTranslucent() ? mShape->subShapeFirstTranslucentObject[ss] : mShape->subShapeFirstObject[ss] + mShape->subShapeNumObjects[ss];
for (i=start; i<end; i++)
{
// following line is handy for debugging, to see what part of the shape that it is rendering
// const char *name = mShape->names[ mMeshObjects[i].object->nameIndex ];
mMeshObjects[i].render( od, mMaterialList, rdata, mAlphaAlways ? mAlphaAlwaysValue : 1.0f );
}
}
开发者ID:mray,项目名称:terminal-overload,代码行数:31,代码来源:tsShapeInstance.cpp
示例2: prepBatchRender
void Projectile::prepBatchRender( SceneRenderState *state )
{
if ( !mProjectileShape )
return;
GFXTransformSaver saver;
// Set up our TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init( getWorldSphere() );
rdata.setLightQuery( &query );
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
mat.scale( mDataBlock->scale );
GFX->setWorldMatrix( mat );
mProjectileShape->setDetailFromPosAndScale( state, mat.getPosition(), mObjScale );
mProjectileShape->animate();
mProjectileShape->render( rdata );
}
开发者ID:AlkexGas,项目名称:Torque3D,代码行数:27,代码来源:projectile.cpp
示例3: render
void TSLastDetail::render( TSRenderState &rdata, F32 alpha )
{
#if 0
// Early out if we have nothing to render.
if ( alpha < 0.01f ||
!mMatInstance ||
mMaterial->mImposterUVs.size() == 0 )
return;
const MatrixF &mat = GFX->getWorldMatrix();
// Post a render instance for this imposter... the special
// imposter render manager will do the magic!
RenderPassManager *renderPass = rdata.getSceneState()->getRenderPass();
ImposterRenderInst *ri = renderPass->allocInst<ImposterRenderInst>();
ri->mat = rdata.getSceneState()->getOverrideMaterial( mMatInstance );
ri->state.alpha = alpha;
// Store the up and right vectors of the rotation
// and we'll generate the up vector in the shader.
//
// This is faster than building a quat on the
// CPU and then rebuilding the matrix on the GPU.
//
// NOTE: These vector include scale.
//
mat.getColumn( 2, &ri->state.upVec );
mat.getColumn( 0, &ri->state.rightVec );
// We send the unscaled size and the vertex shader
// will use the orientation vectors above to scale it.
ri->state.halfSize = mRadius;
// We use the center of the object bounds for
// the center of the billboard quad.
mat.mulP( mCenter, &ri->state.center );
// We sort by the imposter type first so that RIT_Imposter and s
// RIT_ImposterBatches do not get mixed together.
//
// We then sort by material.
//
ri->defaultKey = 1;
ri->defaultKey2 = ri->mat->getStateHint();
renderPass->addInst( ri );
#endif
}
开发者ID:jamesu,项目名称:libDTShape,代码行数:50,代码来源:tsLastDetail.cpp
示例4: box
void TSShapeInstance::MeshObjectInstance::render( S32 objectDetail,
TSMaterialList *materials,
const TSRenderState &rdata,
F32 alpha )
{
PROFILE_SCOPE( TSShapeInstance_MeshObjectInstance_render );
if ( forceHidden || ( ( visible * alpha ) <= 0.01f ) )
return;
TSMesh *mesh = getMesh(objectDetail);
if ( !mesh )
return;
const MatrixF &transform = getTransform();
if ( rdata.getCuller() )
{
Box3F box( mesh->getBounds() );
transform.mul( box );
if ( rdata.getCuller()->isCulled( box ) )
return;
}
GFX->pushWorldMatrix();
GFX->multWorld( transform );
mesh->setFade( visible * alpha );
// Pass a hint to the mesh that time has advanced and that the
// skin is dirty and needs to be updated. This should result
// in the skin only updating once per frame in most cases.
const U32 currTime = Sim::getCurrentTime();
bool isSkinDirty = currTime != mLastTime;
mesh->render( materials,
rdata,
isSkinDirty,
*mTransforms,
mVertexBuffer,
mPrimitiveBuffer );
// Update the last render time.
mLastTime = currTime;
GFX->popWorldMatrix();
}
开发者ID:mray,项目名称:terminal-overload,代码行数:47,代码来源:tsShapeInstance.cpp
示例5: renderObject
void PxSingleActor::renderObject(SceneState* state)
{
GFXTransformSaver saver;
// Set up our TS render state here.
TSRenderState rdata;
rdata.setSceneState( state );
//rdata.setObjScale( &getScale() );
LightManager *lm = gClientSceneGraph->getLightManager();
if ( !state->isShadowPass() )
lm->setupLights( this, getWorldSphere() );
MatrixF mat = getTransform();
mat.scale( getScale() );
GFX->setWorldMatrix( mat );
mShapeInstance->animate();
mShapeInstance->render( rdata );
lm->resetLights();
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:22,代码来源:pxSingleActor.cpp
示例6: prepBatchRender
void Projectile::prepBatchRender( SceneState *state )
{
GFXTransformSaver saver;
// Set up our TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
mat.scale( mDataBlock->scale );
GFX->setWorldMatrix( mat );
if(mProjectileShape)
{
AssertFatal(mProjectileShape != NULL,
"Projectile::renderObject: Error, projectile shape should always be present in renderObject");
mProjectileShape->setDetailFromPosAndScale( state, mat.getPosition(), mObjScale );
mProjectileShape->animate();
mProjectileShape->render( rdata );
}
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:23,代码来源:projectile.cpp
示例7: getRenderTransform
void TSStatic::prepRenderImage( SceneRenderState* state )
{
if( !mShapeInstance )
return;
Point3F cameraOffset;
getRenderTransform().getColumn(3,&cameraOffset);
cameraOffset -= state->getDiffuseCameraPosition();
F32 dist = cameraOffset.len();
if (dist < 0.01f)
dist = 0.01f;
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
if ( mForceDetail == -1 )
mShapeInstance->setDetailFromDistance( state, dist * invScale );
else
mShapeInstance->setCurrentDetail( mForceDetail );
if ( mShapeInstance->getCurrentDetail() < 0 )
return;
GFXTransformSaver saver;
// Set up our TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
rdata.setFadeOverride( 1.0f );
rdata.setOriginSort( mUseOriginSort );
// If we have submesh culling enabled then prepare
// the object space frustum to pass to the shape.
Frustum culler;
if ( mMeshCulling )
{
culler = state->getCullingFrustum();
MatrixF xfm( true );
xfm.scale( Point3F::One / getScale() );
xfm.mul( getRenderWorldTransform() );
xfm.mul( culler.getTransform() );
culler.setTransform( xfm );
rdata.setCuller( &culler );
}
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init( getWorldSphere() );
rdata.setLightQuery( &query );
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
GFX->setWorldMatrix( mat );
mShapeInstance->animate();
mShapeInstance->render( rdata );
if ( mRenderNormalScalar > 0 )
{
ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
ri->renderDelegate.bind( this, &TSStatic::_renderNormals );
ri->type = RenderPassManager::RIT_Editor;
state->getRenderPass()->addInst( ri );
}
}
开发者ID:mray,项目名称:terminal-overload,代码行数:65,代码来源:tsStatic.cpp
示例8: getRenderTransform
void TSStatic::prepRenderImage( SceneRenderState* state )
{
if( !mShapeInstance )
return;
//WLE - Vince
//Lod preloading
GameConnection* connection = GameConnection::getConnectionToServer();
if (connection && !connection->didFirstRender)
{
TSRenderState rdata;
rdata.setSceneState( state );
rdata.setFadeOverride( 1.0f );
rdata.setOriginSort( mUseOriginSort );
for (S32 i = mShapeInstance->getSmallestVisibleDL(); i >= 0; i-- )
{
mShapeInstance->setCurrentDetail( i );
mShapeInstance->render( rdata );
}
}
Point3F cameraOffset;
getRenderTransform().getColumn(3,&cameraOffset);
cameraOffset -= state->getDiffuseCameraPosition();
F32 dist = cameraOffset.len();
if (dist < 0.01f)
dist = 0.01f;
if (mUseAlphaLod)
{
mAlphaLOD = 1.0f;
if ((mAlphaLODStart < mAlphaLODEnd) && mAlphaLODStart > 0.1f)
{
if (mInvertAlphaLod)
{
if (dist <= mAlphaLODStart)
{
return;
}
if (dist < mAlphaLODEnd)
{
mAlphaLOD = ((dist - mAlphaLODStart) / (mAlphaLODEnd - mAlphaLODStart));
}
}
else
{
if (dist >= mAlphaLODEnd)
{
return;
}
if (dist > mAlphaLODStart)
{
mAlphaLOD -= ((dist - mAlphaLODStart) / (mAlphaLODEnd - mAlphaLODStart));
}
}
}
}
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
if ( mForceDetail == -1 )
mShapeInstance->setDetailFromDistance( state, dist * invScale );
else
mShapeInstance->setCurrentDetail( mForceDetail );
if ( mShapeInstance->getCurrentDetail() < 0 )
return;
GFXTransformSaver saver;
// Set up our TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
rdata.setFadeOverride( 1.0f );
rdata.setOriginSort( mUseOriginSort );
// If we have submesh culling enabled then prepare
// the object space frustum to pass to the shape.
Frustum culler;
if ( mMeshCulling )
{
culler = state->getCullingFrustum();
MatrixF xfm( true );
xfm.scale( Point3F::One / getScale() );
xfm.mul( getRenderWorldTransform() );
xfm.mul( culler.getTransform() );
culler.setTransform( xfm );
rdata.setCuller( &culler );
}
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init( getWorldSphere() );
rdata.setLightQuery( &query );
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
//.........这里部分代码省略.........
开发者ID:Dwarf-King,项目名称:OmniEngine.Net,代码行数:101,代码来源:tsStatic.cpp
示例9: frust
void GuiObjectView::renderWorld( const RectI& updateRect )
{
if( !mModel )
return;
GFXTransformSaver _saveTransforms;
// Determine the camera position, and store off render state.
MatrixF modelview;
MatrixF mv;
Point3F cp;
modelview = GFX->getWorldMatrix();
mv = modelview;
mv.inverse();
mv.getColumn( 3, &cp );
RenderPassManager* renderPass = gClientSceneGraph->getDefaultRenderPass();
S32 time = Platform::getVirtualMilliseconds();
S32 dt = time - mLastRenderTime;
mLastRenderTime = time;
LIGHTMGR->unregisterAllLights();
LIGHTMGR->setSpecialLight( LightManager::slSunLightType, mLight );
GFX->setStateBlock( mDefaultGuiSB );
F32 left, right, top, bottom, nearPlane, farPlane;
bool isOrtho;
GFX->getFrustum( &left, &right, &bottom, &top, &nearPlane, &farPlane, &isOrtho );
Frustum frust( false, left, right, top, bottom, nearPlane, farPlane, MatrixF::Identity );
SceneRenderState state
(
gClientSceneGraph,
SPT_Diffuse,
SceneCameraState( GFX->getViewport(), frust, GFX->getWorldMatrix(), GFX->getProjectionMatrix() ),
renderPass,
false
);
// Set up our TS render state here.
TSRenderState rdata;
rdata.setSceneState( &state );
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init( SphereF( Point3F::Zero, 1.0f ) );
rdata.setLightQuery( &query );
// Render primary model.
if( mModel )
{
if( mRunThread )
{
mModel->advanceTime( dt / 1000.f, mRunThread );
mModel->animate();
}
mModel->render( rdata );
}
// Render mounted model.
if( mMountedModel && mMountNode != -1 )
{
GFX->pushWorldMatrix();
GFX->multWorld( mModel->mNodeTransforms[ mMountNode ] );
GFX->multWorld( mMountTransform );
mMountedModel->render( rdata );
GFX->popWorldMatrix();
}
renderPass->renderPass( &state );
// Make sure to remove our fake sun.
LIGHTMGR->unregisterAllLights();
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:86,代码来源:guiObjectView.cpp
示例10: getRenderTransform
void TSStatic::prepRenderImage( SceneRenderState* state )
{
if( !mShapeInstance )
return;
Point3F cameraOffset;
getRenderTransform().getColumn(3,&cameraOffset);
cameraOffset -= state->getDiffuseCameraPosition();
F32 dist = cameraOffset.len();
if (dist < 0.01f)
dist = 0.01f;
if (mUseAlphaFade)
{
mAlphaFade = 1.0f;
if ((mAlphaFadeStart < mAlphaFadeEnd) && mAlphaFadeStart > 0.1f)
{
if (mInvertAlphaFade)
{
if (dist <= mAlphaFadeStart)
{
return;
}
if (dist < mAlphaFadeEnd)
{
mAlphaFade = ((dist - mAlphaFadeStart) / (mAlphaFadeEnd - mAlphaFadeStart));
}
}
else
{
if (dist >= mAlphaFadeEnd)
{
return;
}
if (dist > mAlphaFadeStart)
{
mAlphaFade -= ((dist - mAlphaFadeStart) / (mAlphaFadeEnd - mAlphaFadeStart));
}
}
}
}
F32 invScale = (1.0f/getMax(getMax(mObjScale.x,mObjScale.y),mObjScale.z));
// If we're currently rendering our own reflection we
// don't want to render ourselves into it.
if ( mCubeReflector.isRendering() )
return;
if ( mForceDetail == -1 )
mShapeInstance->setDetailFromDistance( state, dist * invScale );
else
mShapeInstance->setCurrentDetail( mForceDetail );
if ( mShapeInstance->getCurrentDetail() < 0 )
return;
GFXTransformSaver saver;
// Set up our TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
rdata.setFadeOverride( 1.0f );
rdata.setOriginSort( mUseOriginSort );
if ( mCubeReflector.isEnabled() )
rdata.setCubemap( mCubeReflector.getCubemap() );
// Acculumation
rdata.setAccuTex(mAccuTex);
// If we have submesh culling enabled then prepare
// the object space frustum to pass to the shape.
Frustum culler;
if ( mMeshCulling )
{
culler = state->getCullingFrustum();
MatrixF xfm( true );
xfm.scale( Point3F::One / getScale() );
xfm.mul( getRenderWorldTransform() );
xfm.mul( culler.getTransform() );
culler.setTransform( xfm );
rdata.setCuller( &culler );
}
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init( getWorldSphere() );
rdata.setLightQuery( &query );
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
GFX->setWorldMatrix( mat );
if ( state->isDiffusePass() && mCubeReflector.isEnabled() && mCubeReflector.getOcclusionQuery() )
{
RenderPassManager *pass = state->getRenderPass();
OccluderRenderInst *ri = pass->allocInst<OccluderRenderInst>();
//.........这里部分代码省略.........
开发者ID:elfprince13,项目名称:Torque3D,代码行数:101,代码来源:tsStatic.cpp
示例11: frust
void GuiMaterialPreview::renderWorld(const RectI &updateRect)
{
// nothing to render, punt
if ( !mModel && !mMountedModel )
return;
S32 time = Platform::getVirtualMilliseconds();
//S32 dt = time - lastRenderTime;
lastRenderTime = time;
F32 left, right, top, bottom, nearPlane, farPlane;
bool isOrtho;
GFX->getFrustum( &left, &right, &bottom, &top, &nearPlane, &farPlane, &isOrtho);
Frustum frust( isOrtho, left, right, bottom, top, nearPlane, farPlane, MatrixF::Identity );
FogData savedFogData = gClientSceneGraph->getFogData();
gClientSceneGraph->setFogData( FogData() ); // no fog in preview window
RenderPassManager* renderPass = gClientSceneGraph->getDefaultRenderPass();
SceneRenderState state
(
gClientSceneGraph,
SPT_Diffuse,
SceneCameraState( GFX->getViewport(), frust, GFX->getWorldMatrix(), GFX->getProjectionMatrix() ),
renderPass,
true
);
// Set up our TS render state here.
TSRenderState rdata;
rdata.setSceneState( &state );
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init( SphereF( Point3F::Zero, 1.0f ) );
rdata.setLightQuery( &query );
// Set up pass transforms
renderPass->assignSharedXform(RenderPassManager::View, MatrixF::Identity);
renderPass->assignSharedXform(RenderPassManager::Projection, GFX->getProjectionMatrix());
LIGHTMGR->unregisterAllLights();
LIGHTMGR->setSpecialLight( LightManager::slSunLightType, mFakeSun );
if ( mModel )
mModel->render( rdata );
if ( mMountedModel )
{
// render a weapon
/*
MatrixF mat;
GFX->pushWorldMatrix();
GFX->multWorld( mat );
GFX->popWorldMatrix();
*/
}
renderPass->renderPass( &state );
gClientSceneGraph->setFogData( savedFogData ); // restore fog setting
// Make sure to remove our fake sun
LIGHTMGR->unregisterAllLights();
}
开发者ID:Azaezel,项目名称:Torque3D,代码行数:70,代码来源:guiMaterialPreview.cpp
示例12: _renderToTexture
void ProjectedShadow::_renderToTexture( F32 camDist, const TSRenderState &rdata )
{
PROFILE_SCOPE( ProjectedShadow_RenderToTexture );
GFXDEBUGEVENT_SCOPE( ProjectedShadow_RenderToTexture, ColorI( 255, 0, 0 ) );
RenderPassManager *renderPass = _getRenderPass();
if ( !renderPass )
return;
GFXTransformSaver saver;
// NOTE: GFXTransformSaver does not save/restore the frustum
// so we must save it here before we modify it.
F32 l, r, b, t, n, f;
bool ortho;
GFX->getFrustum( &l, &r, &b, &t, &n, &f, &ortho );
// Set the orthographic projection
// matrix up, to be based on the radius
// generated based on our shape.
GFX->setOrtho( -mRadius, mRadius, -mRadius, mRadius, 0.001f, (mRadius * 2) * smDepthAdjust, true );
// Set the world to light space
// matrix set up in shouldRender().
GFX->setWorldMatrix( mWorldToLight );
// Get the shapebase datablock if we have one.
ShapeBaseData *data = NULL;
if ( mShapeBase )
data = static_cast<ShapeBaseData*>( mShapeBase->getDataBlock() );
// Init or update the shadow texture size.
if ( mShadowTexture.isNull() || ( data && data->shadowSize != mShadowTexture.getWidth() ) )
{
U32 texSize = getNextPow2( data ? data->shadowSize : 256 * LightShadowMap::smShadowTexScalar );
mShadowTexture.set( texSize, texSize, GFXFormatR8G8B8A8, &PostFxTargetProfile, "BLShadow" );
}
GFX->pushActiveRenderTarget();
if ( !mRenderTarget )
mRenderTarget = GFX->allocRenderToTextureTarget();
mRenderTarget->attachTexture( GFXTextureTarget::DepthStencil, _getDepthTarget( mShadowTexture->getWidth(), mShadowTexture->getHeight() ) );
mRenderTarget->attachTexture( GFXTextureTarget::Color0, mShadowTexture );
GFX->setActiveRenderTarget( mRenderTarget );
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, ColorI( 0, 0, 0, 0 ), 1.0f, 0 );
const SceneRenderState *diffuseState = rdata.getSceneState();
SceneManager *sceneManager = diffuseState->getSceneManager();
SceneRenderState baseState
(
sceneManager,
SPT_Shadow,
SceneCameraState::fromGFXWithViewport( diffuseState->getViewport() ),
renderPass
);
baseState.getMaterialDelegate().bind( &ProjectedShadow::_getShadowMaterial );
baseState.setDiffuseCameraTransform( diffuseState->getCameraTransform() );
baseState.setWorldToScreenScale( diffuseState->getWorldToScreenScale() );
baseState.getCullingState().disableZoneCulling( true );
mParentObject->prepRenderImage( &baseState );
renderPass->renderPass( &baseState );
// Delete the SceneRenderState we allocated.
mRenderTarget->resolve();
GFX->popActiveRenderTarget();
// If we're close enough then filter the shadow.
if ( camDist < BasicLightManager::getShadowFilterDistance() )
{
if ( !smShadowFilter )
{
PostEffect *filter = NULL;
if ( !Sim::findObject( "BL_ShadowFilterPostFx", filter ) )
Con::errorf( "ProjectedShadow::_renderToTexture() - 'BL_ShadowFilterPostFx' not found!" );
smShadowFilter = filter;
}
if ( smShadowFilter )
smShadowFilter->process( NULL, mShadowTexture );
}
// Restore frustum
if (!ortho)
GFX->setFrustum(l, r, b, t, n, f);
else
GFX->setOrtho(l, r, b, t, n, f);
// Set the last render time.
mLastRenderTime = Platform::getVirtualMilliseconds();
// HACK: Will remove in future release!
//.........这里部分代码省略.........
开发者ID:mray,项目名称:terminal-overload,代码行数:101,代码来源:projectedShadow.cpp
示例13: PROFILE_SCOPE
void Forest::prepRenderImage( SceneRenderState *state )
{
PROFILE_SCOPE(Forest_RenderCells);
// TODO: Fix stats.
/*
ForestCellVector &theCells = mData->getCells();
smTotalCells += theCells.size();
// Don't render if we don't have a grid!
if ( theCells.empty() )
return false;
*/
// Prepare to render.
GFXTransformSaver saver;
// Figure out the grid range in the viewing area.
const bool isReflectPass = state->isReflectPass();
const F32 cullScale = isReflectPass ? mReflectionLodScalar : 1.0f;
// If we need to update our cached
// zone state then do it now.
if ( mZoningDirty )
{
mZoningDirty = false;
Vector<ForestCell*> cells;
mData->getCells( &cells );
for ( U32 i=0; i < cells.size(); i++ )
cells[i]->_updateZoning( getSceneManager()->getZoneManager() );
}
// TODO: Move these into the TSForestItemData as something we
// setup once and don't do per-instance.
// Set up the TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
// Use origin sort on all forest elements as
// its alot cheaper than the bounds sort.
rdata.setOriginSort( true );
// We may have some forward lit materials in
// the forest, so pass down a LightQuery for it.
LightQuery lightQuery;
rdata.setLightQuery( &lightQuery );
Frustum culler = state->getFrustum();
// Adjust the far distance if the cull scale has changed.
if ( !mIsEqual( cullScale, 1.0f ) )
{
const F32 visFarDist = culler.getFarDist() * cullScale;
culler.setFarDist( visFarDist );
}
Box3F worldBox;
// Used for debug drawing.
GFXDrawUtil* drawer = GFX->getDrawUtil();
drawer->clearBitmapModulation();
// Go thru the visible cells.
const Box3F &cullerBounds = culler.getBounds();
const Point3F &camPos = state->getDiffuseCameraPosition();
U32 clipMask;
smAverageItemsPerCell = 0.0f;
U32 cellsProcessed = 0;
ForestCell *cell;
// First get all the top level cells which
// intersect the frustum.
Vector<ForestCell*> cellStack;
mData->getCells( culler, &cellStack );
// Get the culling zone state.
const BitVector &zoneState = state->getCullingState().getZoneVisibilityFlags();
// Now loop till we run out of cells.
while ( !cellStack.empty() )
{
// Pop off the next cell.
cell = cellStack.last();
cellStack.pop_back();
const Box3F &cellBounds = cell->getBounds();
// If the cell is empty or its bounds is outside the frustum
// bounds then we have nothing nothing more to do.
if ( cell->isEmpty() || !cullerBounds.isOverlapped( cellBounds ) )
continue;
// Can we cull this cell entirely?
clipMask = culler.testPlanes( cellBounds, Frustum::PlaneMaskAll );
if ( clipMask == -1 )
continue;
//.........这里部分代码省略.........
开发者ID:RasterCode,项目名称:Torque3D,代码行数:101,代码来源:forestRender.cpp
示例14: innerRender
void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata, TSVertexBufferHandle &vb, GFXPrimitiveBufferHandle &pb )
{
PROFILE_SCOPE( TSMesh_InnerRender );
if( vertsPerFrame <= 0 )
return;
F32 meshVisibility = rdata.getFadeOverride() * mVisibility;
if ( meshVisibility < VISIBILITY_EPSILON )
return;
const SceneRenderState *state = rdata.getSceneState();
RenderPassManager *renderPass = state->getRenderPass();
MeshRenderInst *coreRI = renderPass->allocInst<MeshRenderInst>();
coreRI->type = RenderPassManager::RIT_Mesh;
const MatrixF &objToWorld = GFX->getWorldMatrix();
// Sort by the center point or the bounds.
if ( rdata.useOriginSort() )
coreRI->sortDistSq = ( objToWorld.getPosition() - state->getCameraPosition() ).lenSquared();
else
{
Box3F rBox = mBounds;
objToWorld.mul( rBox );
coreRI->sortDistSq = rBox.getSqDistanceToPoint( state->getCameraPosition() );
}
if (getFlags(Billboard))
{
Point3F camPos = state->getDiffuseCameraPosition();
Point3F objPos;
objToWorld.getColumn(3, &objPos);
Point3F targetVector = camPos - objPos;
if(getFlags(BillboardZAxis))
targetVector.z = 0.0f;
targetVector.normalize();
MatrixF orient = MathUtils::createOrientFromDir(targetVector);
orient.setPosition(objPos);
orient.scale(objToWorld.getScale());
coreRI->objectToWorld = renderPass->allocUniqueXform( orient );
}
else
coreRI->objectToWorld = renderPass->allocUniqueXform( objToWorld );
coreRI->worldToCamera = renderPass->allocSharedXform(RenderPassManager::View);
coreRI->projection = renderPass->allocSharedXform(RenderPassManager::Projection);
AssertFatal( vb.isValid(), "TSMesh::innerRender() - Got invalid vertex buffer!" );
AssertFatal( pb.isValid(), "TSMesh::innerRender() - Got invalid primitive buffer!" );
coreRI->vertBuff = &vb;
coreRI->primBuff = &pb;
coreRI->defaultKey2 = (U32) coreRI->vertBuff;
coreRI->materialHint = rdata.getMaterialHint();
coreRI->visibility = meshVisibility;
coreRI->cubemap = rdata.getCubemap();
// NOTICE: SFXBB is removed and refraction is disabled!
//coreRI->backBuffTex = GFX->getSfxBackBuffer();
for ( S32 i = 0; i < primitives.size(); i++ )
{
const TSDrawPrimitive &draw = primitives[i];
// We need to have a material.
if ( draw.matIndex & TSDrawPrimitive::NoMaterial )
continue;
#ifdef TORQUE_DEBUG
// for inspection if you happen to be running in a debugger and can't do bit
// operations in your head.
S32 triangles = draw.matIndex & TSDrawPrimitive::Triangles;
S32 strip = draw.matIndex & TSDrawPrimitive::Strip;
S32 fan = draw.matIndex & TSDrawPrimitive::Fan;
S32 indexed = draw.matIndex & TSDrawPrimitive::Indexed;
S32 type = draw.matIndex & TSDrawPrimitive::TypeMask;
TORQUE_UNUSED(triangles);
TORQUE_UNUSED(strip);
TORQUE_UNUSED(fan);
TORQUE_UNUSED(indexed);
TORQUE_UNUSED(type);
#endif
const U32 matIndex = draw.matIndex & TSDrawPrimitive::MaterialMask;
BaseMatInstance *matInst = materials->getMaterialInst( matIndex );
#ifndef TORQUE_OS_MAC
// Get the instancing material if this mesh qualifies.
if ( meshType != SkinMeshType && pb->mPrimitiveArray[i].numVertices < smMaxInstancingVerts )
matInst = InstancingMaterialHook::getInstancingMat( matInst );
#endif
// If we don't have a material instance after the overload then
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
注:本文中的TSRenderState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论