forked from teamnwah/openmw-tes3coop
102 lines
2.8 KiB
C++
102 lines
2.8 KiB
C++
/*
|
|
OpenMW - The completely unofficial reimplementation of Morrowind
|
|
Copyright (C) 2008-2010 Nicolay Korslund
|
|
Email: < korslund@gmail.com >
|
|
WWW: http://openmw.sourceforge.net/
|
|
|
|
This file (ogre_nif_loader.h) is part of the OpenMW package.
|
|
|
|
OpenMW is distributed as free software: you can redistribute it
|
|
and/or modify it under the terms of the GNU General Public License
|
|
version 3, as published by the Free Software Foundation.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
version 3 along with this program. If not, see
|
|
http://www.gnu.org/licenses/ .
|
|
|
|
*/
|
|
|
|
#ifndef _OGRE_NIF_LOADER_H_
|
|
#define _OGRE_NIF_LOADER_H_
|
|
|
|
#include <OgreResource.h>
|
|
#include <OgreMesh.h>
|
|
|
|
#include <cassert>
|
|
#include <string>
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include <libs/mangle/vfs/servers/ogre_vfs.hpp>
|
|
#include "../nif/nif_file.hpp"
|
|
#include "../nif/node.hpp"
|
|
#include "../nif/data.hpp"
|
|
#include "../nif/property.hpp"
|
|
#include "../nif/controller.hpp"
|
|
#include "../nif/extra.hpp"
|
|
#include <libs/platform/strings.h>
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
// For warning messages
|
|
#include <limits>
|
|
using namespace boost::algorithm;
|
|
|
|
|
|
class BoundsFinder;
|
|
|
|
struct ciLessBoost : std::binary_function<std::string, std::string, bool>
|
|
{
|
|
bool operator() (const std::string & s1, const std::string & s2) const {
|
|
//case insensitive version of is_less
|
|
return lexicographical_compare(s1, s2, is_iless());
|
|
}
|
|
};
|
|
|
|
namespace Nif
|
|
{
|
|
class Node;
|
|
class Transformation;
|
|
class NiTriShape;
|
|
}
|
|
|
|
|
|
namespace NifOgre
|
|
{
|
|
/** Manual resource loader for NIF meshes. This is the main class
|
|
responsible for translating the internal NIF mesh structure into
|
|
something Ogre can use.
|
|
|
|
You have to insert meshes manually into Ogre like this:
|
|
|
|
NIFLoader::load("somemesh.nif");
|
|
|
|
Afterwards, you can use the mesh name "somemesh.nif" normally to
|
|
create entities and so on. The mesh isn't loaded from disk until
|
|
OGRE needs it for rendering. Thus the above load() command is not
|
|
very resource intensive, and can safely be done for a large number
|
|
of meshes at load time.
|
|
*/
|
|
class NIFLoader : Ogre::ManualResourceLoader
|
|
{
|
|
public:
|
|
virtual void loadResource(Ogre::Resource *resource);
|
|
|
|
static Ogre::MeshPtr load(const std::string &name,
|
|
const std::string &group="General");
|
|
|
|
private:
|
|
void warn(const std::string &msg);
|
|
void fail(const std::string &msg);
|
|
|
|
typedef std::map<std::string,NIFLoader,ciLessBoost> LoaderMap;
|
|
static LoaderMap sLoaders;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|