ScummVM API documentation
body.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 TWINE_PARSER_BODY_H
23 #define TWINE_PARSER_BODY_H
24 
25 #include "common/array.h"
26 #include "common/memstream.h"
27 #include "common/stream.h"
28 #include "twine/parser/anim.h"
29 #include "twine/parser/bodytypes.h"
30 #include "twine/parser/parser.h"
31 #include "twine/shared.h"
32 
33 namespace TwinE {
34 
35 class BodyData : public Parser {
36 private:
37  void loadVertices(Common::SeekableReadStream &stream);
38  void loadBones(Common::SeekableReadStream &stream);
39  void loadNormals(Common::SeekableReadStream &stream);
40  void loadPolygons(Common::SeekableReadStream &stream);
41  void loadLines(Common::SeekableReadStream &stream);
42  void loadSpheres(Common::SeekableReadStream &stream);
43 
45  Common::Array<BodyVertex> _vertices;
50 
51  BoneFrame _boneStates[560];
52 
53 protected:
54  void reset() override;
55 
56 public:
57  bool animated = false;
58 
59  BoundingBox bbox;
60  int16 offsetToData = 0;
61 
62  inline bool isAnimated() const {
63  return animated;
64  }
65 
66  inline uint getNumBones() const {
67  return _bones.size();
68  }
69 
70  inline uint getNumVertices() const {
71  return _vertices.size();
72  }
73 
74  BoneFrame *getBoneState(int16 boneIdx) {
75  return &_boneStates[boneIdx];
76  }
77 
78  const BoneFrame *getBoneState(int16 boneIdx) const {
79  return &_boneStates[boneIdx];
80  }
81 
82  const Common::Array<BodyPolygon> &getPolygons() const {
83  return _polygons;
84  }
85 
86  const Common::Array<BodyVertex> &getVertices() const {
87  return _vertices;
88  }
89 
90  const Common::Array<BodySphere> &getSpheres() const {
91  return _spheres;
92  }
93 
94  const Common::Array<BodyNormal> &getNormals() const {
95  return _normals;
96  }
97 
98  const BodyNormal &getNormal(int16 normalIdx) const {
99  return _normals[normalIdx];
100  }
101 
102  const Common::Array<BodyLine> &getLines() const {
103  return _lines;
104  }
105 
106  const Common::Array<BodyBone> &getBones() const {
107  return _bones;
108  }
109 
110  const BodyBone &getBone(int16 boneIdx) const {
111  return _bones[boneIdx];
112  }
113 
114  bool loadFromStream(Common::SeekableReadStream &stream, bool lba1) override;
115 };
116 
117 } // End of namespace TwinE
118 
119 #endif
Definition: array.h:52
Definition: bodytypes.h:67
Definition: stream.h:745
Definition: achievements_tables.h:27
size_type size() const
Definition: array.h:315
Definition: anim.h:38
Definition: parser.h:32
Axis aligned bounding box.
Definition: shared.h:188
Definition: bodytypes.h:54
Definition: body.h:35