mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-06 09:39:49 +00:00
Moved base NIF classes into a separate file.
This resolves the dependency mess, and makes things more readable. The dependency tree for nif records now looks like this: Record.hpp --base.hpp ----controlled.hpp ----controller.hpp ----data.hpp ----effect.hpp ----extra.hpp ----node.hpp Node.hpp has many extra dependencies because nifogre only includes it instead of each of these files. That should be fixed.
This commit is contained in:
parent
5abed1c32a
commit
38bcff2622
@ -19,7 +19,7 @@ add_component_dir (bsa
|
||||
)
|
||||
|
||||
add_component_dir (nif
|
||||
controlled effect niftypes record controller extra node record_ptr data niffile property nifkey data node
|
||||
controlled effect niftypes record controller extra node record_ptr data niffile property nifkey data node base
|
||||
)
|
||||
|
||||
add_component_dir (nifcache
|
||||
|
91
components/nif/base.hpp
Normal file
91
components/nif/base.hpp
Normal file
@ -0,0 +1,91 @@
|
||||
///This file holds the main classes of NIF Records used by everything else.
|
||||
#ifndef OPENMW_COMPONENTS_NIF_BASE_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_BASE_HPP
|
||||
|
||||
#include "record.hpp"
|
||||
#include "niffile.hpp"
|
||||
#include "recordptr.hpp"
|
||||
#include "nifstream.hpp"
|
||||
#include "nifkey.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
/** A record that can have extra data. The extra data objects
|
||||
themselves descend from the Extra class, and all the extra data
|
||||
connected to an object form a linked list
|
||||
*/
|
||||
class Extra : public Record
|
||||
{
|
||||
public:
|
||||
ExtraPtr extra;
|
||||
|
||||
void read(NIFStream *nif) { extra.read(nif); }
|
||||
void post(NIFFile *nif) { extra.post(nif); }
|
||||
};
|
||||
|
||||
class Controller : public Record
|
||||
{
|
||||
public:
|
||||
ControllerPtr next;
|
||||
int flags;
|
||||
float frequency, phase;
|
||||
float timeStart, timeStop;
|
||||
ControlledPtr target;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
next.read(nif);
|
||||
|
||||
flags = nif->getUShort();
|
||||
|
||||
frequency = nif->getFloat();
|
||||
phase = nif->getFloat();
|
||||
timeStart = nif->getFloat();
|
||||
timeStop = nif->getFloat();
|
||||
|
||||
target.read(nif);
|
||||
}
|
||||
|
||||
void post(NIFFile *nif)
|
||||
{
|
||||
Record::post(nif);
|
||||
next.post(nif);
|
||||
target.post(nif);
|
||||
}
|
||||
};
|
||||
|
||||
/// Anything that has a controller
|
||||
class Controlled : public Extra
|
||||
{
|
||||
public:
|
||||
ControllerPtr controller;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
Extra::read(nif);
|
||||
controller.read(nif);
|
||||
}
|
||||
|
||||
void post(NIFFile *nif)
|
||||
{
|
||||
Extra::post(nif);
|
||||
controller.post(nif);
|
||||
}
|
||||
};
|
||||
|
||||
/// Has name, extra-data and controller
|
||||
class Named : public Controlled
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
name = nif->getString();
|
||||
Controlled::read(nif);
|
||||
}
|
||||
};
|
||||
typedef Named NiSequenceStreamHelper;
|
||||
|
||||
} // Namespace
|
||||
#endif
|
@ -24,45 +24,71 @@
|
||||
#ifndef OPENMW_COMPONENTS_NIF_CONTROLLED_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_CONTROLLED_HPP
|
||||
|
||||
#include "extra.hpp"
|
||||
#include "controller.hpp"
|
||||
#include "base.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
/// Anything that has a controller
|
||||
class Controlled : public Extra
|
||||
class NiSourceTexture : public Named
|
||||
{
|
||||
public:
|
||||
ControllerPtr controller;
|
||||
// Is this an external (references a separate texture file) or
|
||||
// internal (data is inside the nif itself) texture?
|
||||
bool external;
|
||||
|
||||
std::string filename; // In case of external textures
|
||||
NiPixelDataPtr data; // In case of internal textures
|
||||
|
||||
/* Pixel layout
|
||||
0 - Palettised
|
||||
1 - High color 16
|
||||
2 - True color 32
|
||||
3 - Compressed
|
||||
4 - Bumpmap
|
||||
5 - Default */
|
||||
int pixel;
|
||||
|
||||
/* Mipmap format
|
||||
0 - no
|
||||
1 - yes
|
||||
2 - default */
|
||||
int mipmap;
|
||||
|
||||
/* Alpha
|
||||
0 - none
|
||||
1 - binary
|
||||
2 - smooth
|
||||
3 - default (use material alpha, or multiply material with texture if present)
|
||||
*/
|
||||
int alpha;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
Extra::read(nif);
|
||||
controller.read(nif);
|
||||
Named::read(nif);
|
||||
|
||||
external = !!nif->getChar();
|
||||
if(external)
|
||||
filename = nif->getString();
|
||||
else
|
||||
{
|
||||
nif->getChar(); // always 1
|
||||
data.read(nif);
|
||||
}
|
||||
|
||||
pixel = nif->getInt();
|
||||
mipmap = nif->getInt();
|
||||
alpha = nif->getInt();
|
||||
|
||||
nif->getChar(); // always 1
|
||||
}
|
||||
|
||||
void post(NIFFile *nif)
|
||||
{
|
||||
Extra::post(nif);
|
||||
controller.post(nif);
|
||||
Named::post(nif);
|
||||
data.post(nif);
|
||||
}
|
||||
};
|
||||
|
||||
/// Has name, extra-data and controller
|
||||
class Named : public Controlled
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
name = nif->getString();
|
||||
Controlled::read(nif);
|
||||
}
|
||||
};
|
||||
typedef Named NiSequenceStreamHelper;
|
||||
|
||||
class NiParticleGrowFade : public Controlled
|
||||
{
|
||||
public:
|
||||
@ -147,5 +173,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // Namespace
|
||||
#endif
|
||||
|
@ -24,44 +24,11 @@
|
||||
#ifndef OPENMW_COMPONENTS_NIF_CONTROLLER_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_CONTROLLER_HPP
|
||||
|
||||
#include "record.hpp"
|
||||
#include "niffile.hpp"
|
||||
#include "recordptr.hpp"
|
||||
#include "base.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
class Controller : public Record
|
||||
{
|
||||
public:
|
||||
ControllerPtr next;
|
||||
int flags;
|
||||
float frequency, phase;
|
||||
float timeStart, timeStop;
|
||||
ControlledPtr target;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
next.read(nif);
|
||||
|
||||
flags = nif->getUShort();
|
||||
|
||||
frequency = nif->getFloat();
|
||||
phase = nif->getFloat();
|
||||
timeStart = nif->getFloat();
|
||||
timeStop = nif->getFloat();
|
||||
|
||||
target.read(nif);
|
||||
}
|
||||
|
||||
void post(NIFFile *nif)
|
||||
{
|
||||
Record::post(nif);
|
||||
next.post(nif);
|
||||
target.post(nif);
|
||||
}
|
||||
};
|
||||
|
||||
class NiParticleSystemController : public Controller
|
||||
{
|
||||
public:
|
||||
|
@ -24,73 +24,11 @@
|
||||
#ifndef OPENMW_COMPONENTS_NIF_DATA_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_DATA_HPP
|
||||
|
||||
#include "controlled.hpp"
|
||||
#include "nifstream.hpp"
|
||||
#include "nifkey.hpp"
|
||||
#include "base.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
class NiSourceTexture : public Named
|
||||
{
|
||||
public:
|
||||
// Is this an external (references a separate texture file) or
|
||||
// internal (data is inside the nif itself) texture?
|
||||
bool external;
|
||||
|
||||
std::string filename; // In case of external textures
|
||||
NiPixelDataPtr data; // In case of internal textures
|
||||
|
||||
/* Pixel layout
|
||||
0 - Palettised
|
||||
1 - High color 16
|
||||
2 - True color 32
|
||||
3 - Compressed
|
||||
4 - Bumpmap
|
||||
5 - Default */
|
||||
int pixel;
|
||||
|
||||
/* Mipmap format
|
||||
0 - no
|
||||
1 - yes
|
||||
2 - default */
|
||||
int mipmap;
|
||||
|
||||
/* Alpha
|
||||
0 - none
|
||||
1 - binary
|
||||
2 - smooth
|
||||
3 - default (use material alpha, or multiply material with texture if present)
|
||||
*/
|
||||
int alpha;
|
||||
|
||||
void read(NIFStream *nif)
|
||||
{
|
||||
Named::read(nif);
|
||||
|
||||
external = !!nif->getChar();
|
||||
if(external)
|
||||
filename = nif->getString();
|
||||
else
|
||||
{
|
||||
nif->getChar(); // always 1
|
||||
data.read(nif);
|
||||
}
|
||||
|
||||
pixel = nif->getInt();
|
||||
mipmap = nif->getInt();
|
||||
alpha = nif->getInt();
|
||||
|
||||
nif->getChar(); // always 1
|
||||
}
|
||||
|
||||
void post(NIFFile *nif)
|
||||
{
|
||||
Named::post(nif);
|
||||
data.post(nif);
|
||||
}
|
||||
};
|
||||
|
||||
// Common ancestor for several data classes
|
||||
class ShapeData : public Record
|
||||
{
|
||||
|
@ -24,26 +24,11 @@
|
||||
#ifndef OPENMW_COMPONENTS_NIF_EXTRA_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_EXTRA_HPP
|
||||
|
||||
#include "record.hpp"
|
||||
#include "niffile.hpp"
|
||||
#include "recordptr.hpp"
|
||||
#include "base.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
/** A record that can have extra data. The extra data objects
|
||||
themselves decend from the Extra class, and all the extra data
|
||||
connected to an object form a linked list
|
||||
*/
|
||||
class Extra : public Record
|
||||
{
|
||||
public:
|
||||
ExtraPtr extra;
|
||||
|
||||
void read(NIFStream *nif) { extra.read(nif); }
|
||||
void post(NIFFile *nif) { extra.post(nif); }
|
||||
};
|
||||
|
||||
class NiVertWeightsExtraData : public Extra
|
||||
{
|
||||
public:
|
||||
|
@ -4,9 +4,12 @@
|
||||
#include <OgreMatrix4.h>
|
||||
|
||||
#include "controlled.hpp"
|
||||
#include "extra.hpp"
|
||||
#include "data.hpp"
|
||||
#include "property.hpp"
|
||||
#include "niftypes.hpp"
|
||||
#include "controller.hpp"
|
||||
#include "base.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
@ -24,7 +24,7 @@
|
||||
#ifndef OPENMW_COMPONENTS_NIF_PROPERTY_HPP
|
||||
#define OPENMW_COMPONENTS_NIF_PROPERTY_HPP
|
||||
|
||||
#include "controlled.hpp"
|
||||
#include "base.hpp"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user