ScummVM API documentation
modelemi.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRIM_MODELEMI_H
23 #define GRIM_MODELEMI_H
24 
25 #include "engines/grim/object.h"
26 #include "engines/grim/actor.h"
27 
28 #include "math/matrix4.h"
29 #include "math/vector2d.h"
30 #include "math/vector3d.h"
31 #include "math/vector4d.h"
32 #include "math/aabb.h"
33 
34 namespace Common {
35 class SeekableReadStream;
36 }
37 
38 namespace Grim {
39 
40 class Material;
41 
42 struct EMIColormap {
43  unsigned char r, g, b, a;
44 };
45 
46 // Todo: port this to math::vector
47 struct Vector3int;
48 
49 class EMICostume;
50 class EMIModel;
51 struct BoneInfo;
52 struct Bone;
53 class Skeleton;
54 
55 class EMIMeshFace {
56 public:
57  Vector3int *_indexes;
58  uint32 _indicesEBO;
59  uint32 _faceLength;
60  uint32 _numFaces;
61  uint32 _hasTexture;
62  uint32 _texID;
63  uint32 _flags;
64  EMIModel *_parent;
65 
66  enum MeshFaceFlags {
67  kNoLighting = 0x20, // guessed, but distinctive for screen actors
68  kAlphaBlend = 0x10000,
69  kUnknownBlend = 0x40000 // used only in intro screen actors
70  };
71 
72  EMIMeshFace() : _faceLength(0), _numFaces(0), _hasTexture(0), _texID(0), _flags(0), _indexes(NULL), _parent(NULL), _indicesEBO(0) { }
73  ~EMIMeshFace();
74  void loadFace(Common::SeekableReadStream *data);
75  void setParent(EMIModel *m) { _parent = m; }
76  void render();
77 };
78 
79 /* TODO: Remember to credit JohnDoe for his EMIMeshViewer, as most of the Skeletal
80  * math, and understandings comes from his Delphi-code.
81  */
82 class EMIModel : public Object {
83 public:
84  enum TextureFlags {
85  BlendAdditive = 0x400
86  // There are more flags, but their purpose is currently unknown.
87  };
88 
89  Common::String _meshName;
90  Actor::AlphaMode _meshAlphaMode;
91  float _meshAlpha;
92  int _numVertices;
93  Math::Vector3d *_vertices;
94  Math::Vector3d *_drawVertices;
95  Math::Vector3d *_normals;
96  Math::Vector3d *_drawNormals;
97  Math::Vector3d *_lighting;
98  EMIColormap *_colorMap;
99  Math::Vector2d *_texVerts;
100 
101  uint32 _numFaces;
102  EMIMeshFace *_faces;
103  uint32 _numTextures;
104  Common::String *_texNames;
105  uint32 *_texFlags;
106  Material **_mats;
107 
108  Skeleton *_skeleton;
109 
110  int _numBones;
111 
112  // Bone-stuff:
113  int _numBoneInfos;
114  BoneInfo *_boneInfos;
115  Common::String *_boneNames;
116  int *_vertexBoneInfo;
117 
118  // Stuff we dont know how to use:
119  float _radius;
120  Math::Vector3d *_center;
121  Math::Vector3d *_boxData;
122  Math::Vector3d *_boxData2;
123  int _numTexSets;
124  int _setType;
125 
126  Common::String _fname;
127  EMICostume *_costume;
128 
129  void *_userData;
130  bool _lightingDirty;
131 
132 public:
133  EMIModel(const Common::String &filename, Common::SeekableReadStream *data, EMICostume *costume);
134  ~EMIModel();
135  void setTex(uint32 index);
136  void setSkeleton(Skeleton *skel);
137  void loadMesh(Common::SeekableReadStream *data);
138  void prepareForRender();
139  void prepareTextures();
140  void draw();
141  void updateLighting(const Math::Matrix4 &modelToWorld);
142  void getBoundingBox(int *x1, int *y1, int *x2, int *y2) const;
143  Math::AABB calculateWorldBounds(const Math::Matrix4 &matrix) const;
144 };
145 
146 } // end of namespace Grim
147 
148 #endif
Definition: str.h:59
Definition: modelemi.h:82
Definition: animationemi.h:46
Definition: stream.h:745
Definition: actor.h:33
Definition: material.h:63
Definition: skeleton.h:68
Definition: algorithm.h:29
Definition: modelemi.h:55
Definition: costumeemi.h:40
Definition: modelemi.h:42
Definition: object.h:32