2010-01-12 13:46:44 +00:00
|
|
|
/*
|
|
|
|
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>
|
2012-07-14 01:25:35 +00:00
|
|
|
#include <OgreSkeleton.h>
|
2012-07-03 13:32:38 +00:00
|
|
|
|
2012-07-17 17:57:15 +00:00
|
|
|
#include <vector>
|
2010-08-08 15:20:55 +00:00
|
|
|
#include <string>
|
2012-07-03 13:32:38 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <boost/algorithm/string.hpp>
|
2011-11-23 23:18:51 +00:00
|
|
|
|
|
|
|
#include "../nif/node.hpp"
|
2010-08-08 15:20:55 +00:00
|
|
|
|
2012-07-17 07:27:12 +00:00
|
|
|
#include <libs/platform/strings.h>
|
2010-08-08 15:20:55 +00:00
|
|
|
|
|
|
|
class BoundsFinder;
|
|
|
|
|
2011-11-23 23:18:51 +00:00
|
|
|
struct ciLessBoost : std::binary_function<std::string, std::string, bool>
|
|
|
|
{
|
2012-07-17 07:27:12 +00:00
|
|
|
bool operator() (const std::string & s1, const std::string & s2) const
|
|
|
|
{
|
|
|
|
//case insensitive version of is_less
|
|
|
|
return boost::algorithm::lexicographical_compare(s1, s2, boost::algorithm::is_iless());
|
2011-11-23 23:18:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-08-08 15:20:55 +00:00
|
|
|
namespace Nif
|
|
|
|
{
|
|
|
|
class Node;
|
|
|
|
class Transformation;
|
|
|
|
class NiTriShape;
|
|
|
|
}
|
|
|
|
|
2011-06-19 17:14:14 +00:00
|
|
|
namespace NifOgre
|
|
|
|
{
|
2012-07-14 01:25:35 +00:00
|
|
|
|
2012-07-18 18:14:13 +00:00
|
|
|
// FIXME: This should not be in NifOgre, it works agnostic of what model format is used
|
2012-07-17 20:40:03 +00:00
|
|
|
struct EntityList {
|
|
|
|
std::vector<Ogre::Entity*> mEntities;
|
|
|
|
Ogre::Entity *mSkelBase;
|
|
|
|
|
2012-07-22 00:09:16 +00:00
|
|
|
EntityList() : mSkelBase(0)
|
2012-07-17 20:40:03 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2012-07-14 01:25:35 +00:00
|
|
|
/** This holds a list of meshes along with the names of their parent nodes
|
|
|
|
*/
|
|
|
|
typedef std::vector< std::pair<Ogre::MeshPtr,std::string> > MeshPairList;
|
|
|
|
|
|
|
|
|
2010-01-12 13:46:44 +00:00
|
|
|
/** Manual resource loader for NIF meshes. This is the main class
|
|
|
|
responsible for translating the internal NIF mesh structure into
|
2012-07-13 03:12:18 +00:00
|
|
|
something Ogre can use.
|
2010-01-12 13:46:44 +00:00
|
|
|
|
|
|
|
You have to insert meshes manually into Ogre like this:
|
|
|
|
|
|
|
|
NIFLoader::load("somemesh.nif");
|
|
|
|
|
2012-07-14 01:25:35 +00:00
|
|
|
This returns a list of meshes used by the model, as well as the names of
|
|
|
|
their parent nodes (as they pertain to the skeleton, which is optionally
|
|
|
|
returned in the second argument if it exists).
|
2010-01-12 13:46:44 +00:00
|
|
|
*/
|
2012-07-15 18:37:36 +00:00
|
|
|
class NIFLoader
|
2010-01-12 13:46:44 +00:00
|
|
|
{
|
2012-07-19 01:29:25 +00:00
|
|
|
static MeshPairList load(std::string name, std::string skelName, const std::string &group);
|
2012-07-17 20:40:03 +00:00
|
|
|
|
2012-07-18 03:23:09 +00:00
|
|
|
public:
|
2012-07-18 18:14:13 +00:00
|
|
|
static EntityList createEntities(Ogre::Entity *parent, const std::string &bonename,
|
2012-07-19 01:38:55 +00:00
|
|
|
Ogre::SceneNode *parentNode,
|
2012-07-18 18:14:13 +00:00
|
|
|
const std::string &name,
|
|
|
|
const std::string &group="General");
|
|
|
|
|
2012-07-17 20:40:03 +00:00
|
|
|
static EntityList createEntities(Ogre::SceneNode *parent,
|
|
|
|
const std::string &name,
|
|
|
|
const std::string &group="General");
|
2010-01-12 13:46:44 +00:00
|
|
|
};
|
|
|
|
|
2011-06-19 17:14:14 +00:00
|
|
|
}
|
|
|
|
|
2010-01-12 13:46:44 +00:00
|
|
|
#endif
|
2012-07-17 07:27:12 +00:00
|
|
|
|
|
|
|
|