2014-08-24 17:27:09 +00:00
|
|
|
///Functions used to read raw binary data from .nif files
|
|
|
|
|
2013-02-24 21:51:56 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP
|
|
|
|
#define OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP
|
2013-01-05 21:03:05 +00:00
|
|
|
|
2014-08-24 17:27:09 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
#include <OgreDataStream.h>
|
|
|
|
#include <OgreVector2.h>
|
|
|
|
#include <OgreVector3.h>
|
|
|
|
#include <OgreVector4.h>
|
|
|
|
#include <OgreMatrix3.h>
|
|
|
|
#include <OgreQuaternion.h>
|
2014-10-19 06:40:18 +00:00
|
|
|
#include <OgreStringConverter.h>
|
2014-08-24 17:27:09 +00:00
|
|
|
|
|
|
|
#include "niftypes.hpp"
|
|
|
|
|
2013-01-05 21:03:05 +00:00
|
|
|
namespace Nif
|
|
|
|
{
|
|
|
|
|
|
|
|
class NIFFile;
|
|
|
|
|
|
|
|
class NIFStream {
|
|
|
|
|
|
|
|
/// Input stream
|
|
|
|
Ogre::DataStreamPtr inp;
|
|
|
|
|
2014-10-28 07:12:36 +00:00
|
|
|
uint8_t read_byte();
|
|
|
|
uint16_t read_le16();
|
|
|
|
uint32_t read_le32();
|
|
|
|
float read_le32f();
|
2013-01-05 21:03:05 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NIFFile * const file;
|
|
|
|
|
2015-04-25 18:37:42 +00:00
|
|
|
NIFStream (NIFFile * file, Ogre::DataStreamPtr inp): inp (inp), file (file) {}
|
2013-01-05 21:03:05 +00:00
|
|
|
|
|
|
|
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(); }
|
2014-10-31 09:01:26 +00:00
|
|
|
unsigned int getUInt() { return read_le32(); }
|
2013-01-05 21:03:05 +00:00
|
|
|
float getFloat() { return read_le32f(); }
|
|
|
|
|
2014-10-28 07:12:36 +00:00
|
|
|
Ogre::Vector2 getVector2();
|
|
|
|
Ogre::Vector3 getVector3();
|
|
|
|
Ogre::Vector4 getVector4();
|
|
|
|
Ogre::Matrix3 getMatrix3();
|
|
|
|
Ogre::Quaternion getQuaternion();
|
|
|
|
Transformation getTrafo();
|
|
|
|
|
|
|
|
///Read in a string of the given length
|
|
|
|
std::string getString(size_t length);
|
|
|
|
///Read in a string of the length specified in the file
|
|
|
|
std::string getString();
|
2014-12-12 06:48:57 +00:00
|
|
|
///This is special since the version string doesn't start with a number, and ends with "\n"
|
|
|
|
std::string getVersionString();
|
2014-10-28 07:12:36 +00:00
|
|
|
|
2015-01-06 22:35:40 +00:00
|
|
|
void getShorts(std::vector<short> &vec, size_t size);
|
|
|
|
void getFloats(std::vector<float> &vec, size_t size);
|
|
|
|
void getVector2s(std::vector<Ogre::Vector2> &vec, size_t size);
|
|
|
|
void getVector3s(std::vector<Ogre::Vector3> &vec, size_t size);
|
|
|
|
void getVector4s(std::vector<Ogre::Vector4> &vec, size_t size);
|
|
|
|
void getQuaternions(std::vector<Ogre::Quaternion> &quat, size_t size);
|
2013-01-05 21:03:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|