Operating System: :Windows 10:
Render System: :Any:
I'm assessing the ogre engine to see if suits my needs, by I'm having problems with some samples.
In the "Sample_ImportAnimationsShareSkeletonInstance" sample I'm trying to spawn multiple animated characters. It works fine for the most part, but when I add the following lines:
Code: Select all
mAnyAnimation[t] = skeletonInstance->getAnimation("char_mining");//This one specifically, the other one does not matter.
mAnyAnimation[t]->setEnabled(true);
The code.
Sample_ImportAnimationsShareSkeletonInstance.h
Code: Select all
class ImportAnimationsShareSkeletonInstanceGameState : public TutorialGameState
{
int size = 3000;
Ogre::SkeletonAnimation* mAnyAnimation[];
public:
ImportAnimationsShareSkeletonInstanceGameState(const Ogre::String &helpDescription);
virtual void createScene01(void);
virtual void update(float timeSinceLast);
};
Code: Select all
void ImportAnimationsShareSkeletonInstanceGameState::createScene01(void)
{
...
// Prepare parts
for (size_t i = 0; i < numParts; ++i)
{
v1Mesh = Ogre::v1::MeshManager::getSingleton().load(
parts[i], Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC);
v2Mesh = Ogre::MeshManager::getSingleton().createManual(
parts[i], Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
v2Mesh->importV1(v1Mesh.get(), halfPosition, halfUVs, useQtangents);
v1Mesh->unload();
}
for (int t = 0; t < size; t++)
{
Ogre::SceneNode *sceneNode = sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)->
createChildSceneNode(Ogre::SCENE_DYNAMIC);
//Create the master.
Ogre::Item *charItem = sceneManager->createItem("char_reference.mesh",
Ogre::ResourceGroupManager::
AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::SCENE_DYNAMIC);
sceneNode->attachObject(charItem);
sceneNode->setPosition(Ogre::Vector3((t / 100)*0.25, 0, -(t % 100) * 0.25f));
for (size_t i = 0; i < numParts; ++i)
{
//Create the slaves, and make them use the skeleton from the master.
Ogre::Item* charPart = sceneManager->createItem(parts[i],
Ogre::ResourceGroupManager::
AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::SCENE_DYNAMIC);
sceneNode->attachObject(charPart);
charPart->useSkeletonInstanceFrom(charItem);
}
{
//Import animation from char_mining.skeleton
Ogre::SkeletonInstance *skeletonInstance = charItem->getSkeletonInstance();
skeletonInstance->addAnimationsFromSkeleton("char_mining.skeleton",
Ogre::ResourceGroupManager::
AUTODETECT_RESOURCE_GROUP_NAME);
mAnyAnimation[t] = skeletonInstance->getAnimation("char_mining");
mAnyAnimation[t]->setEnabled(true);
}
}
...
}