@ -32,104 +32,116 @@ namespace Nif
class Property : public Named
{
public :
// The meaning of these depends on the actual property type.
int flags ;
void read ( NIFFile * nif )
{
Named : : read ( nif ) ;
flags = nif - > getShort ( ) ;
}
// The meaning of these depends on the actual property type.
int flags ;
void read ( NIFFile * nif )
{
Named : : read ( nif ) ;
flags = nif - > getShort ( ) ;
}
} ;
class NiTexturingProperty : public Property
{
public :
// A sub-texture
struct Texture
{
/* Clamp mode
0 - clampS clampT
1 - clampS wrapT
2 - wrapS clampT
3 - wrapS wrapT
*/
/* Filter:
0 - nearest
1 - bilinear
2 - trilinear
3 , 4 , 5 - who knows
// A sub-texture
struct Texture
{
/* Clamp mode
0 - clampS clampT
1 - clampS wrapT
2 - wrapS clampT
3 - wrapS wrapT
*/
/* Filter:
0 - nearest
1 - bilinear
2 - trilinear
3 , 4 , 5 - who knows
*/
bool inUse ;
NiSourceTexturePtr texture ;
int clamp , set , filter ;
short unknown2 ;
void read ( NIFFile * nif )
{
inUse = ! ! nif - > getInt ( ) ;
if ( ! inUse ) return ;
texture . read ( nif ) ;
clamp = nif - > getInt ( ) ;
filter = nif - > getInt ( ) ;
set = nif - > getInt ( ) ;
// I have no idea, but I think these are actually two
// PS2-specific shorts (ps2L and ps2K), followed by an unknown
// short.
nif - > skip ( 6 ) ;
}
void post ( NIFFile * nif )
{
texture . post ( nif ) ;
}
} ;
/* Apply mode:
0 - replace
1 - decal
2 - modulate
3 - hilight // These two are for PS2 only?
4 - hilight2
*/
bool inUse ;
NiSourceTexturePtr texture ;
int clamp , set , filter ;
short unknown2 ;
int apply ;
/*
* The textures in this list are as follows :
*
* 0 - Base texture
* 1 - Dark texture
* 2 - Detail texture
* 3 - Gloss texture ( never used ? )
* 4 - Glow texture
* 5 - Bump map texture
* 6 - Decal texture
*/
Texture textures [ 7 ] ;
void read ( NIFFile * nif )
{
inUse = ! ! nif - > getInt ( ) ;
if ( ! inUse ) return ;
texture . read ( nif ) ;
clamp = nif - > getInt ( ) ;
filter = nif - > getInt ( ) ;
set = nif - > getInt ( ) ;
// I have no idea, but I think these are actually two
// PS2-specific shorts (ps2L and ps2K), followed by an unknown
// short.
nif - > skip ( 6 ) ;
Property : : read ( nif ) ;
apply = nif - > getInt ( ) ;
// Unknown, always 7. Probably the number of textures to read
// below
nif - > getInt ( ) ;
textures [ 0 ] . read ( nif ) ; // Base
textures [ 1 ] . read ( nif ) ; // Dark
textures [ 2 ] . read ( nif ) ; // Detail
textures [ 3 ] . read ( nif ) ; // Gloss (never present)
textures [ 4 ] . read ( nif ) ; // Glow
textures [ 5 ] . read ( nif ) ; // Bump map
if ( textures [ 5 ] . inUse )
{
// Ignore these at the moment
/*float lumaScale =*/ nif - > getFloat ( ) ;
/*float lumaOffset =*/ nif - > getFloat ( ) ;
/*const Vector4 *lumaMatrix =*/ nif - > getVector4 ( ) ;
}
textures [ 6 ] . read ( nif ) ; // Decal
}
void post ( NIFFile * nif )
{
Property : : post ( nif ) ;
for ( int i = 0 ; i < 7 ; i + + )
textures [ i ] . post ( nif ) ;
}
} ;
/* Apply mode:
0 - replace
1 - decal
2 - modulate
3 - hilight // These two are for PS2 only?
4 - hilight2
*/
int apply ;
/*
* The textures in this list are as follows :
*
* 0 - Base texture
* 1 - Dark texture
* 2 - Detail texture
* 3 - Gloss texture ( never used ? )
* 4 - Glow texture
* 5 - Bump map texture
* 6 - Decal texture
*/
Texture textures [ 7 ] ;
void read ( NIFFile * nif )
{
Property : : read ( nif ) ;
apply = nif - > getInt ( ) ;
// Unknown, always 7. Probably the number of textures to read
// below
nif - > getInt ( ) ;
textures [ 0 ] . read ( nif ) ; // Base
textures [ 1 ] . read ( nif ) ; // Dark
textures [ 2 ] . read ( nif ) ; // Detail
textures [ 3 ] . read ( nif ) ; // Gloss (never present)
textures [ 4 ] . read ( nif ) ; // Glow
textures [ 5 ] . read ( nif ) ; // Bump map
if ( textures [ 5 ] . inUse )
{
// Ignore these at the moment
/*float lumaScale =*/ nif - > getFloat ( ) ;
/*float lumaOffset =*/ nif - > getFloat ( ) ;
/*const Vector4 *lumaMatrix =*/ nif - > getVector4 ( ) ;
}
textures [ 6 ] . read ( nif ) ; // Decal
}
} ;
// These contain no other data than the 'flags' field in Property
@ -140,88 +152,88 @@ typedef Property NiSpecularProperty;
typedef Property NiWireframeProperty ;
// The rest are all struct-based
template < typename Struct >
template < typename T >
struct StructPropT : Property
{
const Struct * data ;
const T * data ;
void read ( NIFFile * nif )
{
Property : : read ( nif ) ;
data = nif - > getPtr < Struct > ( ) ;
}
void read ( NIFFile * nif )
{
Property : : read ( nif ) ;
data = nif - > getPtr < T > ( ) ;
}
} ;
struct S_MaterialProperty
{
// The vector components are R,G,B
Vector ambient , diffuse , specular , emissive ;
float glossiness , alpha ;
// The vector components are R,G,B
Vector ambient , diffuse , specular , emissive ;
float glossiness , alpha ;
} ;
struct S_VertexColorProperty
{
/* Vertex mode:
0 - source ignore
1 - source emmisive
2 - source amb diff
Lighting mode
0 - lighting emmisive
1 - lighting emmisive ambient / diffuse
*/
int vertmode , lightmode ;
/* Vertex mode:
0 - source ignore
1 - source emmisive
2 - source amb diff
Lighting mode
0 - lighting emmisive
1 - lighting emmisive ambient / diffuse
*/
int vertmode , lightmode ;
} ;
struct S_AlphaProperty
{
/*
In NiAlphaProperty , the flags have the following meaning :
Bit 0 : alpha blending enable
Bits 1 - 4 : source blend mode
Bits 5 - 8 : destination blend mode
Bit 9 : alpha test enable
Bit 10 - 12 : alpha test mode
Bit 13 : no sorter flag ( disables triangle sorting )
blend modes ( glBlendFunc ) :
0000 GL_ONE
0001 GL_ZERO
0010 GL_SRC_COLOR
0011 GL_ONE_MINUS_SRC_COLOR
0100 GL_DST_COLOR
0101 GL_ONE_MINUS_DST_COLOR
0110 GL_SRC_ALPHA
0111 GL_ONE_MINUS_SRC_ALPHA
1000 GL_DST_ALPHA
1001 GL_ONE_MINUS_DST_ALPHA
1010 GL_SRC_ALPHA_SATURATE
test modes ( glAlphaFunc ) :
000 GL_ALWAYS
001 GL_LESS
010 GL_EQUAL
011 GL_LEQUAL
100 GL_GREATER
101 GL_NOTEQUAL
110 GL_GEQUAL
111 GL_NEVER
Taken from :
http : //niftools.sourceforge.net/doc/nif/NiAlphaProperty.html
Right now we only use standard alpha blending ( see the Ogre code
that sets it up ) and it appears that this is the only blending
used in the original game . Bloodmoon ( along with several mods ) do
however use other settings , such as discarding pixel values with
alpha < 1.0 . This is faster because we don ' t have to mess with the
depth stuff like we did for blending . And OGRE has settings for
this too .
*/
// Tested against when certain flags are set (see above.)
unsigned char threshold ;
/*
In NiAlphaProperty , the flags have the following meaning :
Bit 0 : alpha blending enable
Bits 1 - 4 : source blend mode
Bits 5 - 8 : destination blend mode
Bit 9 : alpha test enable
Bit 10 - 12 : alpha test mode
Bit 13 : no sorter flag ( disables triangle sorting )
blend modes ( glBlendFunc ) :
0000 GL_ONE
0001 GL_ZERO
0010 GL_SRC_COLOR
0011 GL_ONE_MINUS_SRC_COLOR
0100 GL_DST_COLOR
0101 GL_ONE_MINUS_DST_COLOR
0110 GL_SRC_ALPHA
0111 GL_ONE_MINUS_SRC_ALPHA
1000 GL_DST_ALPHA
1001 GL_ONE_MINUS_DST_ALPHA
1010 GL_SRC_ALPHA_SATURATE
test modes ( glAlphaFunc ) :
000 GL_ALWAYS
001 GL_LESS
010 GL_EQUAL
011 GL_LEQUAL
100 GL_GREATER
101 GL_NOTEQUAL
110 GL_GEQUAL
111 GL_NEVER
Taken from :
http : //niftools.sourceforge.net/doc/nif/NiAlphaProperty.html
Right now we only use standard alpha blending ( see the Ogre code
that sets it up ) and it appears that this is the only blending
used in the original game . Bloodmoon ( along with several mods ) do
however use other settings , such as discarding pixel values with
alpha < 1.0 . This is faster because we don ' t have to mess with the
depth stuff like we did for blending . And OGRE has settings for
this too .
*/
// Tested against when certain flags are set (see above.)
unsigned char threshold ;
} ;
typedef StructPropT < S_AlphaProperty > NiAlphaProperty ;