Merge branch 'master' of git://github.com/zinnschlag/openmw into graphics

This commit is contained in:
scrawl 2013-03-03 15:14:20 +01:00
commit 05bd94effb
27 changed files with 402 additions and 339 deletions

View file

@ -9,11 +9,11 @@
#include <components/bsa/bsa_archive.hpp> #include <components/bsa/bsa_archive.hpp>
#include <components/files/configurationmanager.hpp> #include <components/files/configurationmanager.hpp>
#include <components/translation/translation.hpp> #include <components/translation/translation.hpp>
#include <components/nif/nif_file.hpp> #include <components/nif/niffile.hpp>
#include <components/nifoverrides/nifoverrides.hpp> #include <components/nifoverrides/nifoverrides.hpp>
#include <components/nifbullet/bullet_nif_loader.hpp> #include <components/nifbullet/bulletnifloader.hpp>
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogrenifloader.hpp>
#include "mwinput/inputmanagerimp.hpp" #include "mwinput/inputmanagerimp.hpp"

View file

@ -1,7 +1,7 @@
#ifndef _GAME_RENDER_ANIMATION_H #ifndef _GAME_RENDER_ANIMATION_H
#define _GAME_RENDER_ANIMATION_H #define _GAME_RENDER_ANIMATION_H
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogrenifloader.hpp>
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"

View file

@ -7,7 +7,7 @@
#include <OgreSubEntity.h> #include <OgreSubEntity.h>
#include <OgreStaticGeometry.h> #include <OgreStaticGeometry.h>
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogrenifloader.hpp>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"

View file

@ -14,7 +14,7 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <components/nifogre/ogre_nif_loader.hpp> #include <components/nifogre/ogrenifloader.hpp>
#include <extern/shiny/Platforms/Ogre/OgreMaterial.hpp> #include <extern/shiny/Platforms/Ogre/OgreMaterial.hpp>

View file

@ -13,7 +13,7 @@
#include <openengine/bullet/physic.hpp> #include <openengine/bullet/physic.hpp>
#include <openengine/ogre/renderer.hpp> #include <openengine/ogre/renderer.hpp>
#include <components/nifbullet/bullet_nif_loader.hpp> #include <components/nifbullet/bulletnifloader.hpp>
//#include "../mwbase/world.hpp" // FIXME //#include "../mwbase/world.hpp" // FIXME
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"

View file

@ -1,6 +1,6 @@
#include "scene.hpp" #include "scene.hpp"
#include <components/nif/nif_file.hpp> #include <components/nif/niffile.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" /// FIXME #include "../mwbase/world.hpp" /// FIXME

View file

