1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 03:39:14 +00:00
OpenMW/components/nifogre/skeleton.hpp
Chris Robinson a3511c62cf Don't store textkeys in user object bindings
It's a bit unwieldy to have them stored in the 'skeleton master' instead
of the skeleton instance. And although the text keys are extracted for
each created instance now, this shouldn't be much worse than the
multimap copying going on before.

Plus, proper serialization can help for future optimizations.
2013-04-22 00:01:30 -07:00

63 lines
1.9 KiB
C++

#ifndef COMPONENTS_NIFOGRE_SKELETON_HPP
#define COMPONENTS_NIFOGRE_SKELETON_HPP
#include <iostream>
#include <string>
#include <cassert>
#include <OgreResource.h>
#include "ogrenifloader.hpp"
namespace Nif
{
class NiTextKeyExtraData;
class Node;
class NiKeyframeController;
}
namespace NifOgre
{
/** Manual resource loader for NIF skeletons. This is the main class
responsible for translating the internal NIF skeleton structure into
something Ogre can use (includes animations and node TextKeyData).
*/
class NIFSkeletonLoader : public Ogre::ManualResourceLoader
{
static void warn(const std::string &msg)
{
std::cerr << "NIFSkeletonLoader: Warn: " << msg << std::endl;
}
static void fail(const std::string &msg)
{
std::cerr << "NIFSkeletonLoader: Fail: "<< msg << std::endl;
abort();
}
static void buildAnimation(Ogre::Skeleton *skel, const std::string &name, const std::vector<const Nif::NiKeyframeController*> &ctrls, const std::vector<std::string> &targets, float startTime, float stopTime);
void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *&animroot, TextKeyMap &textkeys, std::vector<Nif::NiKeyframeController const*> &ctrls, Ogre::Bone *parent=NULL);
// Lookup to retrieve an Ogre bone handle for a given Nif record index
std::map<int,int> mNifToOgreHandleMap;
typedef std::map<std::string,NIFSkeletonLoader> LoaderMap;
static LoaderMap sLoaders;
public:
static TextKeyMap extractTextKeys(const Nif::NiTextKeyExtraData *tk);
void loadResource(Ogre::Resource *resource);
static Ogre::SkeletonPtr createSkeleton(const std::string &name, const std::string &group, const Nif::Node *node);
// Looks up an Ogre Bone handle ID from a NIF's record index. Should only
// be used when the bone name is insufficient as this is a relatively slow
// lookup
static int lookupOgreBoneHandle(const std::string &nifname, int idx);
};
}
#endif