OpenMW
components/nif/extra.hpp
Go to the documentation of this file.
00001 /*
00002   OpenMW - The completely unofficial reimplementation of Morrowind
00003   Copyright (C) 2008-2010  Nicolay Korslund
00004   Email: < korslund@gmail.com >
00005   WWW: http://openmw.sourceforge.net/
00006 
00007   This file (extra.h) is part of the OpenMW package.
00008 
00009   OpenMW is distributed as free software: you can redistribute it
00010   and/or modify it under the terms of the GNU General Public License
00011   version 3, as published by the Free Software Foundation.
00012 
00013   This program is distributed in the hope that it will be useful, but
00014   WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016   General Public License for more details.
00017 
00018   You should have received a copy of the GNU General Public License
00019   version 3 along with this program. If not, see
00020   http://www.gnu.org/licenses/ .
00021 
00022  */
00023 
00024 #ifndef OPENMW_COMPONENTS_NIF_EXTRA_HPP
00025 #define OPENMW_COMPONENTS_NIF_EXTRA_HPP
00026 
00027 #include "record.hpp"
00028 #include "niffile.hpp"
00029 #include "recordptr.hpp"
00030 
00031 namespace Nif
00032 {
00033 
00038 class Extra : public Record
00039 {
00040 public:
00041     ExtraPtr extra;
00042 
00043     void read(NIFStream *nif) { extra.read(nif); }
00044     void post(NIFFile *nif) { extra.post(nif); }
00045 };
00046 
00047 class NiVertWeightsExtraData : public Extra
00048 {
00049 public:
00050     void read(NIFStream *nif)
00051     {
00052         Extra::read(nif);
00053 
00054         // We should have s*4+2 == i, for some reason. Might simply be the
00055         // size of the rest of the record, unhelpful as that may be.
00056         /*int i =*/ nif->getInt();
00057         int s = nif->getUShort();
00058 
00059         nif->skip(s * sizeof(float)); // vertex weights I guess
00060     }
00061 };
00062 
00063 class NiTextKeyExtraData : public Extra
00064 {
00065 public:
00066     struct TextKey
00067     {
00068         float time;
00069         std::string text;
00070     };
00071     std::vector<TextKey> list;
00072 
00073     void read(NIFStream *nif)
00074     {
00075         Extra::read(nif);
00076 
00077         nif->getInt(); // 0
00078 
00079         int keynum = nif->getInt();
00080         list.resize(keynum);
00081         for(int i=0; i<keynum; i++)
00082         {
00083             list[i].time = nif->getFloat();
00084             list[i].text = nif->getString();
00085         }
00086     }
00087 };
00088 
00089 class NiStringExtraData : public Extra
00090 {
00091 public:
00092     /* Two known meanings:
00093        "MRK" - marker, only visible in the editor, not rendered in-game
00094        "NCO" - no collision
00095     */
00096     std::string string;
00097 
00098     void read(NIFStream *nif)
00099     {
00100         Extra::read(nif);
00101 
00102         nif->getInt(); // size of string + 4. Really useful...
00103         string = nif->getString();
00104     }
00105 };
00106 
00107 } // Namespace
00108 #endif