OpenMW
components/nifogre/skeleton.hpp
Go to the documentation of this file.
00001 #ifndef COMPONENTS_NIFOGRE_SKELETON_HPP
00002 #define COMPONENTS_NIFOGRE_SKELETON_HPP
00003 
00004 #include <iostream>
00005 #include <string>
00006 #include <cassert>
00007 
00008 #include <OgreResource.h>
00009 
00010 #include "ogrenifloader.hpp"
00011 
00012 namespace Nif
00013 {
00014     class NiTextKeyExtraData;
00015     class Node;
00016     class NiKeyframeController;
00017 }
00018 
00019 namespace NifOgre
00020 {
00021 
00026 class NIFSkeletonLoader : public Ogre::ManualResourceLoader
00027 {
00028     static void warn(const std::string &msg)
00029     {
00030         std::cerr << "NIFSkeletonLoader: Warn: " << msg << std::endl;
00031     }
00032 
00033     static void fail(const std::string &msg)
00034     {
00035         std::cerr << "NIFSkeletonLoader: Fail: "<< msg << std::endl;
00036         abort();
00037     }
00038 
00039     void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, Ogre::Bone *parent=NULL);
00040 
00041     static bool needSkeleton(const Nif::Node *node);
00042 
00043     // Lookup to retrieve an Ogre bone handle for a given Nif record index
00044     std::map<int,int> mNifToOgreHandleMap;
00045 
00046     typedef std::map<std::string,NIFSkeletonLoader> LoaderMap;
00047     static LoaderMap sLoaders;
00048 
00049 public:
00050     void loadResource(Ogre::Resource *resource);
00051 
00052     static Ogre::SkeletonPtr createSkeleton(const std::string &name, const std::string &group, const Nif::Node *node);
00053 
00054     // Looks up an Ogre Bone handle ID from a NIF's record index. Should only
00055     // be used when the bone name is insufficient as this is a relatively slow
00056     // lookup
00057     static int lookupOgreBoneHandle(const std::string &nifname, int idx);
00058 };
00059 
00060 }
00061 
00062 #endif