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: http://openmw.sourceforge.net/
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  http://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 #include <osg/Array>
32 
33 namespace Nif
34 {
35 
36 // Common ancestor for several data classes
37 class ShapeData : public Record
38 {
39 public:
40  osg::ref_ptr<osg::Vec3Array> vertices, normals;
41  osg::ref_ptr<osg::Vec4Array> colors;
42 
43  std::vector< osg::ref_ptr<osg::Vec2Array> > uvlist;
44  osg::Vec3f center;
45  float radius;
46 
47  void read(NIFStream *nif);
48 };
49 
50 class NiTriShapeData : public ShapeData
51 {
52 public:
53  // Triangles, three vertex indices per triangle
54  osg::ref_ptr<osg::DrawElementsUShort> triangles;
55 
56  void read(NIFStream *nif);
57 };
58 
60 {
61 public:
63 
65 
67 
68  std::vector<float> sizes;
69 
70  void read(NIFStream *nif);
71 };
72 
74 {
75 public:
76  std::vector<osg::Quat> rotations;
77 
78  void read(NIFStream *nif);
79 };
80 
81 class NiPosData : public Record
82 {
83 public:
85 
86  void read(NIFStream *nif);
87 };
88 
89 class NiUVData : public Record
90 {
91 public:
93 
94  void read(NIFStream *nif);
95 };
96 
97 class NiFloatData : public Record
98 {
99 public:
101 
102  void read(NIFStream *nif);
103 };
104 
105 class NiPixelData : public Record
106 {
107 public:
108  enum Format
109  {
117  };
119 
120  unsigned int rmask, gmask, bmask, amask;
121  int bpp, mips;
122 
123  struct Mipmap
124  {
125  int width, height;
127  };
128  std::vector<Mipmap> mipmaps;
129 
130  std::vector<unsigned char> data;
131 
132  void read(NIFStream *nif);
133 };
134 
135 class NiColorData : public Record
136 {
137 public:
139 
140  void read(NIFStream *nif);
141 };
142 
143 class NiVisData : public Record
144 {
145 public:
146  struct VisData {
147  float time;
148  bool isSet;
149  };
150  std::vector<VisData> mVis;
151 
152  void read(NIFStream *nif);
153 };
154 
155 class NiSkinInstance : public Record
156 {
157 public:
161 
162  void read(NIFStream *nif);
163  void post(NIFFile *nif);
164 };
165 
166 class NiSkinData : public Record
167 {
168 public:
169  struct VertWeight
170  {
171  unsigned short vertex;
172  float weight;
173  };
174 
175  struct BoneInfo
176  {
178  osg::Vec3f boundSphereCenter;
180  std::vector<VertWeight> weights;
181  };
182 
184  std::vector<BoneInfo> bones;
185 
186  void read(NIFStream *nif);
187 };
188 
189 struct NiMorphData : public Record
190 {
191  struct MorphData {
193  osg::ref_ptr<osg::Vec3Array> mVertices;
194  };
195  std::vector<MorphData> mMorphs;
196 
197  void read(NIFStream *nif);
198 };
199 
200 
201 struct NiKeyframeData : public Record
202 {
204 
205  // may be NULL
209 
212 
213  void read(NIFStream *nif);
214 };
215 
216 } // Namespace
217 #endif
Definition: niffile.hpp:17
float time
Definition: data.hpp:147
std::vector< Mipmap > mipmaps
Definition: data.hpp:128
osg::ref_ptr< osg::DrawElementsUShort > triangles
Definition: data.hpp:54
Definition: data.hpp:166
Definition: data.hpp:123
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:153
osg::Vec3f center
Definition: data.hpp:44
osg::ref_ptr< osg::Vec4Array > colors
Definition: data.hpp:41
Format
Definition: data.hpp:108
Definition: data.hpp:110
boost::shared_ptr< FloatKeyMap > FloatKeyMapPtr
Definition: nifkey.hpp:159
QuaternionKeyMapPtr mRotations
Definition: data.hpp:203
std::vector< unsigned char > data
Definition: data.hpp:130
std::vector< osg::ref_ptr< osg::Vec2Array > > uvlist
Definition: data.hpp:43
bool isSet
Definition: data.hpp:148
unsigned int gmask
Definition: data.hpp:120
float boundSphereRadius
Definition: data.hpp:179
Base class for all records.
Definition: record.hpp:100
std::vector< BoneInfo > bones
Definition: data.hpp:184
std::vector< VisData > mVis
Definition: data.hpp:150
NodeList bones
Definition: data.hpp:160
unsigned int bmask
Definition: data.hpp:120
FloatKeyMapPtr mXRotations
Definition: data.hpp:206
Definition: data.hpp:113
Definition: data.hpp:169
NiSkinDataPtr data
Definition: data.hpp:158
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:93
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:273
FloatKeyMapPtr mZRotations
Definition: data.hpp:208
Definition: data.hpp:37
Definition: data.hpp:201
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:210
std::vector< MorphData > mMorphs
Definition: data.hpp:195
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:159
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:168
int bpp
Definition: data.hpp:121
unsigned int rmask
Definition: data.hpp:120
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:9
int dataOffset
Definition: data.hpp:126
boost::shared_ptr< Vector3KeyMap > Vector3KeyMapPtr
Definition: nifkey.hpp:160
FloatKeyMapPtr mKeyFrames
Definition: data.hpp:192
int numParticles
Definition: data.hpp:62
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:174
FloatKeyMapPtr mScales
Definition: data.hpp:211
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:141
Definition: data.hpp:115
Definition: data.hpp:59
osg::Vec3f boundSphereCenter
Definition: data.hpp:178
Transformation trafo
Definition: data.hpp:183
int width
Definition: data.hpp:125
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:227
Definition: niftypes.hpp:56
osg::ref_ptr< osg::Vec3Array > mVertices
Definition: data.hpp:193
float weight
Definition: data.hpp:172
Definition: data.hpp:114
float radius
Definition: data.hpp:45
Definition: data.hpp:105
std::vector< osg::Quat > rotations
Definition: data.hpp:76
Definition: data.hpp:191
FloatKeyMapPtr mYRotations
Definition: data.hpp:207
Vector4KeyMapPtr mKeyMap
Definition: data.hpp:138
Vector3KeyMapPtr mKeyList
Definition: data.hpp:84
Definition: data.hpp:116
Vector3KeyMapPtr mTranslations
Definition: data.hpp:210
Definition: data.hpp:155
FloatKeyMapPtr mKeyList
Definition: data.hpp:100
std::vector< VertWeight > weights
Definition: data.hpp:180
boost::shared_ptr< Vector4KeyMap > Vector4KeyMapPtr
Definition: nifkey.hpp:161
Transformation trafo
Definition: data.hpp:177
Definition: data.hpp:89
Definition: data.hpp:143
boost::shared_ptr< QuaternionKeyMap > QuaternionKeyMapPtr
Definition: nifkey.hpp:162
Definition: data.hpp:97
Definition: data.hpp:135
Definition: data.hpp:175
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:123
Definition: data.hpp:146
void post(NIFFile *nif)
Does post-processing, after the entire tree is loaded.
Definition: data.cpp:16
unsigned int amask
Definition: data.hpp:120
Definition: nifstream.hpp:26
Definition: data.hpp:81
Definition: data.hpp:50
int activeCount
Definition: data.hpp:66
Format fmt
Definition: data.hpp:118
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:216
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:257
Definition: data.hpp:112
FloatKeyMapPtr mKeyList[4]
Definition: data.hpp:92
Definition: data.hpp:111
std::vector< float > sizes
Definition: data.hpp:68
int height
Definition: data.hpp:125
Definition: data.hpp:73
float particleRadius
Definition: data.hpp:64
Definition: data.hpp:189
unsigned short vertex
Definition: data.hpp:171
NodePtr root
Definition: data.hpp:159
int mips
Definition: data.hpp:121
osg::ref_ptr< osg::Vec3Array > vertices
Definition: data.hpp:40
void read(NIFStream *nif)
Parses the record from file.
Definition: data.cpp:39
osg::ref_ptr< osg::Vec3Array > normals
Definition: data.hpp:40