本文整理汇总了C++中ogre::TextureUnitState::setScrollAnimation方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureUnitState::setScrollAnimation方法的具体用法?C++ TextureUnitState::setScrollAnimation怎么用?C++ TextureUnitState::setScrollAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::TextureUnitState
的用法示例。
在下文中一共展示了TextureUnitState::setScrollAnimation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _makeScene
void _makeScene()
{
mCamera->setNearClipDistance(1);
mCamera->setFarClipDistance(1000);
// Create the texture
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().createManual(
"DynamicTexture", // name
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, // type
128, 128, // width & height
0, // number of mipmaps
Ogre::PF_BYTE_BGRA, // pixel format
Ogre::TU_DEFAULT); // usage; should be TU_DYNAMIC_WRITE_ONLY_DISCARDABLE for
// textures updated very often (e.g. each frame)
// Get the pixel buffer
Ogre::HardwarePixelBufferSharedPtr pixelBuffer = texture->getBuffer();
// Lock the pixel buffer and get a pixel box
pixelBuffer->lock(Ogre::HardwareBuffer::HBL_NORMAL); // for best performance use HBL_DISCARD!
const Ogre::PixelBox& pixelBox = pixelBuffer->getCurrentLock();
Ogre::uint8* pDest = static_cast<Ogre::uint8*>(pixelBox.data);
// Fill in some pixel data. This will give a semi-transparent blue,
// but this is of course dependent on the chosen pixel format.
for (size_t j = 0; j < 128; j++)
for(size_t i = 0; i < 128; i++)
{
*pDest++ = 82 + (Ogre::Math::Sin(i) + Ogre::Math::Cos(j) * 10.5);
*pDest++ = 45 + (Ogre::Math::Cos(i) + Ogre::Math::Sin(j) * 10.5);
*pDest++ = 128 + (Ogre::Math::Tan(i) + Ogre::Math::Cos(j) * 10.5);
*pDest++ = 255; // A
}
// Unlock the pixel buffer
pixelBuffer->unlock();
// Create a material using the texture
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(
"DynamicTextureMaterial", // name
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::TextureUnitState* tus = material->getTechnique(0)->getPass(0)->createTextureUnitState("DynamicTexture");
tus->setScrollAnimation(0.005f, 0.0025f);
tus->setRotateAnimation(0.009f);
material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
Ogre::Plane plane(Ogre::Vector3::UNIT_Y, 0);
Ogre::MeshManager::getSingleton().createPlane("ground", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane, 1500, 1500, 1, 1, true, 1, 1, 1, Ogre::Vector3::UNIT_Z);
Ogre::Entity* entGround = mSceneMgr->createEntity("GroundEntity", "ground");
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(entGround);
entGround->setMaterialName("DynamicTextureMaterial");
entGround->setCastShadows(false);
mCamera->setPosition(25,100,30);
mCamera->lookAt(0,0,0);
}