3 #ifndef OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP
4 #define OPENMW_COMPONENTS_NIF_NIFSTREAM_HPP
29 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
30 pIStream->read((
char*)dest, numInstances *
sizeof(
T));
32 uint8_t* destByteBuffer = (uint8_t*)dest;
33 pIStream->read((
char*)dest, numInstances *
sizeof(
T));
43 for (uint32_t i = 0; i < numInstances; i++)
46 for (uint32_t byte = 0; byte <
sizeof(
T); byte++)
47 u.i |= (((IntegerT)destByteBuffer[i *
sizeof(
T) + byte]) << (byte * 8));
58 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
59 pIStream->read((
char*)dest, numInstances *
sizeof(
T));
61 uint8_t* destByteBuffer = (uint8_t*)dest;
62 pIStream->read((
char*)dest, numInstances *
sizeof(
T));
67 for (uint32_t i = 0; i < numInstances; i++)
70 for (uint32_t byte = 0; byte <
sizeof(
T); byte++)
71 u.i |= ((IntegerT)destByteBuffer[i *
sizeof(
T) + byte]) << (byte * 8);
79 readLittleEndianBufferOfType<1,type,IntegerT>(pIStream, (type*)&val);
94 void skip(
size_t size) {
inp->ignore(size); }
98 return readLittleEndianType<char,char>(
inp);
103 return readLittleEndianType<short,short>(
inp);
108 return readLittleEndianType<unsigned short,unsigned short>(
inp);
113 return readLittleEndianType<int,int>(
inp);
118 return readLittleEndianType<unsigned int,unsigned int>(
inp);
123 return readLittleEndianType<float,uint32_t>(
inp);
129 readLittleEndianBufferOfType<2,float,uint32_t>(
inp, (
float*)&vec._v[0]);
136 readLittleEndianBufferOfType<3, float,uint32_t>(
inp, (
float*)&vec._v[0]);
143 readLittleEndianBufferOfType<4, float,uint32_t>(
inp, (
float*)&vec._v[0]);
150 readLittleEndianBufferOfType<9, float,uint32_t>(
inp, (
float*)&mat.
mValues);
161 std::vector<char> str(length + 1, 0);
163 inp->read(&str[0], length);
170 size_t size = readLittleEndianType<uint32_t,uint32_t>(
inp);
177 std::getline(*
inp, result);
181 void getUShorts(std::vector<unsigned short> &vec,
size_t size)
184 readLittleEndianDynamicBufferOfType<unsigned short,unsigned short>(
inp, &vec.front(), size);
190 readLittleEndianDynamicBufferOfType<float,uint32_t>(
inp, &vec.front(), size);
197 readLittleEndianDynamicBufferOfType<float,uint32_t>(
inp,(
float*) &vec.front(), size*2);
204 readLittleEndianDynamicBufferOfType<float,uint32_t>(
inp, (
float*) &vec.front(), size*3);
211 readLittleEndianDynamicBufferOfType<float,uint32_t>(
inp, (
float*) &vec.front(), size*4);
217 for (
size_t i = 0;i < quat.size();i++)
Definition: niffile.hpp:40
float mValues[3][3]
Definition: niftypes.hpp:37
std::string getString(size_t length)
Read in a string of the given length.
Definition: nifstream.hpp:159
int getInt()
Definition: nifstream.hpp:111
osg::Vec4f getVector4()
Definition: nifstream.hpp:140
osg::Quat getQuaternion()
Definition: nifstream.cpp:7
std::shared_ptr< std::istream > IStreamPtr
Definition: constrainedfilestream.hpp:21
void readLittleEndianDynamicBufferOfType(Files::IStreamPtr &pIStream, T *dest, uint32_t numInstances)
Definition: nifstream.hpp:56
NIFFile *const file
Definition: nifstream.hpp:90
void skip(size_t size)
Definition: nifstream.hpp:94
Matrix3 getMatrix3()
Definition: nifstream.hpp:147
std::string getVersionString()
This is special since the version string doesn't start with a number, and ends with "\n"...
Definition: nifstream.hpp:174
unsigned short getUShort()
Definition: nifstream.hpp:106
void getUShorts(std::vector< unsigned short > &vec, size_t size)
Definition: nifstream.hpp:181
void readLittleEndianBufferOfType(Files::IStreamPtr &pIStream, T *dest)
Definition: nifstream.hpp:27
Transformation getTrafo()
Definition: nifstream.cpp:19
void getQuaternions(std::vector< osg::Quat > &quat, size_t size)
Definition: nifstream.hpp:214
type readLittleEndianType(Files::IStreamPtr &pIStream)
Definition: nifstream.hpp:76
NIFStream(NIFFile *file, Files::IStreamPtr inp)
Definition: nifstream.hpp:92
osg::Vec2f getVector2()
Definition: nifstream.hpp:126
void getVector4s(std::vector< osg::Vec4f > &vec, size_t size)
Definition: nifstream.hpp:207
osg::Vec3f getVector3()
Definition: nifstream.hpp:133
char getChar()
Definition: nifstream.hpp:96
float getFloat()
Definition: nifstream.hpp:121
void getVector2s(std::vector< osg::Vec2f > &vec, size_t size)
Definition: nifstream.hpp:193
Files::IStreamPtr inp
Input stream.
Definition: nifstream.hpp:86
Definition: niftypes.hpp:35
std::string getString()
Read in a string of the length specified in the file.
Definition: nifstream.hpp:168
void getFloats(std::vector< float > &vec, size_t size)
Definition: nifstream.hpp:187
Definition: nifstream.hpp:83
unsigned int getUInt()
Definition: nifstream.hpp:116
short getShort()
Definition: nifstream.hpp:101
void getVector3s(std::vector< osg::Vec3f > &vec, size_t size)
Definition: nifstream.hpp:200