xoreos  0.0.5
model_jade.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_JADE_H
26 #define GRAPHICS_AURORA_MODEL_JADE_H
27 
30 
31 namespace Common {
32  class SeekableReadStream;
33 }
34 
35 namespace Graphics {
36 
37 namespace Aurora {
38 
39 class ModelNode_Jade;
40 
42 class Model_Jade : public Model {
43 public:
45  const Common::UString &texture = "");
46  ~Model_Jade();
47 
48 private:
49  struct ParserContext {
52 
54 
55  State *state;
56 
57  std::list<ModelNode_Jade *> nodes;
58 
60 
62 
64 
68 
69  std::vector<Common::UString> names;
70 
71  std::vector<float> vertices;
72  std::vector<uint16> indices;
73 
74  std::vector<Common::UString> textures;
75 
76  std::vector<std::vector<float> > texCoords;
77 
78  ParserContext(const Common::UString &name, const Common::UString &t);
80 
81  void clear();
82  void newNode();
83  };
84 
85 
86  void newState(ParserContext &ctx);
87  void addState(ParserContext &ctx);
88 
89  void load(ParserContext &ctx);
90 
92  const std::vector<uint32> &offsets, uint32 offset,
93  std::vector<Common::UString> &strings);
94 
95  friend class ModelNode_Jade;
96 };
97 
98 class ModelNode_Jade : public ModelNode {
99 public:
100  ModelNode_Jade(Model &model);
101  ~ModelNode_Jade();
102 
103  void load(Model_Jade::ParserContext &ctx);
104 
105  void buildMaterial();
106 
107 private:
108 
116  float falloff;
117  float waterAlpha;
120  // 2 bytes unknown (padding?)
121  float diffuseColor[3];
122  float ambientColor[3];
123  // 24 bytes unknown.
126  // 4 bytes unknown.
127  };
128 
130 
131  void readPlainIndices (Common::SeekableReadStream &stream, std::vector<uint16> &indices,
132  uint32 offset, uint32 count);
133  void readChunkedIndices(Common::SeekableReadStream &stream, std::vector<uint16> &indices,
134  uint32 offset, uint32 count);
135 
136  void unfoldFaces (std::vector<uint16> &indices, uint32 meshType);
137  void unfoldTriangleStrip(std::vector<uint16> &indices);
138  void unfoldTriangleFan (std::vector<uint16> &indices);
139 
141 
142  void readMaterialTextures(uint32 materialID, std::vector<Common::UString> &textures);
143 
145 };
146 
147 } // End of namespace Aurora
148 
149 } // End of namespace Graphics
150 
151 #endif // GRAPHICS_AURORA_MODEL_JADE_H
void unfoldFaces(std::vector< uint16 > &indices, uint32 meshType)
Unfolds triangle strips / fans into triangle lists.
Definition: model_jade.cpp:586
A 3D model in the Jade Empire MDL/MDX format.
Definition: model_jade.h:42
Definition: 2dafile.h:39
Common::SeekableReadStream * mdl
Definition: model_jade.h:50
A class holding an UTF-8 string.
Definition: ustring.h:48
Common::SeekableReadStream * mdx
Definition: model_jade.h:51
void readMesh(Model_Jade::ParserContext &ctx)
Definition: model_jade.cpp:390
void readPlainIndices(Common::SeekableReadStream &stream, std::vector< uint16 > &indices, uint32 offset, uint32 count)
Definition: model_jade.cpp:542
uint8_t uint8
Definition: types.h:200
void readStrings(Common::SeekableReadStream &mdl, const std::vector< uint32 > &offsets, uint32 offset, std::vector< Common::UString > &strings)
Definition: model_jade.cpp:246
A real object in the game world.
Definition: types.h:52
void readChunkedIndices(Common::SeekableReadStream &stream, std::vector< uint16 > &indices, uint32 offset, uint32 count)
Definition: model_jade.cpp:556
JadeMaterialData _jadeMaterialData
Definition: model_jade.h:144
ParserContext(const Common::UString &name, const Common::UString &t)
Definition: model_jade.cpp:94
void unfoldTriangleStrip(std::vector< uint16 > &indices)
Definition: model_jade.cpp:611
std::vector< Common::UString > textures
Definition: model_jade.h:74
Model_Jade(const Common::UString &name, ModelType type=kModelTypeObject, const Common::UString &texture="")
Definition: model_jade.cpp:140
ModelType
The display type of a model.
Definition: types.h:51
void createMesh(Model_Jade::ParserContext &ctx)
Definition: model_jade.cpp:653
std::vector< std::vector< float > > texCoords
Definition: model_jade.h:76
void load(Model_Jade::ParserContext &ctx)
Definition: model_jade.cpp:302
A node within a 3D model.
void readMaterialTextures(uint32 materialID, std::vector< Common::UString > &textures)
Opens the resource for the materialID and parses it to return the 4 normal textures.
Definition: model_jade.cpp:702
A 3D model of an object.
std::vector< Common::UString > names
Definition: model_jade.h:69
void load(ParserContext &ctx)
Definition: model_jade.cpp:155
uint32_t uint32
Definition: types.h:204
std::list< ModelNode_Jade * > nodes
Definition: model_jade.h:57
void unfoldTriangleFan(std::vector< uint16 > &indices)
Definition: model_jade.cpp:635
void newState(ParserContext &ctx)
Definition: model_jade.cpp:262
Interface for a seekable & readable data stream.
Definition: readstream.h:265
void addState(ParserContext &ctx)
Definition: model_jade.cpp:268