@ -15,15 +15,15 @@ add_component_dir (bsa
) )
add_component_dir (nif add_component_dir (nif
controlled effect nif_types record controller extra node record_ptr data nif_file property controlled effect niftypes record controller extra node record_ptr data niffile property
) )
add_component_dir (nifogre add_component_dir (nifogre
ogre_nif_loader ogrenifloader
) )
add_component_dir (nifbullet add_component_dir (nifbullet
bullet_nif_loader bulletnifloader
) )
add_component_dir (to_utf8 add_component_dir (to_utf8

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_CONTROLLED_H_ #ifndef OPENMW_COMPONENTS_NIF_CONTROLLED_HPP
#define _NIF_CONTROLLED_H_ #define OPENMW_COMPONENTS_NIF_CONTROLLED_HPP
#include "extra.hpp" #include "extra.hpp"
#include "controller.hpp" #include "controller.hpp"
@ -36,7 +36,7 @@ class Controlled : public Extra
public: public:
ControllerPtr controller; ControllerPtr controller;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Extra::read(nif); Extra::read(nif);
controller.read(nif); controller.read(nif);
@ -55,7 +55,7 @@ class Named : public Controlled
public: public:
std::string name; std::string name;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
name = nif->getString(); name = nif->getString();
Controlled::read(nif); Controlled::read(nif);
@ -66,7 +66,7 @@ typedef Named NiSequenceStreamHelper;
class NiParticleGrowFade : public Controlled class NiParticleGrowFade : public Controlled
{ {
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controlled::read(nif); Controlled::read(nif);
@ -80,7 +80,7 @@ class NiParticleColorModifier : public Controlled
public: public:
NiColorDataPtr data; NiColorDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controlled::read(nif); Controlled::read(nif);
data.read(nif); data.read(nif);
@ -96,7 +96,7 @@ public:
class NiGravity : public Controlled class NiGravity : public Controlled
{ {
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controlled::read(nif); Controlled::read(nif);
@ -109,7 +109,7 @@ public:
class NiPlanarCollider : public Controlled class NiPlanarCollider : public Controlled
{ {
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controlled::read(nif); Controlled::read(nif);
@ -121,7 +121,7 @@ public:
class NiParticleRotation : public Controlled class NiParticleRotation : public Controlled
{ {
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controlled::read(nif); Controlled::read(nif);

View file

@ -21,12 +21,12 @@
*/ */
#ifndef _NIF_CONTROLLER_H_ #ifndef OPENMW_COMPONENTS_NIF_CONTROLLER_HPP
#define _NIF_CONTROLLER_H_ #define OPENMW_COMPONENTS_NIF_CONTROLLER_HPP
#include "record.hpp" #include "record.hpp"
#include "nif_file.hpp" #include "niffile.hpp"
#include "record_ptr.hpp" #include "recordptr.hpp"
namespace Nif namespace Nif
{ {
@ -40,7 +40,7 @@ public:
float timeStart, timeStop; float timeStart, timeStop;
ControlledPtr target; ControlledPtr target;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
next.read(nif); next.read(nif);
@ -65,7 +65,7 @@ public:
class NiBSPArrayController : public Controller class NiBSPArrayController : public Controller
{ {
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
@ -82,7 +82,7 @@ class NiMaterialColorController : public Controller
public: public:
NiPosDataPtr data; NiPosDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
data.read(nif); data.read(nif);
@ -101,7 +101,7 @@ public:
NiPosDataPtr posData; NiPosDataPtr posData;
NiFloatDataPtr floatData; NiFloatDataPtr floatData;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
@ -129,7 +129,7 @@ class NiUVController : public Controller
public: public:
NiUVDataPtr data; NiUVDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
@ -149,7 +149,7 @@ class NiKeyframeController : public Controller
public: public:
NiKeyframeDataPtr data; NiKeyframeDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
data.read(nif); data.read(nif);
@ -167,7 +167,7 @@ class NiAlphaController : public Controller
public: public:
NiFloatDataPtr data; NiFloatDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
data.read(nif); data.read(nif);
@ -185,7 +185,7 @@ class NiGeomMorpherController : public Controller
public: public:
NiMorphDataPtr data; NiMorphDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
data.read(nif); data.read(nif);
@ -204,7 +204,7 @@ class NiVisController : public Controller
public: public:
NiVisDataPtr data; NiVisDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Controller::read(nif); Controller::read(nif);
data.read(nif); data.read(nif);

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_DATA_H_ #ifndef OPENMW_COMPONENTS_NIF_DATA_HPP
#define _NIF_DATA_H_ #define OPENMW_COMPONENTS_NIF_DATA_HPP
#include "controlled.hpp" #include "controlled.hpp"
@ -65,7 +65,7 @@ public:
*/ */
int alpha; int alpha;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Named::read(nif); Named::read(nif);
@ -102,7 +102,7 @@ public:
Ogre::Vector3 center; Ogre::Vector3 center;
float radius; float radius;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
int verts = nif->getUShort(); int verts = nif->getUShort();
@ -138,7 +138,7 @@ public:
// Triangles, three vertex indices per triangle // Triangles, three vertex indices per triangle
std::vector<short> triangles; std::vector<short> triangles;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
ShapeData::read(nif); ShapeData::read(nif);
@ -167,7 +167,7 @@ class NiAutoNormalParticlesData : public ShapeData
public: public:
int activeCount; int activeCount;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
ShapeData::read(nif); ShapeData::read(nif);
@ -189,7 +189,7 @@ public:
class NiRotatingParticlesData : public NiAutoNormalParticlesData class NiRotatingParticlesData : public NiAutoNormalParticlesData
{ {
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
NiAutoNormalParticlesData::read(nif); NiAutoNormalParticlesData::read(nif);
@ -208,7 +208,7 @@ class NiPosData : public Record
public: public:
Vector3KeyList mKeyList; Vector3KeyList mKeyList;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
mKeyList.read(nif); mKeyList.read(nif);
} }
@ -219,7 +219,7 @@ class NiUVData : public Record
public: public:
FloatKeyList mKeyList[4]; FloatKeyList mKeyList[4];
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
for(int i = 0;i < 4;i++) for(int i = 0;i < 4;i++)
mKeyList[i].read(nif); mKeyList[i].read(nif);
@ -231,7 +231,7 @@ class NiFloatData : public Record
public: public:
FloatKeyList mKeyList; FloatKeyList mKeyList;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
mKeyList.read(nif); mKeyList.read(nif);
} }
@ -243,7 +243,7 @@ public:
unsigned int rmask, gmask, bmask, amask; unsigned int rmask, gmask, bmask, amask;
int bpp, mips; int bpp, mips;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
nif->getInt(); // always 0 or 1 nif->getInt(); // always 0 or 1
@ -281,7 +281,7 @@ class NiColorData : public Record
public: public:
Vector4KeyList mKeyList; Vector4KeyList mKeyList;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
mKeyList.read(nif); mKeyList.read(nif);
} }
@ -295,7 +295,7 @@ public:
char isSet; char isSet;
}; };
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
int count = nif->getInt(); int count = nif->getInt();
@ -311,7 +311,7 @@ public:
NodePtr root; NodePtr root;
NodeList bones; NodeList bones;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
data.read(nif); data.read(nif);
root.read(nif); root.read(nif);
@ -347,7 +347,7 @@ public:
BoneTrafo trafo; BoneTrafo trafo;
std::vector<BoneInfo> bones; std::vector<BoneInfo> bones;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
trafo.rotation = nif->getMatrix3(); trafo.rotation = nif->getMatrix3();
trafo.trans = nif->getVector3(); trafo.trans = nif->getVector3();
@ -385,7 +385,7 @@ struct NiMorphData : public Record
}; };
std::vector<MorphData> mMorphs; std::vector<MorphData> mMorphs;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
int morphCount = nif->getInt(); int morphCount = nif->getInt();
int vertCount = nif->getInt(); int vertCount = nif->getInt();
@ -410,7 +410,7 @@ struct NiKeyframeData : public Record
Vector3KeyList mTranslations; Vector3KeyList mTranslations;
FloatKeyList mScales; FloatKeyList mScales;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
mRotations.read(nif); mRotations.read(nif);
mTranslations.read(nif); mTranslations.read(nif);

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_EFFECT_H_ #ifndef OPENMW_COMPONENTS_NIF_EFFECT_HPP
#define _NIF_EFFECT_H_ #define OPENMW_COMPONENTS_NIF_EFFECT_HPP
#include "node.hpp" #include "node.hpp"
@ -42,7 +42,7 @@ struct NiLight : Effect
Ogre::Vector3 diffuse; Ogre::Vector3 diffuse;
Ogre::Vector3 specular; Ogre::Vector3 specular;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
dimmer = nif->getFloat(); dimmer = nif->getFloat();
ambient = nif->getVector3(); ambient = nif->getVector3();
@ -52,7 +52,7 @@ struct NiLight : Effect
}; };
SLight light; SLight light;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Effect::read(nif); Effect::read(nif);
@ -66,7 +66,7 @@ struct NiTextureEffect : Effect
{ {
NiSourceTexturePtr texture; NiSourceTexturePtr texture;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Effect::read(nif); Effect::read(nif);

View file

@ -21,12 +21,12 @@
*/ */
#ifndef _NIF_EXTRA_H_ #ifndef OPENMW_COMPONENTS_NIF_EXTRA_HPP
#define _NIF_EXTRA_H_ #define OPENMW_COMPONENTS_NIF_EXTRA_HPP
#include "record.hpp" #include "record.hpp"
#include "nif_file.hpp" #include "niffile.hpp"
#include "record_ptr.hpp" #include "recordptr.hpp"
namespace Nif namespace Nif
{ {
@ -40,14 +40,14 @@ class Extra : public Record
public: public:
ExtraPtr extra; ExtraPtr extra;
void read(NIFFile *nif) { extra.read(nif); } void read(NIFStream *nif) { extra.read(nif); }
void post(NIFFile *nif) { extra.post(nif); } void post(NIFFile *nif) { extra.post(nif); }
}; };
class NiVertWeightsExtraData : public Extra class NiVertWeightsExtraData : public Extra
{ {
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Extra::read(nif); Extra::read(nif);
@ -70,7 +70,7 @@ public:
}; };
std::vector<TextKey> list; std::vector<TextKey> list;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Extra::read(nif); Extra::read(nif);
@ -95,7 +95,7 @@ public:
*/ */
std::string string; std::string string;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Extra::read(nif); Extra::read(nif);

View file

@ -21,7 +21,7 @@
*/ */
#include "nif_file.hpp" #include "niffile.hpp"
#include "record.hpp" #include "record.hpp"
#include "components/misc/stringops.hpp" #include "components/misc/stringops.hpp"
@ -174,10 +174,7 @@ NIFFile::ptr NIFFile::create (const std::string &name) { return LoadedCache::cre
NIFFile::NIFFile(const std::string &name, psudo_private_modifier) NIFFile::NIFFile(const std::string &name, psudo_private_modifier)
: filename(name) : filename(name)
{ {
inp = Ogre::ResourceGroupManager::getSingleton().openResource(name);
parse(); parse();
// Make sure to close the file after it was loaded into memory
inp.setNull();
} }
NIFFile::~NIFFile() NIFFile::~NIFFile()
@ -188,6 +185,101 @@ NIFFile::~NIFFile()
delete records[i]; delete records[i];
} }
template <typename NodeType> static Record* construct() { return new NodeType; }
struct RecordFactoryEntry {
typedef Record* (*create_t) ();
char const * mName;
create_t mCreate;
RecordType mType;
};
/* These are all the record types we know how to read.
This can be heavily optimized later if needed. For example, a
hash table or a FSM-based parser could be used to look up
node names.
*/
static const RecordFactoryEntry recordFactories [] = {
{ "NiNode", &construct <NiNode >, RC_NiNode },
{ "AvoidNode", &construct <NiNode >, RC_NiNode },
{ "NiBSParticleNode", &construct <NiNode >, RC_NiNode },
{ "NiBSAnimationNode", &construct <NiNode >, RC_NiNode },
{ "NiBillboardNode", &construct <NiNode >, RC_NiNode },
{ "NiTriShape", &construct <NiTriShape >, RC_NiTriShape },
{ "NiRotatingParticles", &construct <NiRotatingParticles >, RC_NiRotatingParticles },
{ "NiAutoNormalParticles", &construct <NiAutoNormalParticles >, RC_NiAutoNormalParticles },
{ "NiCamera", &construct <NiCamera >, RC_NiCamera },
{ "RootCollisionNode", &construct <NiNode >, RC_RootCollisionNode },
{ "NiTexturingProperty", &construct <NiTexturingProperty >, RC_NiTexturingProperty },
{ "NiMaterialProperty", &construct <NiMaterialProperty >, RC_NiMaterialProperty },
{ "NiZBufferProperty", &construct <NiZBufferProperty >, RC_NiZBufferProperty },
{ "NiAlphaProperty", &construct <NiAlphaProperty >, RC_NiAlphaProperty },
{ "NiVertexColorProperty", &construct <NiVertexColorProperty >, RC_NiVertexColorProperty },
{ "NiShadeProperty", &construct <NiShadeProperty >, RC_NiShadeProperty },
{ "NiDitherProperty", &construct <NiDitherProperty >, RC_NiDitherProperty },
{ "NiWireframeProperty", &construct <NiWireframeProperty >, RC_NiWireframeProperty },
{ "NiSpecularProperty", &construct <NiSpecularProperty >, RC_NiSpecularProperty },
{ "NiStencilProperty", &construct <NiStencilProperty >, RC_NiStencilProperty },
{ "NiVisController", &construct <NiVisController >, RC_NiVisController },
{ "NiGeomMorpherController", &construct <NiGeomMorpherController >, RC_NiGeomMorpherController },
{ "NiKeyframeController", &construct <NiKeyframeController >, RC_NiKeyframeController },
{ "NiAlphaController", &construct <NiAlphaController >, RC_NiAlphaController },
{ "NiUVController", &construct <NiUVController >, RC_NiUVController },
{ "NiPathController", &construct <NiPathController >, RC_NiPathController },
{ "NiMaterialColorController", &construct <NiMaterialColorController >, RC_NiMaterialColorController },
{ "NiBSPArrayController", &construct <NiBSPArrayController >, RC_NiBSPArrayController },
{ "NiParticleSystemController", &construct <NiParticleSystemController >, RC_NiParticleSystemController },
{ "NiAmbientLight", &construct <NiLight >, RC_NiLight },
{ "NiDirectionalLight", &construct <NiLight >, RC_NiLight },
{ "NiTextureEffect", &construct <NiTextureEffect >, RC_NiTextureEffect },
{ "NiVertWeightsExtraData", &construct <NiVertWeightsExtraData >, RC_NiVertWeightsExtraData },
{ "NiTextKeyExtraData", &construct <NiTextKeyExtraData >, RC_NiTextKeyExtraData },
{ "NiStringExtraData", &construct <NiStringExtraData >, RC_NiStringExtraData },
{ "NiGravity", &construct <NiGravity >, RC_NiGravity },
{ "NiPlanarCollider", &construct <NiPlanarCollider >, RC_NiPlanarCollider },
{ "NiParticleGrowFade", &construct <NiParticleGrowFade >, RC_NiParticleGrowFade },
{ "NiParticleColorModifier", &construct <NiParticleColorModifier >, RC_NiParticleColorModifier },
{ "NiParticleRotation", &construct <NiParticleRotation >, RC_NiParticleRotation },
{ "NiFloatData", &construct <NiFloatData >, RC_NiFloatData },
{ "NiTriShapeData", &construct <NiTriShapeData >, RC_NiTriShapeData },
{ "NiVisData", &construct <NiVisData >, RC_NiVisData },
{ "NiColorData", &construct <NiColorData >, RC_NiColorData },
{ "NiPixelData", &construct <NiPixelData >, RC_NiPixelData },
{ "NiMorphData", &construct <NiMorphData >, RC_NiMorphData },
{ "NiKeyframeData", &construct <NiKeyframeData >, RC_NiKeyframeData },
{ "NiSkinData", &construct <NiSkinData >, RC_NiSkinData },
{ "NiUVData", &construct <NiUVData >, RC_NiUVData },
{ "NiPosData", &construct <NiPosData >, RC_NiPosData },
{ "NiRotatingParticlesData", &construct <NiRotatingParticlesData >, RC_NiRotatingParticlesData },
{ "NiAutoNormalParticlesData", &construct <NiAutoNormalParticlesData >, RC_NiAutoNormalParticlesData },
{ "NiSequenceStreamHelper", &construct <NiSequenceStreamHelper >, RC_NiSequenceStreamHelper },
{ "NiSourceTexture", &construct <NiSourceTexture >, RC_NiSourceTexture },
{ "NiSkinInstance", &construct <NiSkinInstance >, RC_NiSkinInstance },
};
static RecordFactoryEntry const * recordFactories_begin = &recordFactories [0];
static RecordFactoryEntry const * recordFactories_end = &recordFactories [sizeof (recordFactories) / sizeof (recordFactories[0])];
RecordFactoryEntry const * lookupRecordFactory (char const * name)
{
RecordFactoryEntry const * i;
for (i = recordFactories_begin; i != recordFactories_end; ++i)
if (strcmp (name, i->mName) == 0)
break;
if (i == recordFactories_end)
return NULL;
return i;
}
/* This file implements functions from the NIFFile class. It is also /* This file implements functions from the NIFFile class. It is also
where we stash all the functions we couldn't add as inline where we stash all the functions we couldn't add as inline
definitions in the record types. definitions in the record types.
@ -195,18 +287,20 @@ NIFFile::~NIFFile()
void NIFFile::parse() void NIFFile::parse()
{ {
NIFStream nif (this, Ogre::ResourceGroupManager::getSingleton().openResource(filename));
// Check the header string // Check the header string
std::string head = getString(40); std::string head = nif.getString(40);
if(head.compare(0, 22, "NetImmerse File Format") != 0) if(head.compare(0, 22, "NetImmerse File Format") != 0)
fail("Invalid NIF header"); fail("Invalid NIF header");
// Get BCD version // Get BCD version
ver = getInt(); ver = nif.getInt();
if(ver != VER_MW) if(ver != VER_MW)
fail("Unsupported NIF version"); fail("Unsupported NIF version");
// Number of records // Number of records
size_t recNum = getInt(); size_t recNum = nif.getInt();
records.resize(recNum); records.resize(recNum);
/* The format for 10.0.1.0 seems to be a bit different. After the /* The format for 10.0.1.0 seems to be a bit different. After the
@ -222,97 +316,24 @@ void NIFFile::parse()
{ {
Record *r = NULL; Record *r = NULL;
std::string rec = getString(); std::string rec = nif.getString();
/* These are all the record types we know how to read. RecordFactoryEntry const * entry = lookupRecordFactory (rec.c_str ());
This can be heavily optimized later if needed. For example, a if (entry != NULL)
hash table or a FSM-based parser could be used to look up {
node names. r = entry->mCreate ();
*/ r->recType = entry->mType;
}
// NiNodes
if(rec == "NiNode" || rec == "AvoidNode" ||
rec == "NiBSParticleNode" ||
rec == "NiBSAnimationNode" ||
rec == "NiBillboardNode") { r = new NiNode; r->recType = RC_NiNode; }
// Other nodes
else if(rec == "NiTriShape") { r = new NiTriShape; r->recType = RC_NiTriShape; }
else if(rec == "NiRotatingParticles") { r = new NiRotatingParticles; r->recType = RC_NiRotatingParticles; }
else if(rec == "NiAutoNormalParticles") { r = new NiAutoNormalParticles; r->recType = RC_NiAutoNormalParticles; }
else if(rec == "NiCamera") { r = new NiCamera; r->recType = RC_NiCamera; }
else if(rec == "RootCollisionNode"){ r = new NiNode; r->recType = RC_RootCollisionNode; }// a root collision node is exactly like a node
//that's why there is no need to create a new type
// Properties
else if(rec == "NiTexturingProperty") { r = new NiTexturingProperty; r->recType = RC_NiTexturingProperty; }
else if(rec == "NiMaterialProperty") { r = new NiMaterialProperty; r->recType = RC_NiMaterialProperty; }
else if(rec == "NiZBufferProperty") { r = new NiZBufferProperty; r->recType = RC_NiZBufferProperty; }
else if(rec == "NiAlphaProperty") { r = new NiAlphaProperty; r->recType = RC_NiAlphaProperty; }
else if(rec == "NiVertexColorProperty") { r = new NiVertexColorProperty; r->recType = RC_NiVertexColorProperty; }
else if(rec == "NiShadeProperty") { r = new NiShadeProperty; r->recType = RC_NiShadeProperty; }
else if(rec == "NiDitherProperty") { r = new NiDitherProperty; r->recType = RC_NiDitherProperty; }
else if(rec == "NiWireframeProperty") { r = new NiWireframeProperty; r->recType = RC_NiWireframeProperty; }
else if(rec == "NiSpecularProperty") { r = new NiSpecularProperty; r->recType = RC_NiSpecularProperty; }
else if(rec == "NiStencilProperty") { r = new NiStencilProperty; r->recType = RC_NiStencilProperty; }
// Controllers
else if(rec == "NiVisController") { r = new NiVisController; r->recType = RC_NiVisController; }
else if(rec == "NiGeomMorpherController") { r = new NiGeomMorpherController; r->recType = RC_NiGeomMorpherController; }
else if(rec == "NiKeyframeController") { r = new NiKeyframeController; r->recType = RC_NiKeyframeController; }
else if(rec == "NiAlphaController") { r = new NiAlphaController; r->recType = RC_NiAlphaController; }
else if(rec == "NiUVController") { r = new NiUVController; r->recType = RC_NiUVController; }
else if(rec == "NiPathController") { r = new NiPathController; r->recType = RC_NiPathController; }
else if(rec == "NiMaterialColorController") { r = new NiMaterialColorController; r->recType = RC_NiMaterialColorController; }
else if(rec == "NiBSPArrayController") { r = new NiBSPArrayController; r->recType = RC_NiBSPArrayController; }
else if(rec == "NiParticleSystemController") { r = new NiParticleSystemController; r->recType = RC_NiParticleSystemController; }
// Effects
else if(rec == "NiAmbientLight" ||
rec == "NiDirectionalLight") { r = new NiLight; r->recType = RC_NiLight; }
else if(rec == "NiTextureEffect") { r = new NiTextureEffect; r->recType = RC_NiTextureEffect; }
// Extra Data
else if(rec == "NiVertWeightsExtraData") { r = new NiVertWeightsExtraData; r->recType = RC_NiVertWeightsExtraData; }
else if(rec == "NiTextKeyExtraData") { r = new NiTextKeyExtraData; r->recType = RC_NiTextKeyExtraData; }
else if(rec == "NiStringExtraData") { r = new NiStringExtraData; r->recType = RC_NiStringExtraData; }
else if(rec == "NiGravity") { r = new NiGravity; r->recType = RC_NiGravity; }
else if(rec == "NiPlanarCollider") { r = new NiPlanarCollider; r->recType = RC_NiPlanarCollider; }
else if(rec == "NiParticleGrowFade") { r = new NiParticleGrowFade; r->recType = RC_NiParticleGrowFade; }
else if(rec == "NiParticleColorModifier") { r = new NiParticleColorModifier; r->recType = RC_NiParticleColorModifier; }
else if(rec == "NiParticleRotation") { r = new NiParticleRotation; r->recType = RC_NiParticleRotation; }
// Data
else if(rec == "NiFloatData") { r = new NiFloatData; r->recType = RC_NiFloatData; }
else if(rec == "NiTriShapeData") { r = new NiTriShapeData; r->recType = RC_NiTriShapeData; }
else if(rec == "NiVisData") { r = new NiVisData; r->recType = RC_NiVisData; }
else if(rec == "NiColorData") { r = new NiColorData; r->recType = RC_NiColorData; }
else if(rec == "NiPixelData") { r = new NiPixelData; r->recType = RC_NiPixelData; }
else if(rec == "NiMorphData") { r = new NiMorphData; r->recType = RC_NiMorphData; }
else if(rec == "NiKeyframeData") { r = new NiKeyframeData; r->recType = RC_NiKeyframeData; }
else if(rec == "NiSkinData") { r = new NiSkinData; r->recType = RC_NiSkinData; }
else if(rec == "NiUVData") { r = new NiUVData; r->recType = RC_NiUVData; }
else if(rec == "NiPosData") { r = new NiPosData; r->recType = RC_NiPosData; }
else if(rec == "NiRotatingParticlesData") { r = new NiRotatingParticlesData; r->recType = RC_NiRotatingParticlesData; }
else if(rec == "NiAutoNormalParticlesData") { r = new NiAutoNormalParticlesData; r->recType = RC_NiAutoNormalParticlesData; }
// Other
else if(rec == "NiSequenceStreamHelper") { r = new NiSequenceStreamHelper; r->recType = RC_NiSequenceStreamHelper; }
else if(rec == "NiSourceTexture") { r = new NiSourceTexture; r->recType = RC_NiSourceTexture; }
else if(rec == "NiSkinInstance") { r = new NiSkinInstance; r->recType = RC_NiSkinInstance; }
// Failure
else else
fail("Unknown record type " + rec); fail("Unknown record type " + rec);
assert(r != NULL); assert(r != NULL);
assert(r->recType != RC_MISSING); assert(r->recType != RC_MISSING);
r->recName = rec; r->recName = rec;
r->recIndex = i; r->recIndex = i;
records[i] = r; records[i] = r;
r->read(this); r->read(&nif);
// Discard tranformations for the root node, otherwise some meshes // Discard tranformations for the root node, otherwise some meshes
// occasionally get wrong orientation. Only for NiNode-s for now, but // occasionally get wrong orientation. Only for NiNode-s for now, but

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_FILE_H_ #ifndef OPENMW_COMPONENTS_NIF_NIFFILE_HPP
#define _NIF_FILE_H_ #define OPENMW_COMPONENTS_NIF_NIFFILE_HPP
#include <OgreResourceGroupManager.h> #include <OgreResourceGroupManager.h>
#include <OgreDataStream.h> #include <OgreDataStream.h>
@ -45,7 +45,8 @@
#include <libs/platform/stdint.h> #include <libs/platform/stdint.h>
#include "record.hpp" #include "record.hpp"
#include "nif_types.hpp" #include "niftypes.hpp"
#include "nifstream.hpp"
namespace Nif namespace Nif
{ {
@ -59,9 +60,6 @@ class NIFFile
/// Nif file version /// Nif file version
int ver; int ver;
/// Input stream
Ogre::DataStreamPtr inp;
/// File name, used for error messages /// File name, used for error messages
std::string filename; std::string filename;
@ -71,33 +69,6 @@ class NIFFile
/// Parse the file /// Parse the file
void parse(); void parse();
uint8_t read_byte()
{
uint8_t byte;
if(inp->read(&byte, 1) != 1) return 0;
return byte;
}
uint16_t read_le16()
{
uint8_t buffer[2];
if(inp->read(buffer, 2) != 2) return 0;
return buffer[0] | (buffer[1]<<8);
}
uint32_t read_le32()
{
uint8_t buffer[4];
if(inp->read(buffer, 4) != 4) return 0;
return buffer[0] | (buffer[1]<<8) | (buffer[2]<<16) | (buffer[3]<<24);
}
float read_le32f()
{
union {
uint32_t i;
float f;
} u = { read_le32() };
return u.f;
}
class LoadedCache; class LoadedCache;
friend class LoadedCache; friend class LoadedCache;
@ -117,8 +88,8 @@ public:
void warn(const std::string &msg) void warn(const std::string &msg)
{ {
std::cerr<< "NIFFile Warning: "<<msg <<std::endl std::cerr << "NIFFile Warning: " << msg <<std::endl
<< "File: "<<filename <<std::endl; << "File: " << filename <<std::endl;
} }
typedef boost::shared_ptr <NIFFile> ptr; typedef boost::shared_ptr <NIFFile> ptr;
@ -147,111 +118,6 @@ public:
/// Number of records /// Number of records
size_t numRecords() { return records.size(); } size_t numRecords() { return records.size(); }
/*************************************************
Parser functions
****************************************************/
void skip(size_t size) { inp->skip(size); }
char getChar() { return read_byte(); }
short getShort() { return read_le16(); }
unsigned short getUShort() { return read_le16(); }
int getInt() { return read_le32(); }
unsigned int getUInt() { return read_le32(); }
float getFloat() { return read_le32f(); }
Ogre::Vector2 getVector2()
{
float a[2];
for(size_t i = 0;i < 2;i++)
a[i] = getFloat();
return Ogre::Vector2(a);
}
Ogre::Vector3 getVector3()
{
float a[3];
for(size_t i = 0;i < 3;i++)
a[i] = getFloat();
return Ogre::Vector3(a);
}
Ogre::Vector4 getVector4()
{
float a[4];
for(size_t i = 0;i < 4;i++)
a[i] = getFloat();
return Ogre::Vector4(a);
}
Ogre::Matrix3 getMatrix3()
{
Ogre::Real a[3][3];
for(size_t i = 0;i < 3;i++)
{
for(size_t j = 0;j < 3;j++)
a[i][j] = Ogre::Real(getFloat());
}
return Ogre::Matrix3(a);
}
Ogre::Quaternion getQuaternion()
{
float a[4];
for(size_t i = 0;i < 4;i++)
a[i] = getFloat();
return Ogre::Quaternion(a);
}
Transformation getTrafo()
{
Transformation t;
t.pos = getVector3();
t.rotation = getMatrix3();
t.scale = getFloat();
return t;
}
std::string getString(size_t length)
{
std::vector<char> str (length+1, 0);
if(inp->read(&str[0], length) != length)
throw std::runtime_error ("string length in NIF file does not match");
return &str[0];
}
std::string getString()
{
size_t size = read_le32();
return getString(size);
}
void getShorts(std::vector<short> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getShort();
}
void getFloats(std::vector<float> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getFloat();
}
void getVector2s(std::vector<Ogre::Vector2> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector2();
}
void getVector3s(std::vector<Ogre::Vector3> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector3();
}
void getVector4s(std::vector<Ogre::Vector4> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector4();
}
}; };
@ -270,7 +136,7 @@ typedef KeyT<Ogre::Vector3> Vector3Key;
typedef KeyT<Ogre::Vector4> Vector4Key; typedef KeyT<Ogre::Vector4> Vector4Key;
typedef KeyT<Ogre::Quaternion> QuaternionKey; typedef KeyT<Ogre::Quaternion> QuaternionKey;
template<typename T, T (NIFFile::*getValue)()> template<typename T, T (NIFStream::*getValue)()>
struct KeyListT { struct KeyListT {
typedef std::vector< KeyT<T> > VecType; typedef std::vector< KeyT<T> > VecType;
@ -281,7 +147,7 @@ struct KeyListT {
int mInterpolationType; int mInterpolationType;
VecType mKeys; VecType mKeys;
void read(NIFFile *nif, bool force=false) void read(NIFStream *nif, bool force=false)
{ {
size_t count = nif->getInt(); size_t count = nif->getInt();
if(count == 0 && !force) if(count == 0 && !force)
@ -322,13 +188,13 @@ struct KeyListT {
} }
} }
else else
nif->warn("Unhandled interpolation type: "+Ogre::StringConverter::toString(mInterpolationType)); nif->file->warn("Unhandled interpolation type: "+Ogre::StringConverter::toString(mInterpolationType));
} }
}; };
typedef KeyListT<float,&NIFFile::getFloat> FloatKeyList; typedef KeyListT<float,&NIFStream::getFloat> FloatKeyList;
typedef KeyListT<Ogre::Vector3,&NIFFile::getVector3> Vector3KeyList; typedef KeyListT<Ogre::Vector3,&NIFStream::getVector3> Vector3KeyList;
typedef KeyListT<Ogre::Vector4,&NIFFile::getVector4> Vector4KeyList; typedef KeyListT<Ogre::Vector4,&NIFStream::getVector4> Vector4KeyList;
typedef KeyListT<Ogre::Quaternion,&NIFFile::getQuaternion> QuaternionKeyList; typedef KeyListT<Ogre::Quaternion,&NIFStream::getQuaternion> QuaternionKeyList;
} // Namespace } // Namespace
#endif #endif

View file

@ -0,0 +1,175 @@
#ifndef OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP
#define OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP
namespace Nif
{
class NIFFile;
class NIFStream {
/// Input stream
Ogre::DataStreamPtr inp;
uint8_t read_byte()
{
uint8_t byte;
if(inp->read(&byte, 1) != 1) return 0;
return byte;
}
uint16_t read_le16()
{
uint8_t buffer[2];
if(inp->read(buffer, 2) != 2) return 0;
return buffer[0] | (buffer[1]<<8);
}
uint32_t read_le32()
{
uint8_t buffer[4];
if(inp->read(buffer, 4) != 4) return 0;
return buffer[0] | (buffer[1]<<8) | (buffer[2]<<16) | (buffer[3]<<24);
}
float read_le32f()
{
union {
uint32_t i;
float f;
} u = { read_le32() };
return u.f;
}
public:
NIFFile * const file;
NIFStream (NIFFile * file, Ogre::DataStreamPtr inp): file (file), inp (inp) {}
/*************************************************
Parser functions
****************************************************/
template <typename T>
struct GetHandler
{
typedef T (NIFStream::*fn_t)();
static const fn_t sValue; // this is specialized per supported type in the .cpp file
static T read (NIFStream* nif)
{
return (nif->*sValue) ();
}
};
template <typename T>
void read (NIFStream* nif, T & Value)
{
Value = GetHandler <T>::read (nif);
}
void skip(size_t size) { inp->skip(size); }
void read (void * data, size_t size) { inp->read (data, size); }
char getChar() { return read_byte(); }
short getShort() { return read_le16(); }
unsigned short getUShort() { return read_le16(); }
int getInt() { return read_le32(); }
int getUInt() { return read_le32(); }
float getFloat() { return read_le32f(); }
Ogre::Vector2 getVector2()
{
float a[2];
for(size_t i = 0;i < 2;i++)
a[i] = getFloat();
return Ogre::Vector2(a);
}
Ogre::Vector3 getVector3()
{
float a[3];
for(size_t i = 0;i < 3;i++)
a[i] = getFloat();
return Ogre::Vector3(a);
}
Ogre::Vector4 getVector4()
{
float a[4];
for(size_t i = 0;i < 4;i++)
a[i] = getFloat();
return Ogre::Vector4(a);
}
Ogre::Matrix3 getMatrix3()
{
Ogre::Real a[3][3];
for(size_t i = 0;i < 3;i++)
{
for(size_t j = 0;j < 3;j++)
a[i][j] = Ogre::Real(getFloat());
}
return Ogre::Matrix3(a);
}
Ogre::Quaternion getQuaternion()
{
float a[4];
for(size_t i = 0;i < 4;i++)
a[i] = getFloat();
return Ogre::Quaternion(a);
}
Transformation getTrafo()
{
Transformation t;
t.pos = getVector3();
t.rotation = getMatrix3();
t.scale = getFloat();
return t;
}
std::string getString(size_t length)
{
std::vector<char> str (length+1, 0);
if(inp->read(&str[0], length) != length)
throw std::runtime_error ("string length in NIF file does not match");
return &str[0];
}
std::string getString()
{
size_t size = read_le32();
return getString(size);
}
void getShorts(std::vector<short> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getShort();
}
void getFloats(std::vector<float> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getFloat();
}
void getVector2s(std::vector<Ogre::Vector2> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector2();
}
void getVector3s(std::vector<Ogre::Vector3> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector3();
}
void getVector4s(std::vector<Ogre::Vector4> &vec, size_t size)
{
vec.resize(size);
for(size_t i = 0;i < vec.size();i++)
vec[i] = getVector4();
}
};
}
#endif

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_TYPES_H_ #ifndef OPENMW_COMPONENTS_NIF_NIFTYPES_HPP
#define _NIF_TYPES_H_ #define OPENMW_COMPONENTS_NIF_NIFTYPES_HPP
#include <OgreVector3.h> #include <OgreVector3.h>
#include <OgreMatrix3.h> #include <OgreMatrix3.h>

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_NODE_H_ #ifndef OPENMW_COMPONENTS_NIF_NODE_HPP
#define _NIF_NODE_H_ #define OPENMW_COMPONENTS_NIF_NODE_HPP
#include <OgreMatrix4.h> #include <OgreMatrix4.h>
@ -54,7 +54,7 @@ public:
Ogre::Matrix3 boundRot; Ogre::Matrix3 boundRot;
Ogre::Vector3 boundXYZ; // Box size Ogre::Vector3 boundXYZ; // Box size
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Named::read(nif); Named::read(nif);
@ -128,7 +128,7 @@ struct NiNode : Node
0x20, 0x40, 0x80 unknown 0x20, 0x40, 0x80 unknown
*/ */
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Node::read(nif); Node::read(nif);
children.read(nif); children.read(nif);
@ -162,7 +162,7 @@ struct NiTriShape : Node
NiTriShapeDataPtr data; NiTriShapeDataPtr data;
NiSkinInstancePtr skin; NiSkinInstancePtr skin;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Node::read(nif); Node::read(nif);
data.read(nif); data.read(nif);
@ -190,7 +190,7 @@ struct NiCamera : Node
// Level of detail modifier // Level of detail modifier
float LOD; float LOD;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
left = nif->getFloat(); left = nif->getFloat();
right = nif->getFloat(); right = nif->getFloat();
@ -209,7 +209,7 @@ struct NiCamera : Node
}; };
Camera cam; Camera cam;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Node::read(nif); Node::read(nif);
@ -224,7 +224,7 @@ struct NiAutoNormalParticles : Node
{ {
NiAutoNormalParticlesDataPtr data; NiAutoNormalParticlesDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Node::read(nif); Node::read(nif);
data.read(nif); data.read(nif);
@ -242,7 +242,7 @@ struct NiRotatingParticles : Node
{ {
NiRotatingParticlesDataPtr data; NiRotatingParticlesDataPtr data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Node::read(nif); Node::read(nif);
data.read(nif); data.read(nif);

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_PROPERTY_H_ #ifndef OPENMW_COMPONENTS_NIF_PROPERTY_HPP
#define _NIF_PROPERTY_H_ #define OPENMW_COMPONENTS_NIF_PROPERTY_HPP
#include "controlled.hpp" #include "controlled.hpp"
@ -35,7 +35,7 @@ public:
// The meaning of these depends on the actual property type. // The meaning of these depends on the actual property type.
int flags; int flags;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Named::read(nif); Named::read(nif);
flags = nif->getUShort(); flags = nif->getUShort();
@ -67,7 +67,7 @@ public:
int clamp, set, filter; int clamp, set, filter;
short unknown2; short unknown2;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
inUse = !!nif->getInt(); inUse = !!nif->getInt();
if(!inUse) return; if(!inUse) return;
@ -111,7 +111,7 @@ public:
*/ */
Texture textures[7]; Texture textures[7];
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Property::read(nif); Property::read(nif);
apply = nif->getInt(); apply = nif->getInt();
@ -157,7 +157,7 @@ struct StructPropT : Property
{ {
T data; T data;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
Property::read(nif); Property::read(nif);
data.read(nif); data.read(nif);
@ -170,7 +170,7 @@ struct S_MaterialProperty
Ogre::Vector3 ambient, diffuse, specular, emissive; Ogre::Vector3 ambient, diffuse, specular, emissive;
float glossiness, alpha; float glossiness, alpha;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
ambient = nif->getVector3(); ambient = nif->getVector3();
diffuse = nif->getVector3(); diffuse = nif->getVector3();
@ -194,7 +194,7 @@ struct S_VertexColorProperty
*/ */
int vertmode, lightmode; int vertmode, lightmode;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
vertmode = nif->getInt(); vertmode = nif->getInt();
lightmode = nif->getInt(); lightmode = nif->getInt();
@ -251,7 +251,7 @@ struct S_AlphaProperty
// Tested against when certain flags are set (see above.) // Tested against when certain flags are set (see above.)
unsigned char threshold; unsigned char threshold;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
threshold = nif->getChar(); threshold = nif->getChar();
} }
@ -300,7 +300,7 @@ struct S_StencilProperty
*/ */
int drawMode; int drawMode;
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
enabled = nif->getChar(); enabled = nif->getChar();
compareFunc = nif->getInt(); compareFunc = nif->getInt();

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _NIF_RECORD_H_ #ifndef OPENMW_COMPONENTS_NIF_RECORD_HPP
#define _NIF_RECORD_H_ #define OPENMW_COMPONENTS_NIF_RECORD_HPP
#include <string> #include <string>
@ -30,6 +30,7 @@ namespace Nif
{ {
class NIFFile; class NIFFile;
class NIFStream;
enum RecordType enum RecordType
{ {
@ -97,7 +98,7 @@ struct Record
Record() : recType(RC_MISSING), recIndex(~(size_t)0) {} Record() : recType(RC_MISSING), recIndex(~(size_t)0) {}
/// Parses the record from file /// Parses the record from file
virtual void read(NIFFile *nif) = 0; virtual void read(NIFStream *nif) = 0;
/// Does post-processing, after the entire tree is loaded /// Does post-processing, after the entire tree is loaded
virtual void post(NIFFile *nif) {} virtual void post(NIFFile *nif) {}

View file

@ -21,10 +21,10 @@
*/ */
#ifndef _NIF_RECORD_PTR_H_ #ifndef OPENMW_COMPONENTS_NIF_RECORDPTR_HPP
#define _NIF_RECORD_PTR_H_ #define OPENMW_COMPONENTS_NIF_RECORDPTR_HPP
#include "nif_file.hpp" #include "niffile.hpp"
#include <vector> #include <vector>
namespace Nif namespace Nif
@ -46,7 +46,7 @@ public:
RecordPtrT() : index(-2) {} RecordPtrT() : index(-2) {}
/// Read the index from the nif /// Read the index from the nif
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
// Can only read the index once // Can only read the index once
assert(index == -2); assert(index == -2);
@ -99,7 +99,7 @@ class RecordListT
std::vector<Ptr> list; std::vector<Ptr> list;
public: public:
void read(NIFFile *nif) void read(NIFStream *nif)
{ {
int len = nif->getInt(); int len = nif->getInt();
list.resize(len); list.resize(len);

View file

@ -21,11 +21,11 @@ http://www.gnu.org/licenses/ .
*/ */
#include "bullet_nif_loader.hpp" #include "bulletnifloader.hpp"
#include <Ogre.h> #include <Ogre.h>
#include <cstdio> #include <cstdio>
#include "../nif/nif_file.hpp" #include "../nif/niffile.hpp"
#include "../nif/node.hpp" #include "../nif/node.hpp"
#include "../nif/data.hpp" #include "../nif/data.hpp"
#include "../nif/property.hpp" #include "../nif/property.hpp"

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _BULLET_NIF_LOADER_H_ #ifndef OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
#define _BULLET_NIF_LOADER_H_ #define OPENMW_COMPONENTS_NIFBULLET_BULLETNIFLOADER_HPP
#include <OgreMesh.h> #include <OgreMesh.h>
#include <cassert> #include <cassert>

View file

@ -21,7 +21,7 @@
*/ */
#include "ogre_nif_loader.hpp" #include "ogrenifloader.hpp"
#include <algorithm> #include <algorithm>

View file

@ -21,8 +21,8 @@
*/ */
#ifndef _OGRE_NIF_LOADER_H_ #ifndef OPENMW_COMPONENTS_NIFOGRE_OGRENIFLOADER_HPP
#define _OGRE_NIF_LOADER_H_ #define OPENMW_COMPONENTS_NIFOGRE_OGRENIFLOADER_HPP
#include <OgreResource.h> #include <OgreResource.h>
#include <OgreMesh.h> #include <OgreMesh.h>

View file

@ -1,5 +1,5 @@
#ifndef COMPONENTS_NIFOVERRIDES_H #ifndef OPENMW_COMPONENTS_NIFOVERRIDES_NIFOVERRIDES_HPP
#define COMPONENTS_NIFOVERRIDES_H #define OPENMW_COMPONENTS_NIFOVERRIDES_NIFOVERRIDES_HPP
#include <OgreConfigFile.h> #include <OgreConfigFile.h>

View file

@ -3,7 +3,7 @@
#include <btBulletDynamicsCommon.h> #include <btBulletDynamicsCommon.h>
#include <btBulletCollisionCommon.h> #include <btBulletCollisionCommon.h>
#include <components/nifbullet/bullet_nif_loader.hpp> #include <components/nifbullet/bulletnifloader.hpp>
namespace OEngine { namespace OEngine {
namespace Physic namespace Physic

View file

@ -2,7 +2,7 @@
#include <btBulletDynamicsCommon.h> #include <btBulletDynamicsCommon.h>
#include <btBulletCollisionCommon.h> #include <btBulletCollisionCommon.h>
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h> #include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
#include <components/nifbullet/bullet_nif_loader.hpp> #include <components/nifbullet/bulletnifloader.hpp>
#include "CMotionState.h" #include "CMotionState.h"
#include "OgreRoot.h" #include "OgreRoot.h"
#include "btKinematicCharacterController.h" #include "btKinematicCharacterController.h"