mirror of https://github.com/OpenMW/openmw.git
Added NiSourceTexture, NiTexturingProperty
parent
4128462add
commit
c9a42f85eb
@ -0,0 +1,86 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008-2010 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.sourceforge.net/
|
||||
|
||||
This file (data.h) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _NIF_DATA_H_
|
||||
#define _NIF_DATA_H_
|
||||
|
||||
#include "controlled.h"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
struct NiSourceTexture : Named
|
||||
{
|
||||
// Is this an external (references a separate texture file) or
|
||||
// internal (data is inside the nif itself) texture?
|
||||
bool external;
|
||||
|
||||
SString filename; // In case of external textures
|
||||
NiPixelDataPtr data; // In case of internal textures
|
||||
|
||||
/* Pixel layout
|
||||
0 - Palettised
|
||||
1 - High color 16
|
||||
2 - True color 32
|
||||
3 - Compressed
|
||||
4 - Bumpmap
|
||||
5 - Default */
|
||||
int pixel;
|
||||
|
||||
/* Mipmap format
|
||||
0 - no
|
||||
1 - yes
|
||||
2 - default */
|
||||
int mipmap;
|
||||
|
||||
/* Alpha
|
||||
0 - none
|
||||
1 - binary
|
||||
2 - smooth
|
||||
3 - default (use material alpha, or multiply material with texture if present)
|
||||
*/
|
||||
int alpha;
|
||||
|
||||
void read(NIFFile *nif)
|
||||
{
|
||||
Named::read(nif);
|
||||
|
||||
external = nif->getByte();
|
||||
|
||||
if(external) filename = nif->getString();
|
||||
else
|
||||
{
|
||||
nif->getByte(); // always 1
|
||||
data.read(nif);
|
||||
}
|
||||
|
||||
pixel = nif->getInt();
|
||||
mipmap = nif->getInt();
|
||||
alpha = nif->getInt();
|
||||
|
||||
nif->getByte(); // always 1
|
||||
}
|
||||
};
|
||||
|
||||
} // Namespace
|
||||
#endif
|
@ -0,0 +1,134 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008-2010 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.sourceforge.net/
|
||||
|
||||
This file (property.h) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _NIF_PROPERTY_H_
|
||||
#define _NIF_PROPERTY_H_
|
||||
|
||||
#include "controlled.h"
|
||||
|
||||
namespace Nif
|
||||
{
|
||||
|
||||
struct Property : Named
|
||||
{
|
||||
// The meaning of these depends on the actual property type.
|
||||
int flags;
|
||||
|
||||
void read(NIFFile *nif)
|
||||
{
|
||||
Named::read(nif);
|
||||
flags = nif->getUshort();
|
||||
}
|
||||
};
|
||||
|
||||
struct NiTexturingProperty : Property
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
};
|
||||
|
||||
/* 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
|
||||
}
|
||||
};
|
||||
|
||||
} // Namespace
|
||||
#endif
|
Loading…
Reference in New Issue