diff --git a/nif/controller.h b/nif/controller.h new file mode 100644 index 000000000..548c8feb2 --- /dev/null +++ b/nif/controller.h @@ -0,0 +1,161 @@ +/* + OpenMW - The completely unofficial reimplementation of Morrowind + Copyright (C) 2008-2010 Nicolay Korslund + Email: < korslund@gmail.com > + WWW: http://openmw.sourceforge.net/ + + This file (controller.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_CONTROLLER_H_ +#define _NIF_CONTROLLER_H_ + +#include "record.h" +#include "nif_file.h" +#include "record_ptr.h" + +namespace Nif +{ + +struct Controller : Record +{ + ControllerPtr next; + int flags; + float frequency, phase; + float timeStart, timeStop; + ControlledPtr target; + + void read(NIFFile *nif) + { + next.read(nif); + + flags = nif->getShort(); + + frequency = nif->getFloat(); + phase = nif->getFloat(); + timeStart = nif->getFloat(); + timeStop = nif->getFloat(); + + target.read(nif); + } +}; + +struct NiBSPArrayController : Controller +{ + void read(NIFFile *nif) + { + Controller::read(nif); + + // At the moment, just skip it all + nif->skip(111); + int s = nif->getShort(); + nif->skip(15 + s*40); + } +}; +typedef NiBSPArrayController NiParticleSystemController; + +struct NiMaterialColorController : Controller +{ + NiPosDataPtr data; + + void read(NIFFile *nif) + { + Controller::read(nif); + data.read(nif); + } +}; + +struct NiPathController : Controller +{ + NiPosDataPtr posData; + NiFloatDataPtr floatData; + + void read(NIFFile *nif) + { + Controller::read(nif); + + /* + int = 1 + 2xfloat + short = 0 or 1 + */ + nif->skip(14); + posData.read(nif); + floatData.read(nif); + } +}; + +struct NiUVController : Controller +{ + NiUVDataPtr data; + + void read(NIFFile *nif) + { + Controller::read(nif); + + nif->getShort(); // always 0 + data.read(nif); + } +}; + +struct NiKeyframeController : Controller +{ + NiKeyframeDataPtr data; + + void read(NIFFile *nif) + { + Controller::read(nif); + data.read(nif); + } +}; + +struct NiAlphaController : Controller +{ + NiFloatDataPtr data; + + void read(NIFFile *nif) + { + Controller::read(nif); + data.read(nif); + } +}; + +struct NiGeomMorpherController : Controller +{ + NiMorphDataPtr data; + + void read(NIFFile *nif) + { + Controller::read(nif); + data.read(nif); + nif->getByte(); // always 0 + } +}; + +struct NiVisController : Controller +{ + NiVisDataPtr data; + + void read(NIFFile *nif) + { + Controller::read(nif); + data.read(nif); + } +}; + +} // Namespace +#endif diff --git a/nif/data.h b/nif/data.h index a8c4aba08..6ea900447 100644 --- a/nif/data.h +++ b/nif/data.h @@ -433,5 +433,19 @@ struct NiKeyframeData : Record } }; +struct NiSkinInstance : Record +{ + NiSkinDataPtr data; + NodePtr root; + NodeList bones; + + void read(NIFFile *nif) + { + data.read(nif); + root.read(nif); + bones.read(nif); + } +}; + } // Namespace #endif diff --git a/nif/effect.h b/nif/effect.h new file mode 100644 index 000000000..2ce835bac --- /dev/null +++ b/nif/effect.h @@ -0,0 +1,92 @@ +/* + OpenMW - The completely unofficial reimplementation of Morrowind + Copyright (C) 2008-2010 Nicolay Korslund + Email: < korslund@gmail.com > + WWW: http://openmw.sourceforge.net/ + + This file (effect.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_EFFECT_H_ +#define _NIF_EFFECT_H_ + +#include "node.h" + +namespace Nif +{ + +typedef Node Effect; + +// Used for NiAmbientLight and NiDirectionalLight. Might also work for +// NiPointLight and NiSpotLight? +struct NiLight : Effect +{ + struct SLight + { + float dimmer; + Vector ambient; + Vector diffuse; + Vector specular; + }; + + const SLight *light; + + void read(NIFFile *nif) + { + Effect::read(nif); + + nif->getInt(); // 1 + nif->getInt(); // 1? + light = nif->getPtr(); + } +}; + +struct NiTextureEffect : Effect +{ + NiSourceTexturePtr texture; + + void read(NIFFile *nif) + { + Effect::read(nif); + + int tmp = nif->getInt(); + if(tmp) nif->getInt(); // always 1? + + /* + 3 x Vector4 = [1,0,0,0] + int = 2 + int = 0 or 3 + int = 2 + int = 2 + */ + nif->skip(16*4); + + texture.read(nif); + + /* + byte = 0 + vector4 = [1,0,0,0] + short = 0 + short = -75 + short = 0 + */ + nif->skip(23); + } +}; + +} // Namespace +#endif diff --git a/nif/extra.h b/nif/extra.h index 9de15494d..2fdc03de9 100644 --- a/nif/extra.h +++ b/nif/extra.h @@ -42,7 +42,7 @@ struct Extra : Record void read(NIFFile *nif) { extra.read(nif); } }; -struct NiVertWeigthsExtraData : Extra +struct NiVertWeightsExtraData : Extra { void read(NIFFile *nif) { diff --git a/nif/nif_file.cpp b/nif/nif_file.cpp index 433a5572b..291d3950d 100644 --- a/nif/nif_file.cpp +++ b/nif/nif_file.cpp @@ -30,6 +30,8 @@ #include "node.h" #include "property.h" #include "data.h" +#include "effect.h" +#include "controller.h" #include using namespace std; diff --git a/nif/record_ptr.h b/nif/record_ptr.h index 8cf54a104..d6d1077f9 100644 --- a/nif/record_ptr.h +++ b/nif/record_ptr.h @@ -126,9 +126,17 @@ class RecordListT class Node; class Extra; class Property; +class NiUVData; +class NiPosData; +class NiVisData; class Controller; +class Controlled; +class NiSkinData; +class NiFloatData; +class NiMorphData; class NiPixelData; class NiColorData; +class NiKeyframeData; class NiTriShapeData; class NiSkinInstance; class NiSourceTexture; @@ -137,9 +145,17 @@ class NiAutoNormalParticlesData; typedef RecordPtrT NodePtr; typedef RecordPtrT ExtraPtr; +typedef RecordPtrT NiUVDataPtr; +typedef RecordPtrT NiPosDataPtr; +typedef RecordPtrT NiVisDataPtr; typedef RecordPtrT ControllerPtr; +typedef RecordPtrT ControlledPtr; +typedef RecordPtrT NiSkinDataPtr; +typedef RecordPtrT NiMorphDataPtr; typedef RecordPtrT NiPixelDataPtr; +typedef RecordPtrT NiFloatDataPtr; typedef RecordPtrT NiColorDataPtr; +typedef RecordPtrT NiKeyframeDataPtr; typedef RecordPtrT NiTriShapeDataPtr; typedef RecordPtrT NiSkinInstancePtr; typedef RecordPtrT NiSourceTexturePtr;