2010-01-12 14:46:44 +01: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/ .
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2013-02-24 13:52:23 -08:00
|
|
|
#ifndef OPENMW_COMPONENTS_NIFOGRE_OGRENIFLOADER_HPP
|
|
|
|
#define OPENMW_COMPONENTS_NIFOGRE_OGRENIFLOADER_HPP
|
2010-01-12 14:46:44 +01:00
|
|
|
|
|
|
|
#include <OgreResource.h>
|
2013-12-09 14:26:08 +01:00
|
|
|
#include <OgreMaterial.h>
|
2013-04-10 19:58:17 -07:00
|
|
|
#include <OgreController.h>
|
2012-07-03 15:32:38 +02:00
|
|
|
|
2012-07-17 10:57:15 -07:00
|
|
|
#include <vector>
|
2010-08-08 17:20:55 +02:00
|
|
|
#include <string>
|
2013-04-10 19:58:17 -07:00
|
|
|
#include <map>
|
2011-11-23 18:18:51 -05:00
|
|
|
|
2010-08-08 17:20:55 +02:00
|
|
|
|
2013-01-09 09:10:59 -08:00
|
|
|
// FIXME: This namespace really doesn't do anything Nif-specific. Any supportable
|
|
|
|
// model format should go through this.
|
2011-06-19 19:14:14 +02:00
|
|
|
namespace NifOgre
|
|
|
|
{
|
2012-07-13 18:25:35 -07:00
|
|
|
|
2013-12-08 16:38:13 +01:00
|
|
|
/**
|
|
|
|
* @brief Clones materials as necessary to not make controllers affect other objects (that share the original material).
|
|
|
|
*/
|
|
|
|
class MaterialControllerManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~MaterialControllerManager();
|
2013-12-19 15:06:15 +01:00
|
|
|
|
|
|
|
/// @attention if \a movable is an Entity, it needs to have *one* SubEntity
|
2013-12-08 16:38:13 +01:00
|
|
|
Ogre::MaterialPtr getWritableMaterial (Ogre::MovableObject* movable);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::map<Ogre::MovableObject*, Ogre::MaterialPtr> mClonedMaterials;
|
|
|
|
};
|
|
|
|
|
2012-09-28 21:57:26 -07:00
|
|
|
typedef std::multimap<float,std::string> TextKeyMap;
|
2013-01-05 04:01:11 -08:00
|
|
|
static const char sTextKeyExtraDataID[] = "TextKeyExtraData";
|
2013-12-07 20:12:03 +01:00
|
|
|
struct ObjectScene {
|
2012-07-17 13:40:03 -07:00
|
|
|
Ogre::Entity *mSkelBase;
|
2013-04-04 01:31:05 -07:00
|
|
|
std::vector<Ogre::Entity*> mEntities;
|
|
|
|
std::vector<Ogre::ParticleSystem*> mParticles;
|
2013-08-05 16:17:40 -07:00
|
|
|
std::vector<Ogre::Light*> mLights;
|
2012-07-17 13:40:03 -07:00
|
|
|
|
2013-12-26 18:16:28 +01:00
|
|
|
// Nodes that should always face the camera when rendering
|
|
|
|
std::vector<Ogre::Node*> mBillboardNodes;
|
|
|
|
|
2013-12-07 20:12:03 +01:00
|
|
|
Ogre::SceneManager* mSceneMgr;
|
|
|
|
|
2013-11-11 23:43:28 +01:00
|
|
|
// The maximum length on any of the controllers. For animations with controllers, but no text keys, consider this the animation length.
|
|
|
|
float mMaxControllerLength;
|
|
|
|
|
2014-07-29 00:23:00 +02:00
|
|
|
TextKeyMap mTextKeys;
|
2013-04-21 22:56:40 -07:00
|
|
|
|
2013-12-08 16:38:13 +01:00
|
|
|
MaterialControllerManager mMaterialControllerMgr;
|
|
|
|
|
2013-04-05 10:13:54 -07:00
|
|
|
std::vector<Ogre::Controller<Ogre::Real> > mControllers;
|
|
|
|
|
2013-12-07 20:12:03 +01:00
|
|
|
ObjectScene(Ogre::SceneManager* sceneMgr) : mSkelBase(0), mMaxControllerLength(0), mSceneMgr(sceneMgr)
|
2012-07-17 13:40:03 -07:00
|
|
|
{ }
|
2013-12-07 20:12:03 +01:00
|
|
|
|
|
|
|
~ObjectScene();
|
2013-12-26 18:16:28 +01:00
|
|
|
|
|
|
|
// Rotate nodes in mBillboardNodes so they face the given camera
|
|
|
|
void rotateBillboardNodes(Ogre::Camera* camera);
|
2014-07-31 14:02:55 +02:00
|
|
|
|
|
|
|
void setVisibilityFlags (unsigned int flags);
|
2012-07-17 13:40:03 -07:00
|
|
|
};
|
|
|
|
|
2013-12-07 20:12:03 +01:00
|
|
|
typedef Ogre::SharedPtr<ObjectScene> ObjectScenePtr;
|
|
|
|
|
2012-07-23 17:20:47 -07:00
|
|
|
|
2013-01-09 09:10:59 -08:00
|
|
|
class Loader
|
2010-01-12 14:46:44 +01:00
|
|
|
{
|
2012-07-17 20:23:09 -07:00
|
|
|
public:
|
2013-12-07 20:12:03 +01:00
|
|
|
static ObjectScenePtr createObjects(Ogre::Entity *parent, const std::string &bonename,
|
2013-04-07 01:52:35 -07:00
|
|
|
Ogre::SceneNode *parentNode,
|
|
|
|
std::string name,
|
|
|
|
const std::string &group="General");
|
|
|
|
|
2013-12-07 20:12:03 +01:00
|
|
|
static ObjectScenePtr createObjects(Ogre::SceneNode *parentNode,
|
2013-04-07 01:52:35 -07:00
|
|
|
std::string name,
|
|
|
|
const std::string &group="General");
|
2013-02-05 17:55:12 -08:00
|
|
|
|
2013-12-07 20:12:03 +01:00
|
|
|
static ObjectScenePtr createObjectBase(Ogre::SceneNode *parentNode,
|
2013-04-07 12:41:27 -07:00
|
|
|
std::string name,
|
|
|
|
const std::string &group="General");
|
2013-05-07 16:59:32 -07:00
|
|
|
|
|
|
|
static void createKfControllers(Ogre::Entity *skelBase,
|
|
|
|
const std::string &name,
|
|
|
|
TextKeyMap &textKeys,
|
|
|
|
std::vector<Ogre::Controller<Ogre::Real> > &ctrls);
|
2010-01-12 14:46:44 +01:00
|
|
|
};
|
|
|
|
|
2013-04-07 13:46:29 -07:00
|
|
|
// FIXME: Should be with other general Ogre extensions.
|
|
|
|
template<typename T>
|
|
|
|
class NodeTargetValue : public Ogre::ControllerValue<T>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
Ogre::Node *mNode;
|
|
|
|
|
|
|
|
public:
|
|
|
|
NodeTargetValue(Ogre::Node *target) : mNode(target)
|
|
|
|
{ }
|
|
|
|
|
2013-04-22 03:41:38 -07:00
|
|
|
virtual Ogre::Quaternion getRotation(T value) const = 0;
|
|
|
|
virtual Ogre::Vector3 getTranslation(T value) const = 0;
|
|
|
|
virtual Ogre::Vector3 getScale(T value) const = 0;
|
2013-04-20 15:35:19 -07:00
|
|
|
|
2013-04-07 13:46:29 -07:00
|
|
|
void setNode(Ogre::Node *target)
|
|
|
|
{ mNode = target; }
|
|
|
|
Ogre::Node *getNode() const
|
|
|
|
{ return mNode; }
|
|
|
|
};
|
|
|
|
typedef Ogre::SharedPtr<NodeTargetValue<Ogre::Real> > NodeTargetValueRealPtr;
|
|
|
|
|
2011-06-19 19:14:14 +02:00
|
|
|
}
|
|
|
|
|
2010-01-12 14:46:44 +01:00
|
|
|
#endif
|