OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
data.hpp
Go to the documentation of this file.
1 /*
2  OpenMW - The completely unofficial reimplementation of Morrowind
3  Copyright (C) 2008-2010 Nicolay Korslund
4  Email: < korslund@gmail.com >
5  WWW: https://openmw.org/
6 
7  This file (data.h) is part of the OpenMW package.
8 
9  OpenMW is distributed as free software: you can redistribute it
10  and/or modify it under the terms of the GNU General Public License
11  version 3, as published by the Free Software Foundation.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  version 3 along with this program. If not, see
20  https://www.gnu.org/licenses/ .
21 
22  */
23 
24 #ifndef OPENMW_COMPONENTS_NIF_DATA_HPP
25 #define OPENMW_COMPONENTS_NIF_DATA_HPP
26 
27 #include "base.hpp"
28 
29 #include "niftypes.hpp" // Transformation
30 
31 namespace Nif
32 {
33 
34 // Common ancestor for several data classes
35 class ShapeData : public Record
36 {
37 public:
38  std::vector<osg::Vec3f> vertices, normals;
39  std::vector<osg::Vec4f> colors;
40  std::vector< std::vector<osg::Vec2f> > uvlist;
41  osg::Vec3f center;
42  float radius;
43 
44  void read(NIFStream *nif);
45 };
46 
47 class NiTriShapeData : public ShapeData
48 {
49 public:
50  // Triangles, three vertex indices per triangle
51  std::vector<unsigned short> triangles;
52 
53  void read(NIFStream *nif);
54 };
55 
57 {
58 public:
60 
62 
64 
65  std::vector<float> sizes;
66 
67  void read(NIFStream *nif);
68 };
69 
71 {
72 public:
73  std::vector<osg::Quat> rotations;
74 
75  void read(NIFStream *nif);
76 };
77 
78 class NiPosData : public Record
79 {
80 public:
82 
83  void read(NIFStream *nif);
84 };
85 
86 class NiUVData : public Record
87 {
88 public:
90 
91  void read(NIFStream *nif);
92 };
93 
94 class NiFloatData : public Record
95 {
96 public:
98 
99  void read(NIFStream *nif);
100 };
101 
102 class NiPixelData : public Record
103 {
104 public:
105  enum Format
106  {
114  };
116 
117  unsigned int rmask, gmask, bmask, amask;
119 
120  struct Mipmap
121  {
122  int width, height;
124  };
125  std::vector<Mipmap> mipmaps;
126 
127  std::vector<unsigned char> data;
128 
129  void read(NIFStream *nif);
130 };
131 
132 class NiColorData : public Record
133 {
134 public:
136 
137  void read(NIFStream *nif);
138 };
139 
140 class NiVisData : public Record
141 {
142 public:
143  struct VisData {
144  float time;
145  bool isSet;
146  };
147  std::vector<VisData> mVis;
148 
149  void read(NIFStream *nif);
150 };
151 
152 class NiSkinInstance : public Record
153 {
154 public:
158 
159  void read(NIFStream *nif);
160  void post(NIFFile *nif);
161 };
162 
163 class NiSkinData : public Record
164 {
165 public:
166  struct VertWeight
167  {
168  unsigned short vertex;
169  float weight;
170  };
171 
172  struct BoneInfo
173  {
175  osg::Vec3f boundSphereCenter;
177  std::vector<VertWeight> weights;
178  };
179 
181  std::vector<BoneInfo> bones;
182 
183  void read(NIFStream *nif);
184 };
185 
186 struct NiMorphData : public Record
187 {
188  struct MorphData {
190  std::vector<osg::Vec3f> mVertices;
191  };
192  std::vector<MorphData> mMorphs;
193 
194  void read(NIFStream *nif);
195 };
196 
197 
198 struct NiKeyframeData : public Record
199 {
201 
202  // may be NULL
206 
209 
210  void read(NIFStream *nif);
211 };
212 
213 } // Namespace
214 #endif
Definition: niffile.hpp:40
int numberOfMipmaps
Definition: data.hpp:118
float time
Definition: data.hpp:144
std::vector< Mipmap > mipmaps
Definition: data.hpp:125
Definition: data.hpp:163
Definition: data.hpp:120
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:121
osg::Vec3f center
Definition: data.hpp:41
Format
Definition: data.hpp:105
Definition: data.hpp:107
std::shared_ptr< QuaternionKeyMap > QuaternionKeyMapPtr
Definition: nifkey.hpp:160
std::vector< osg::Vec3f > mVertices
Definition: data.hpp:190
QuaternionKeyMapPtr mRotations
Definition: data.hpp:200
std::vector< unsigned char > data
Definition: data.hpp:127
bool isSet
Definition: data.hpp:145
unsigned int gmask
Definition: data.hpp:117
std::vector< std::vector< osg::Vec2f > > uvlist
Definition: data.hpp:40
float boundSphereRadius
Definition: data.hpp:176
Base class for all records.
Definition: record.hpp:101
std::vector< BoneInfo > bones
Definition: data.hpp:181
std::vector< VisData > mVis
Definition: data.hpp:147
NodeList bones
Definition: data.hpp:157
unsigned int bmask
Definition: data.hpp:117
FloatKeyMapPtr mXRotations
Definition: data.hpp:203
Definition: data.hpp:110
Definition: data.hpp:166
NiSkinDataPtr data
Definition: data.hpp:155
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:70
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:240
FloatKeyMapPtr mZRotations
Definition: data.hpp:205
Definition: data.hpp:35
Definition: data.hpp:198
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:178
std::vector< MorphData > mMorphs
Definition: data.hpp:192
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:127
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:136
int bpp
Definition: data.hpp:118
unsigned int rmask
Definition: data.hpp:117
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:6
int dataOffset
Definition: data.hpp:123
FloatKeyMapPtr mKeyFrames
Definition: data.hpp:189
std::shared_ptr< Vector4KeyMap > Vector4KeyMapPtr
Definition: nifkey.hpp:159
int numParticles
Definition: data.hpp:59
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:142
FloatKeyMapPtr mScales
Definition: data.hpp:208
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:110
Definition: data.hpp:112
Definition: data.hpp:56
osg::Vec3f boundSphereCenter
Definition: data.hpp:175
Transformation trafo
Definition: data.hpp:180
std::shared_ptr< Vector3KeyMap > Vector3KeyMapPtr
Definition: nifkey.hpp:158
int width
Definition: data.hpp:122
std::vector< osg::Vec4f > colors
Definition: data.hpp:39
std::shared_ptr< FloatKeyMap > FloatKeyMapPtr
Definition: nifkey.hpp:157
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:195
Definition: niftypes.hpp:56
float weight
Definition: data.hpp:169
Definition: data.hpp:111
float radius
Definition: data.hpp:42
Definition: data.hpp:102
std::vector< osg::Quat > rotations
Definition: data.hpp:73
std::vector< osg::Vec3f > vertices
Definition: data.hpp:38
Definition: data.hpp:188
FloatKeyMapPtr mYRotations
Definition: data.hpp:204
Vector4KeyMapPtr mKeyMap
Definition: data.hpp:135
Vector3KeyMapPtr mKeyList
Definition: data.hpp:81
Definition: data.hpp:113
Vector3KeyMapPtr mTranslations
Definition: data.hpp:207
Definition: data.hpp:152
FloatKeyMapPtr mKeyList
Definition: data.hpp:97
std::vector< VertWeight > weights
Definition: data.hpp:177
Transformation trafo
Definition: data.hpp:174
Definition: data.hpp:86
Definition: data.hpp:140
Definition: data.hpp:94
Definition: data.hpp:132
Definition: data.hpp:172
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:93
std::vector< unsigned short > triangles
Definition: data.hpp:51
Definition: data.hpp:143
void post(NIFFile *nif)
Does post-processing, after the entire tree is loaded.
Definition: data.cpp:13
unsigned int amask
Definition: data.hpp:117
Definition: nifstream.hpp:83
Definition: data.hpp:78
Definition: data.hpp:47
int activeCount
Definition: data.hpp:63
Format fmt
Definition: data.hpp:115
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:184
std::vector< osg::Vec3f > normals
Definition: data.hpp:38
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:225
Definition: data.hpp:109
FloatKeyMapPtr mKeyList[4]
Definition: data.hpp:89
Definition: data.hpp:108
std::vector< float > sizes
Definition: data.hpp:65
int height
Definition: data.hpp:122
Definition: data.hpp:70
float particleRadius
Definition: data.hpp:61
Definition: data.hpp:186
unsigned short vertex
Definition: data.hpp:168
NodePtr root
Definition: data.hpp:156
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:34