xoreos  0.0.5
model_kotor.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_AURORA_MODEL_KOTOR_H
26 #define GRAPHICS_AURORA_MODEL_KOTOR_H
27 
30 
31 namespace Common {
32  class SeekableReadStream;
33 }
34 
35 namespace Graphics {
36 
37 namespace Aurora {
38 
39 class ModelNode_KotOR;
40 
42 class Model_KotOR : public Model {
43 public:
44  Model_KotOR(const Common::UString &name, bool kotor2, bool xbox, ModelType type = kModelTypeObject,
45  const Common::UString &texture = "", ModelCache *modelCache = 0);
46  ~Model_KotOR();
47 
48 private:
49  struct ParserContext {
52 
54 
55  State *state;
56 
57  std::list<ModelNode_KotOR *> nodes;
58 
60 
61  bool kotor2;
62  bool xbox;
63 
66 
67  std::vector<Common::UString> names;
68 
72 
73  ParserContext(const Common::UString &name, const Common::UString &t, bool k2, bool x);
75 
76  void clear();
77  };
78 
79 
80  void newState(ParserContext &ctx);
81  void addState(ParserContext &ctx);
82 
83  void load(ParserContext &ctx);
84  bool readAnim(ParserContext &ctx, uint32 offset);
85 
86  void loadSuperModel(ModelCache *modelCache, bool kotor2, bool xbox);
87 
89  const std::vector<uint32> &offsets, uint32 offset,
90  std::vector<Common::UString> &strings);
91 
93  void makeBoneNodeMap();
94 
95  friend class ModelNode_KotOR;
96 };
97 
98 class ModelNode_KotOR : public ModelNode {
99 public:
100  ModelNode_KotOR(Model &model);
102 
103  void load(Model_KotOR::ParserContext &ctx);
104 
105  void buildMaterial();
106 
107 private:
109  uint32 count, std::vector<float> &dataFloat, std::vector<uint32> &dataInt);
110  void readPositionController(uint8 columnCount, uint16 rowCount, uint16 timeIndex,
111  uint16 dataIndex, std::vector<float> &data);
112  void readOrientationController(uint8 columnCount, uint16 rowCount, uint16 timeIndex,
113  uint16 dataIndex, std::vector<float> &dataFloat, std::vector<uint32> &dataInt);
116 };
117 
118 } // End of namespace Aurora
119 
120 } // End of namespace Graphics
121 
122 #endif // GRAPHICS_AURORA_MODEL_KOTOR_H
void newState(ParserContext &ctx)
Definition: 2dafile.h:39
Model_KotOR(const Common::UString &name, bool kotor2, bool xbox, ModelType type=kModelTypeObject, const Common::UString &texture="", ModelCache *modelCache=0)
A class holding an UTF-8 string.
Definition: ustring.h:48
void makeBoneNodeMap()
Map bone indices to model node references for better peformance.
bool readAnim(ParserContext &ctx, uint32 offset)
uint8_t uint8
Definition: types.h:200
A 3D model in the NWN binary MDL format.
Definition: model_kotor.h:42
A real object in the game world.
Definition: types.h:52
Common::SeekableReadStream * mdl
Definition: model_kotor.h:50
ParserContext(const Common::UString &name, const Common::UString &t, bool k2, bool x)
void load(Model_KotOR::ParserContext &ctx)
ModelType
The display type of a model.
Definition: types.h:51
uint16_t uint16
Definition: types.h:202
void addState(ParserContext &ctx)
void loadSuperModel(ModelCache *modelCache, bool kotor2, bool xbox)
void readStrings(Common::SeekableReadStream &mdl, const std::vector< uint32 > &offsets, uint32 offset, std::vector< Common::UString > &strings)
A node within a 3D model.
A 3D model of an object.
void readNodeControllers(Model_KotOR::ParserContext &ctx, uint32 offset, uint32 count, std::vector< float > &dataFloat, std::vector< uint32 > &dataInt)
Common::SeekableReadStream * mdx
Definition: model_kotor.h:51
void readPositionController(uint8 columnCount, uint16 rowCount, uint16 timeIndex, uint16 dataIndex, std::vector< float > &data)
std::vector< Common::UString > names
Definition: model_kotor.h:67
void readOrientationController(uint8 columnCount, uint16 rowCount, uint16 timeIndex, uint16 dataIndex, std::vector< float > &dataFloat, std::vector< uint32 > &dataInt)
uint32_t uint32
Definition: types.h:204
void readSkin(Model_KotOR::ParserContext &ctx)
void readMesh(Model_KotOR::ParserContext &ctx)
Interface for a seekable & readable data stream.
Definition: readstream.h:265
void load(ParserContext &ctx)
std::list< ModelNode_KotOR * > nodes
Definition: model_kotor.h:57