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

stark/model/model.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 AUTHORS
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 STARK_MODEL_MODEL_H
00024 #define STARK_MODEL_MODEL_H
00025 
00026 #include "common/array.h"
00027 #include "common/str.h"
00028 
00029 #include "math/ray.h"
00030 #include "math/vector3d.h"
00031 
00032 namespace Stark {
00033 
00034 namespace Gfx {
00035 class TextureSet;
00036 }
00037 
00038 class ArchiveReadStream;
00039 
00040 class VertNode {
00041 public:
00042     Math::Vector3d _pos1, _pos2;
00043     Math::Vector3d _normal;
00044     float _texS, _texT;
00045     uint32 _bone1, _bone2;
00046     float _boneWeight;
00047 };
00048 
00049 struct Face {
00050     uint32 materialId;
00051     Common::Array<uint32> vertexIndices;
00052 
00053     Face() : materialId(0) {}
00054 };
00055 
00056 struct Material {
00057     Common::String name;
00058     Common::String texture;
00059     float r, g, b;
00060     bool doubleSided;
00061 
00062     Material() : r(0), g(0), b(0), doubleSided(false) {};
00063 };
00064 
00065 class BoneNode {
00066 public:
00067     BoneNode() : _parent(-1), _idx(0), _u1(0) {}
00068     ~BoneNode() { }
00069 
00071     bool intersectRay(const Math::Ray &ray) const;
00072 
00074     void expandModelSpaceBB(Math::AABB &aabb) const;
00075 
00076     Common::String _name;
00077     float _u1;
00078     Common::Array<uint32> _children;
00079     int _parent;
00080     uint32 _idx;
00081 
00082     Math::Vector3d _animPos;
00083     Math::Quaternion _animRot;
00084 
00086     Math::AABB _boundingBox;
00087 };
00088 
00092 class Model {
00093 public:
00094     Model();
00095     ~Model();
00096 
00100     void readFromStream(ArchiveReadStream *stream);
00101 
00102     const Common::Array<VertNode *> &getVertices() const { return _vertices; }
00103     const Common::Array<Face *> &getFaces() const { return _faces; }
00104     const Common::Array<Material *> &getMaterials() const { return _materials; }
00105     const Common::Array<BoneNode *> &getBones() const { return _bones; };
00106 
00108     bool intersectRay(const Math::Ray &ray) const;
00109 
00111     void updateBoundingBox();
00112 
00114     Math::AABB getBoundingBox() const;
00115 
00116 private:
00117     void buildBonesBoundingBoxes();
00118     void buildBoneBoundingBox(BoneNode *bone) const;
00119     void readBones(ArchiveReadStream *stream);
00120 
00121     Common::String _name;
00122     uint32 _u1;
00123     float _u2;
00124 
00125     Common::Array<VertNode *> _vertices;
00126     Common::Array<Material *> _materials;
00127     Common::Array<Face *> _faces;
00128     Common::Array<BoneNode *> _bones;
00129     Math::AABB _boundingBox;
00130 };
00131 
00132 } // End of namespace Stark
00133 
00134 #endif // STARK_MODEL_MODEL_H


Generated on Sat May 25 2019 05:00:50 for ResidualVM by doxygen 1.7.1
curved edge   curved edge