#ifndef COMPONENTS_NIFOGRE_SKELETON_HPP #define COMPONENTS_NIFOGRE_SKELETON_HPP #include #include #include #include #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 &ctrls, const std::vector &targets, float startTime, float stopTime); void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *&animroot, TextKeyMap &textkeys, std::vector &ctrls, Ogre::Bone *parent=NULL); // Lookup to retrieve an Ogre bone handle for a given Nif record index std::map mNifToOgreHandleMap; typedef std::map 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