2014-10-28 07:12:36 +00:00
|
|
|
#include "nifstream.hpp"
|
|
|
|
//For error reporting
|
|
|
|
#include "niffile.hpp"
|
|
|
|
|
|
|
|
namespace Nif
|
|
|
|
{
|
2018-07-10 09:32:52 +00:00
|
|
|
osg::Quat NIFStream::getQuaternion()
|
|
|
|
{
|
|
|
|
float f[4];
|
|
|
|
readLittleEndianBufferOfType<4, float,uint32_t>(inp, (float*)&f);
|
|
|
|
osg::Quat quat;
|
|
|
|
quat.w() = f[0];
|
|
|
|
quat.x() = f[1];
|
|
|
|
quat.y() = f[2];
|
|
|
|
quat.z() = f[3];
|
|
|
|
return quat;
|
|
|
|
}
|
2014-10-28 07:12:36 +00:00
|
|
|
|
2018-07-10 09:32:52 +00:00
|
|
|
Transformation NIFStream::getTrafo()
|
|
|
|
{
|
|
|
|
Transformation t;
|
|
|
|
t.pos = getVector3();
|
|
|
|
t.rotation = getMatrix3();
|
|
|
|
t.scale = getFloat();
|
|
|
|
return t;
|
|
|
|
}
|
2019-12-29 12:53:44 +00:00
|
|
|
|
|
|
|
///Currently specific for 4.0.0.2 and earlier
|
|
|
|
bool NIFStream::getBoolean()
|
|
|
|
{
|
2020-01-02 10:09:54 +00:00
|
|
|
return getInt() != 0;
|
2019-12-29 12:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///Read in a string, either from the string table using the index (currently absent) or from the stream using the specified length
|
|
|
|
std::string NIFStream::getString()
|
|
|
|
{
|
|
|
|
return getSizedString();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convenience utility functions: get the versions of the currently read file
|
2020-02-02 15:40:11 +00:00
|
|
|
unsigned int NIFStream::getVersion() const { return file->getVersion(); }
|
|
|
|
unsigned int NIFStream::getUserVersion() const { return file->getBethVersion(); }
|
|
|
|
unsigned int NIFStream::getBethVersion() const { return file->getBethVersion(); }
|
2014-10-28 07:12:36 +00:00
|
|
|
}
|