OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
property.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 (property.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_PROPERTY_HPP
25 #define OPENMW_COMPONENTS_NIF_PROPERTY_HPP
26 
27 #include "base.hpp"
28 
29 namespace Nif
30 {
31 
32 class Property : public Named
33 {
34 public:
35  // The meaning of these depends on the actual property type.
36  unsigned int flags;
37 
38  void read(NIFStream *nif);
39 };
40 
42 {
43 public:
44  // A sub-texture
45  struct Texture
46  {
47  /* Clamp mode
48  0 - clampS clampT
49  1 - clampS wrapT
50  2 - wrapS clampT
51  3 - wrapS wrapT
52  */
53 
54  /* Filter:
55  0 - nearest
56  1 - bilinear
57  2 - trilinear
58  3, 4, 5 - who knows
59  */
60  bool inUse;
62 
64  short unknown2;
65 
66  void read(NIFStream *nif);
67  void post(NIFFile *nif);
68  };
69 
70  /* Apply mode:
71  0 - replace
72  1 - decal
73  2 - modulate
74  3 - hilight // These two are for PS2 only?
75  4 - hilight2
76  */
77  int apply;
78 
79  /*
80  * The textures in this list are as follows:
81  *
82  * 0 - Base texture
83  * 1 - Dark texture
84  * 2 - Detail texture
85  * 3 - Gloss texture (never used?)
86  * 4 - Glow texture
87  * 5 - Bump map texture
88  * 6 - Decal texture
89  */
91  {
99  NumTextures = 7 // Sentry value
100  };
101 
103 
104  void read(NIFStream *nif);
105  void post(NIFFile *nif);
106 };
107 
108 class NiFogProperty : public Property
109 {
110 public:
111  float mFogDepth;
112  osg::Vec3f mColour;
113 
114  void read(NIFStream *nif);
115 };
116 
117 // These contain no other data than the 'flags' field in Property
118 class NiShadeProperty : public Property { };
119 class NiDitherProperty : public Property { };
120 class NiZBufferProperty : public Property { };
121 class NiSpecularProperty : public Property { };
122 class NiWireframeProperty : public Property { };
123 
124 // The rest are all struct-based
125 template <typename T>
127 {
128  T data;
129 
130  void read(NIFStream *nif)
131  {
132  Property::read(nif);
133  data.read(nif);
134  }
135 };
136 
138 {
139  // The vector components are R,G,B
142 
143  void read(NIFStream *nif);
144 };
145 
147 {
148  /* Vertex mode:
149  0 - source ignore
150  1 - source emmisive
151  2 - source amb diff
152 
153  Lighting mode
154  0 - lighting emmisive
155  1 - lighting emmisive ambient/diffuse
156  */
158 
159  void read(NIFStream *nif);
160 };
161 
163 {
164  /*
165  In NiAlphaProperty, the flags have the following meaning:
166 
167  Bit 0 : alpha blending enable
168  Bits 1-4 : source blend mode
169  Bits 5-8 : destination blend mode
170  Bit 9 : alpha test enable
171  Bit 10-12 : alpha test mode
172  Bit 13 : no sorter flag ( disables triangle sorting )
173 
174  blend modes (glBlendFunc):
175  0000 GL_ONE
176  0001 GL_ZERO
177  0010 GL_SRC_COLOR
178  0011 GL_ONE_MINUS_SRC_COLOR
179  0100 GL_DST_COLOR
180  0101 GL_ONE_MINUS_DST_COLOR
181  0110 GL_SRC_ALPHA
182  0111 GL_ONE_MINUS_SRC_ALPHA
183  1000 GL_DST_ALPHA
184  1001 GL_ONE_MINUS_DST_ALPHA
185  1010 GL_SRC_ALPHA_SATURATE
186 
187  test modes (glAlphaFunc):
188  000 GL_ALWAYS
189  001 GL_LESS
190  010 GL_EQUAL
191  011 GL_LEQUAL
192  100 GL_GREATER
193  101 GL_NOTEQUAL
194  110 GL_GEQUAL
195  111 GL_NEVER
196 
197  Taken from:
198  http://niftools.sourceforge.net/doc/nif/NiAlphaProperty.html
199  */
200 
201  // Tested against when certain flags are set (see above.)
202  unsigned char threshold;
203 
204  void read(NIFStream *nif);
205 };
206 
207 /*
208  Docs taken from:
209  http://niftools.sourceforge.net/doc/nif/NiStencilProperty.html
210  */
212 {
213  // Is stencil test enabled?
214  unsigned char enabled;
215 
216  /*
217  0 TEST_NEVER
218  1 TEST_LESS
219  2 TEST_EQUAL
220  3 TEST_LESS_EQUAL
221  4 TEST_GREATER
222  5 TEST_NOT_EQUAL
223  6 TEST_GREATER_EQUAL
224  7 TEST_NEVER (though nifskope comment says TEST_ALWAYS, but ingame it is TEST_NEVER)
225  */
227  unsigned stencilRef;
228  unsigned stencilMask;
229  /*
230  Stencil test fail action, depth test fail action and depth test pass action:
231  0 ACTION_KEEP
232  1 ACTION_ZERO
233  2 ACTION_REPLACE
234  3 ACTION_INCREMENT
235  4 ACTION_DECREMENT
236  5 ACTION_INVERT
237  */
241  /*
242  Face draw mode:
243  0 DRAW_CCW_OR_BOTH
244  1 DRAW_CCW [default]
245  2 DRAW_CW
246  3 DRAW_BOTH
247  */
248  int drawMode;
249 
250  void read(NIFStream *nif);
251 };
252 
253 class NiAlphaProperty : public StructPropT<S_AlphaProperty> { };
254 class NiMaterialProperty : public StructPropT<S_MaterialProperty> { };
255 class NiVertexColorProperty : public StructPropT<S_VertexColorProperty> { };
256 class NiStencilProperty : public StructPropT<S_StencilProperty> { };
257 
258 } // Namespace
259 #endif
osg::Vec3f ambient
Definition: property.hpp:140
void read(NIFStream *nif)
Definition: property.cpp:76
Definition: niffile.hpp:17
osg::Vec3f specular
Definition: property.hpp:140
void read(NIFStream *nif)
Parses the record from file.
Definition: property.cpp:9
unsigned char enabled
Definition: property.hpp:214
float glossiness
Definition: property.hpp:141
Definition: property.hpp:253
bool inUse
Definition: property.hpp:60
Definition: property.hpp:120
int drawMode
Definition: property.hpp:248
unsigned char threshold
Definition: property.hpp:202
void read(NIFStream *nif)
Definition: property.cpp:86
Definition: property.hpp:254
Definition: property.hpp:122
Definition: property.hpp:211
Definition: property.hpp:45
Definition: property.hpp:93
osg::Vec3f emissive
Definition: property.hpp:140
Definition: property.hpp:119
int zPassAction
Definition: property.hpp:240
Definition: property.hpp:146
Definition: property.hpp:98
void post(NIFFile *nif)
Does post-processing, after the entire tree is loaded.
Definition: property.cpp:61
void read(NIFStream *nif)
Definition: property.cpp:97
Texture textures[7]
Definition: property.hpp:102
int uvSet
Definition: property.hpp:63
TextureType
Definition: property.hpp:90
void read(NIFStream *nif)
Definition: property.cpp:92
Definition: property.hpp:162
float alpha
Definition: property.hpp:141
void post(NIFFile *nif)
Definition: property.cpp:31
int zFailAction
Definition: property.hpp:239
Definition: property.hpp:92
Has name, extra-data and controller.
Definition: base.hpp:59
Definition: property.hpp:108
osg::Vec3f mColour
Definition: property.hpp:112
Definition: property.hpp:97
Definition: property.hpp:95
float mFogDepth
Definition: property.hpp:111
int vertmode
Definition: property.hpp:157
Definition: property.hpp:99
Definition: property.hpp:118
void read(NIFStream *nif)
Parses the record from file.
Definition: property.cpp:68
Definition: property.hpp:126
T data
Definition: property.hpp:128
void read(NIFStream *nif)
Parses the record from file.
Definition: property.cpp:36
NiSourceTexturePtr texture
Definition: property.hpp:61
Definition: property.hpp:256
unsigned int flags
Definition: property.hpp:36
int lightmode
Definition: property.hpp:157
int failAction
Definition: property.hpp:238
void read(NIFStream *nif)
Definition: property.cpp:15
unsigned stencilRef
Definition: property.hpp:227
unsigned stencilMask
Definition: property.hpp:228
Definition: property.hpp:121
Definition: property.hpp:41
Definition: nifstream.hpp:26
Definition: property.hpp:32
Definition: property.hpp:96
int compareFunc
Definition: property.hpp:226
osg::Vec3f diffuse
Definition: property.hpp:140
int apply
Definition: property.hpp:77
void read(NIFStream *nif)
Parses the record from file.
Definition: property.hpp:130
Definition: property.hpp:94
Definition: property.hpp:255
Definition: property.hpp:137
int filter
Definition: property.hpp:63
short unknown2
Definition: property.hpp:64
int clamp
Definition: property.hpp:63