dark_sylinc wrote: ↑Sun Jul 09, 2023 4:08 pm
Hi!
Do you animate this by switching between multiple textures?, or did you create an atlas (e.g. a 1024x1024 containing 256 textures of 16x16 each in a grid)?
Thanks for the reply!
Examples of both methods would be appreciated since I'm just trying to learn Ogre-next's basics, so the more knowledge the better.
I didn't create an atlas, but I found "flame_anim.png" in Ogre-next's texture folder so I planned to use that.
Here are the functions I used to create a plane mesh with texture, not sure I did it the right way tho, though this was sort of a combination of the billboard test + UpdatingDecalsAndAreaLightTex sample:
Code: Select all
Ogre::MeshPtr LowLevelOgreNext::CreatePlaneV2(
const Ogre::String& name, const Ogre::String& groupName, const Ogre::Plane& plane, Ogre::Real width, Ogre::Real height,
Ogre::uint32 xsegments, Ogre::uint32 ysegments, bool normals, unsigned short numTexCoordSets, Ogre::Real uTile, Ogre::Real vTile,
const Ogre::Vector3& upVector, Ogre::v1::HardwareBuffer::Usage vertexBufferUsage, Ogre::v1::HardwareBuffer::Usage indexBufferUsage,
bool vertexShadowBuffer, bool indexShadowBuffer)
{
Ogre::v1::MeshPtr planeMeshV1 = mMeshMgrV1->createPlane(
name + "v1", groupName, plane, width, height, xsegments, ysegments, normals, numTexCoordSets, uTile, vTile,
upVector, vertexBufferUsage, indexBufferUsage, vertexShadowBuffer, indexShadowBuffer);
Ogre::MeshPtr planeMesh = mMeshMgr->createByImportingV1(
name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, planeMeshV1.get(), true,
true, true);
planeMeshV1->unload();
return planeMesh;
}
//-----------------------------------------------------------------------------------
Ogre::SceneNode* LowLevelOgreNext::CreateTexturePlane(
const Ogre::Plane& plane, Ogre::Real width, Ogre::Real height, const Ogre::Vector3& upVector,
const Ogre::String meshName, const Ogre::String materialName, const Ogre::String aliasName, const Ogre::String textureName,
static const Ogre::uint32 areaLightsPoolId)
{
// Create the scene node
Ogre::SceneNode* PlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
// Create the mesh for the plane
Ogre::MeshPtr v2LightPlane = CreatePlaneV2(
meshName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
plane, 1.0f, 1.0f, 1, 1, true, 1, 1.0f, 1.0f,
upVector, Ogre::v1::HardwareBuffer::HBU_STATIC,
Ogre::v1::HardwareBuffer::HBU_STATIC);
Ogre::Hlms* hlmsUnlit = mRoot->getHlmsManager()->getHlms(Ogre::HLMS_UNLIT);
Ogre::HlmsMacroblock macroblock;
macroblock.mCullMode = Ogre::CULL_NONE;
Ogre::HlmsBlendblock blendBlock;
blendBlock.setBlendType(Ogre::SBT_TRANSPARENT_ALPHA);
// Setup datablock
Ogre::HlmsDatablock* datablockBase = hlmsUnlit->getDatablock(materialName);
if (!datablockBase)
{
//datablockBase = hlmsUnlit->createDatablock(materialName, materialName, macroblock, Ogre::HlmsBlendblock(), Ogre::HlmsParamVec());
datablockBase = hlmsUnlit->createDatablock(materialName, materialName, macroblock, blendBlock, Ogre::HlmsParamVec());
}
assert(dynamic_cast<Ogre::HlmsUnlitDatablock*>(datablockBase));
Ogre::HlmsUnlitDatablock* datablock = static_cast<Ogre::HlmsUnlitDatablock*>(datablockBase);
datablock->setUseColour(true);
datablock->setTexture(0u, textureName);
// Create the plane Item
//Ogre::Item* item = mSceneMgr->createItem(meshName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::Item* item = mSceneMgr->createItem(v2LightPlane, Ogre::SCENE_DYNAMIC);
item->setCastShadows(false);
item->setDatablock(datablock);
PlaneNode->attachObject(item);
PlaneNode->setScale(width, height, 1.0f);
return PlaneNode;
}