本文整理汇总了C++中ogre::TextureUnitState::setAnimatedTextureName方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureUnitState::setAnimatedTextureName方法的具体用法?C++ TextureUnitState::setAnimatedTextureName怎么用?C++ TextureUnitState::setAnimatedTextureName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TextureUnitState
的用法示例。
在下文中一共展示了TextureUnitState::setAnimatedTextureName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTextureAndTexAniFPS
//--------------------------------------------------------------------------------
static void setTextureAndTexAniFPS(const MaterialPtr& _material, const String& _texture, Real _texAniFPS)
{
Technique* technique = _material->getTechnique(0);
Pass* pass = technique->getPass(0);
if(_texture.empty())
{
pass->removeAllTextureUnitStates();
}
else
{
TextureManager& tmgr = TextureManager::getSingleton();
Ogre::TextureUnitState* tus = pass->getNumTextureUnitStates() ? pass->getTextureUnitState(0) : pass->createTextureUnitState();
if(_texAniFPS == 0)
{
TexturePtr ogreTexture = tmgr.createOrRetrieve(_texture).first;
const String& ogreTexName = ogreTexture->getName();
tus->setTextureName(ogreTexName);
}
else
{
vector<String>::type ogreTexNames;
TexturePtr ogreTexture = tmgr.createOrRetrieve(_texture).first;
ogreTexNames.push_back(ogreTexture->getName());
size_t dotpos = _texture.rfind('.');
if(dotpos != String::npos && dotpos >= 1
&& '0' <= _texture[dotpos-1] && _texture[dotpos-1] < '9')
{
String tmpname = _texture;
char& dig0 = tmpname[dotpos - 1];
++dig0;
while(!tmgr.getByName(tmpname).isNull() || tmgr.canLoadResource(tmpname, TextureManager::GROUP_NAME))
{
TexturePtr ogreTexture = tmgr.createOrRetrieve(tmpname).first;
ogreTexNames.push_back(ogreTexture->getName());
++dig0;
if(dig0 > '9')
{
if(dotpos >= 2 && '0' <= _texture[dotpos-2] && _texture[dotpos-2] < '9')
{
char& dig1 = tmpname[dotpos-2];
++dig1;
dig0 = '0';
}
else
break;
}
}
}
Real duration = ogreTexNames.size() / _texAniFPS;
tus->setAnimatedTextureName(&ogreTexNames[0], ogreTexNames.size(), duration);
}
}
}
示例2: createNewCrowdMember
void OgreCPP::createNewCrowdMember( float animationTime )
{
char buffer[ 512 ];
uint32_t numCrowdMembers = mCrowdMembers.size();
// Create a new crowd member
Ogre::TextureManager* pTextureMgr = Ogre::TextureManager::getSingletonPtr();
Ogre::String frameTexNames[ 2*NUM_FRAMES_TO_RECORD ];
Ogre::String lowResFrameTexNames[ 2*NUM_FRAMES_TO_RECORD ];
for ( uint32_t frameIdx = 0; frameIdx < NUM_FRAMES_TO_RECORD; frameIdx++ )
{
Ogre::Image image;
image.loadDynamicImage( mpImageData + frameIdx*SMALL_FRAME_WIDTH*SMALL_FRAME_HEIGHT,
SMALL_FRAME_WIDTH, SMALL_FRAME_HEIGHT, 1, Ogre::PF_A4L4 );
sprintf( buffer, "RecordedSequenceTex_%i_%i", numCrowdMembers, frameIdx );
frameTexNames[ frameIdx ] = buffer;
Ogre::TexturePtr pTexture = pTextureMgr->loadImage( frameTexNames[ frameIdx ],
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, image );
sprintf( buffer, "LowResRecordedSequenceTex_%i_%i", numCrowdMembers, frameIdx );
lowResFrameTexNames[ frameIdx ] = buffer;
Ogre::Image lowResImage;
lowResImage.loadDynamicImage( mpLowResImageData + frameIdx*LOW_RES_SMALL_FRAME_WIDTH*LOW_RES_SMALL_FRAME_HEIGHT,
LOW_RES_SMALL_FRAME_WIDTH, LOW_RES_SMALL_FRAME_HEIGHT, 1, Ogre::PF_A4L4 );
pTextureMgr->loadImage( lowResFrameTexNames[ frameIdx ],
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, lowResImage );
}
for ( uint32_t frameIdx = 0; frameIdx < NUM_FRAMES_TO_RECORD; frameIdx++ )
{
frameTexNames[ (2*NUM_FRAMES_TO_RECORD - 1) - frameIdx ] = frameTexNames[ frameIdx ];
lowResFrameTexNames[ (2*NUM_FRAMES_TO_RECORD - 1) - frameIdx ] = lowResFrameTexNames[ frameIdx ];
}
// Create materials for the crowd member
sprintf( buffer, "RecordedSequenceMat_%i", numCrowdMembers );
Ogre::String matName = buffer;
Ogre::MaterialManager* pMatMgr = Ogre::MaterialManager::getSingletonPtr();
Ogre::MaterialPtr pSrcMat = (Ogre::MaterialPtr)pMatMgr->getByName( "Template/CutOut",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
Ogre::MaterialPtr pMat = pSrcMat->clone( matName );
pMat->getTechnique( 0 )->getPass( 0 )->removeAllTextureUnitStates();
Ogre::TextureUnitState* pTex = pMat->getTechnique( 0 )->getPass( 0 )->createTextureUnitState();
pMat->getTechnique( 0 )->getPass( 0 )->addTextureUnitState( pTex );
pTex->setAnimatedTextureName( frameTexNames, 2*NUM_FRAMES_TO_RECORD, 2.0*animationTime );
pMat->setCullingMode( Ogre::CULL_NONE );
pMat->compile();
sprintf( buffer, "LowResRecordedSequenceMat_%i", numCrowdMembers );
Ogre::String lowResMatName = buffer;
pMat = pSrcMat->clone( lowResMatName );
pMat->getTechnique( 0 )->getPass( 0 )->removeAllTextureUnitStates();
pTex = pMat->getTechnique( 0 )->getPass( 0 )->createTextureUnitState();
pMat->getTechnique( 0 )->getPass( 0 )->addTextureUnitState( pTex );
pTex->setAnimatedTextureName( lowResFrameTexNames, 2*NUM_FRAMES_TO_RECORD, 2.0*animationTime );
pMat->setCullingMode( Ogre::CULL_NONE );
pMat->compile();
CrowdMember newCrowdMember;
newCrowdMember.mMaterialName = matName;
newCrowdMember.mLowResMaterialName = lowResMatName;
newCrowdMember.mFrameIdx = 0;
newCrowdMember.mColourIdx = rand()%NUM_COLOURS;
newCrowdMember.mbReversing = false;
num = mCrowdMembers.size()%11;
/** POSITION CROWD MEMBER HERE **/
float x = (num*(5.0/11.0))-2.25;
float y = 1.5;
/* centre is 0,0, extremes are -3,+3 */
newCrowdMember.mPos = Ogre::Vector3( x, y, 5.0 );
newCrowdMember.mRow = 0;
newCrowdMember.mpBillboard = OGRE_NEW PersonBillboard();
newCrowdMember.mpBillboard->setMaterial( newCrowdMember.mMaterialName );
newCrowdMember.mpBillboard->setCorners(
Ogre::Vector3( -0.5f, -0.375f, 0.0f ),
Ogre::Vector3( 0.5f, -0.375f, 0.0f ),
Ogre::Vector3( -0.5f, 0.375f, 0.0f ),
Ogre::Vector3( 0.5f, 0.375f, 0.0f )
);
// Make sure that the front row is drawn in front of everything else
newCrowdMember.mpBillboard->setRenderQueueGroup( CROWD_FRONT_RENDER_QUEUE );
//.........这里部分代码省略.........