1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 20:53:50 +00:00

Attempt to load the skeleton source if it doesn't yet exist

This commit is contained in:
Chris Robinson 2013-02-05 17:55:12 -08:00
parent c839502743
commit 8b1e7b95ba
3 changed files with 36 additions and 2 deletions

View file

@ -52,8 +52,13 @@ Ogre::Bone *Animation::insertSkeletonSource(const std::string &name)
Ogre::SkeletonPtr skel = skelMgr.getByName(name); Ogre::SkeletonPtr skel = skelMgr.getByName(name);
if(skel.isNull()) if(skel.isNull())
{ {
std::cerr<< "Failed to get skeleton source "<<name <<std::endl; NifOgre::Loader::createSkeleton(name);
return NULL; skel = skelMgr.getByName(name);
if(skel.isNull())
{
std::cerr<< "Failed to get skeleton source "<<name <<std::endl;
return NULL;
}
} }
skel->touch(); skel->touch();
mSkeletonSources.push_back(skel); mSkeletonSources.push_back(skel);

View file

@ -1250,6 +1250,33 @@ EntityList Loader::createEntities(Ogre::Entity *parent, const std::string &bonen
} }
bool Loader::createSkeleton(const std::string &name, const std::string &group)
{
Nif::NIFFile::ptr pnif = Nif::NIFFile::create(name);
Nif::NIFFile &nif = *pnif.get();
if(nif.numRecords() < 1)
{
nif.warn("Found no NIF records in "+name+".");
return false;
}
// The first record is assumed to be the root node
Nif::Record const *r = nif.getRecord(0);
assert(r != NULL);
Nif::Node const *node = dynamic_cast<Nif::Node const *>(r);
if(node == NULL)
{
nif.warn("First record in "+name+" was not a node, but a "+
r->recName+".");
return false;
}
NIFSkeletonLoader skelldr;
return skelldr.createSkeleton(name, group, node);
}
/* More code currently not in use, from the old D source. This was /* More code currently not in use, from the old D source. This was
used in the first attempt at loading NIF meshes, where each submesh used in the first attempt at loading NIF meshes, where each submesh
in the file was given a separate bone in a skeleton. Unfortunately in the file was given a separate bone in a skeleton. Unfortunately

View file

@ -77,6 +77,8 @@ public:
static EntityList createEntities(Ogre::SceneNode *parentNode, static EntityList createEntities(Ogre::SceneNode *parentNode,
std::string name, std::string name,
const std::string &group="General"); const std::string &group="General");
static bool createSkeleton(const std::string &name, const std::string &group="General");
}; };
} }