OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
util.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_ESM_UTIL_H
2 #define OPENMW_ESM_UTIL_H
3 
4 #include <osg/Vec3f>
5 #include <osg/Quat>
6 
7 namespace ESM
8 {
9 
10 // format 0, savegames only
11 
12 struct Quaternion
13 {
14  float mValues[4];
15 
17 
18  Quaternion(const osg::Quat& q)
19  {
20  mValues[0] = q.w();
21  mValues[1] = q.x();
22  mValues[2] = q.y();
23  mValues[3] = q.z();
24  }
25 
26  operator osg::Quat () const
27  {
28  return osg::Quat(mValues[1], mValues[2], mValues[3], mValues[0]);
29  }
30 };
31 
32 struct Vector3
33 {
34  float mValues[3];
35 
36  Vector3() {}
37 
38  Vector3(const osg::Vec3f& v)
39  {
40  mValues[0] = v.x();
41  mValues[1] = v.y();
42  mValues[2] = v.z();
43  }
44 
45  operator osg::Vec3f () const
46  {
47  return osg::Vec3f(mValues[0], mValues[1], mValues[2]);
48  }
49 };
50 
51 }
52 
53 #endif
Definition: util.hpp:12
float mValues[4]
Definition: util.hpp:14
Vector3()
Definition: util.hpp:36
Definition: util.hpp:32
Quaternion()
Definition: util.hpp:16
Quaternion(const osg::Quat &q)
Definition: util.hpp:18
float mValues[3]
Definition: util.hpp:34
Vector3(const osg::Vec3f &v)
Definition: util.hpp:38