mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 20:19:57 +00:00
Added NiSourceTexture, NiTexturingProperty
This commit is contained in:
parent
4128462add
commit
c9a42f85eb
5 changed files with 234 additions and 1 deletions
86
nif/data.h
Normal file
86
nif/data.h
Normal file
|
@ -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
|
|
@ -28,6 +28,8 @@
|
|||
#include "extra.h"
|
||||
#include "controlled.h"
|
||||
#include "node.h"
|
||||
#include "property.h"
|
||||
#include "data.h"
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
@ -53,7 +55,7 @@ void NIFFile::parse()
|
|||
{
|
||||
SString rec = getString();
|
||||
|
||||
cout << endl << i << ": " << rec.toString() << endl;
|
||||
cout << i << ": " << rec.toString() << endl;
|
||||
|
||||
Record *r;
|
||||
|
||||
|
@ -62,6 +64,8 @@ void NIFFile::parse()
|
|||
// node names.
|
||||
if(rec == "NiNode") r = new NiNode;
|
||||
else if(rec == "NiTriShape") r = new NiTriShape;
|
||||
else if(rec == "NiTexturingProperty") r = new NiTexturingProperty;
|
||||
else if(rec == "NiSourceTexture") r = new NiSourceTexture;
|
||||
else break;
|
||||
|
||||
r->read(this);
|
||||
|
|
|
@ -108,10 +108,14 @@ class NIFFile
|
|||
|
||||
****************************************************/
|
||||
|
||||
void skip(size_t size) { inp->getPtr(size); }
|
||||
|
||||
template<class X> const X* getPtr() { return (const X*)inp->getPtr(sizeof(X)); }
|
||||
template<class X> X getType() { return *getPtr<X>(); }
|
||||
unsigned short getUshort() { return getType<unsigned short>(); }
|
||||
int getInt() { return getType<int>(); }
|
||||
float getFloat() { return getType<float>(); }
|
||||
char getByte() { return getType<char>(); }
|
||||
|
||||
template<class X>
|
||||
SliceArray<X> getArray()
|
||||
|
@ -125,6 +129,7 @@ class NIFFile
|
|||
const Vector *getVector() { return getPtr<Vector>(); }
|
||||
const Matrix *getMatrix() { return getPtr<Matrix>(); }
|
||||
const Transformation *getTrafo() { return getPtr<Transformation>(); }
|
||||
const Vector4 *getVector4() { return getPtr<Vector4>(); }
|
||||
|
||||
// For fixed-size strings where you already know the size
|
||||
const char *getString(int size)
|
||||
|
|
134
nif/property.h
Normal file
134
nif/property.h
Normal file
|
@ -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
|
|
@ -127,14 +127,18 @@ class Node;
|
|||
class Extra;
|
||||
class Property;
|
||||
class Controller;
|
||||
class NiPixelData;
|
||||
class NiTriShapeData;
|
||||
class NiSkinInstance;
|
||||
class NiSourceTexture;
|
||||
|
||||
typedef RecordPtrT<Node> NodePtr;
|
||||
typedef RecordPtrT<Extra> ExtraPtr;
|
||||
typedef RecordPtrT<Controller> ControllerPtr;
|
||||
typedef RecordPtrT<NiPixelData> NiPixelDataPtr;
|
||||
typedef RecordPtrT<NiTriShapeData> NiTriShapeDataPtr;
|
||||
typedef RecordPtrT<NiSkinInstance> NiSkinInstancePtr;
|
||||
typedef RecordPtrT<NiSourceTexture> NiSourceTexturePtr;
|
||||
|
||||
typedef RecordListT<Node> NodeList;
|
||||
typedef RecordListT<Property> PropertyList;
|
||||
|
|
Loading…
Reference in a new issue