ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

modelemi.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_MODELEMI_H
00024 #define GRIM_MODELEMI_H
00025 
00026 #include "engines/grim/object.h"
00027 #include "engines/grim/actor.h"
00028 #include "math/matrix4.h"
00029 #include "math/vector2d.h"
00030 #include "math/vector3d.h"
00031 #include "math/vector4d.h"
00032 #include "math/aabb.h"
00033 
00034 namespace Common {
00035 class SeekableReadStream;
00036 }
00037 
00038 namespace Grim {
00039 
00040 class Material;
00041 
00042 struct EMIColormap {
00043     unsigned char r, g, b, a;
00044 };
00045 
00046 // Todo: port this to math::vector
00047 struct Vector3int;
00048 
00049 class EMICostume;
00050 class EMIModel;
00051 struct BoneInfo;
00052 struct Bone;
00053 class Skeleton;
00054 
00055 class EMIMeshFace {
00056 public:
00057     Vector3int *_indexes;
00058     uint32 _indicesEBO;
00059     uint32 _faceLength;
00060     uint32 _numFaces;
00061     uint32 _hasTexture;
00062     uint32 _texID;
00063     uint32 _flags;
00064     EMIModel *_parent;
00065 
00066     enum MeshFaceFlags {
00067         kNoLighting = 0x20, // guessed, but distinctive for screen actors
00068         kAlphaBlend = 0x10000,
00069         kUnknownBlend = 0x40000 // used only in intro screen actors
00070     };
00071 
00072     EMIMeshFace() : _faceLength(0), _numFaces(0), _hasTexture(0), _texID(0), _flags(0), _indexes(NULL), _parent(NULL), _indicesEBO(0) { }
00073     ~EMIMeshFace();
00074     void loadFace(Common::SeekableReadStream *data);
00075     void setParent(EMIModel *m) { _parent = m; }
00076     void render();
00077 };
00078 
00079 /* TODO: Remember to credit JohnDoe for his EMIMeshViewer, as most of the Skeletal
00080  * math, and understandings comes from his Delphi-code.
00081  */
00082 class EMIModel : public Object {
00083 public:
00084     enum TextureFlags {
00085         BlendAdditive = 0x400
00086         // There are more flags, but their purpose is currently unknown.
00087     };
00088 
00089     Common::String _meshName;
00090     Actor::AlphaMode _meshAlphaMode;
00091     float _meshAlpha;
00092     int _numVertices;
00093     Math::Vector3d *_vertices;
00094     Math::Vector3d *_drawVertices;
00095     Math::Vector3d *_normals;
00096     Math::Vector3d *_drawNormals;
00097     Math::Vector3d *_lighting;
00098     EMIColormap *_colorMap;
00099     Math::Vector2d *_texVerts;
00100 
00101     uint32 _numFaces;
00102     EMIMeshFace *_faces;
00103     uint32 _numTextures;
00104     Common::String *_texNames;
00105     uint32 *_texFlags;
00106     Material **_mats;
00107 
00108     Skeleton *_skeleton;
00109 
00110     int _numBones;
00111 
00112     // Bone-stuff:
00113     int _numBoneInfos;
00114     BoneInfo *_boneInfos;
00115     Common::String *_boneNames;
00116     int *_vertexBoneInfo;
00117 
00118     // Stuff we dont know how to use:
00119     float _radius;
00120     Math::Vector3d *_center;
00121     Math::Vector3d *_boxData;
00122     Math::Vector3d *_boxData2;
00123     int _numTexSets;
00124     int _setType;
00125 
00126     Common::String _fname;
00127     EMICostume *_costume;
00128 
00129     void *_userData;
00130     bool _lightingDirty;
00131 
00132 public:
00133     EMIModel(const Common::String &filename, Common::SeekableReadStream *data, EMICostume *costume);
00134     ~EMIModel();
00135     void setTex(uint32 index);
00136     void setSkeleton(Skeleton *skel);
00137     void loadMesh(Common::SeekableReadStream *data);
00138     void prepareForRender();
00139     void prepareTextures();
00140     void draw();
00141     void updateLighting(const Math::Matrix4 &modelToWorld);
00142     void getBoundingBox(int *x1, int *y1, int *x2, int *y2) const;
00143     Math::AABB calculateWorldBounds(const Math::Matrix4 &matrix) const;
00144 };
00145 
00146 } // end of namespace Grim
00147 
00148 #endif


Generated on Sat Jul 13 2019 05:01:03 for ResidualVM by doxygen 1.7.1
curved edge   curved edge