ScummVM API documentation
path.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 STARK_RESOURCES_PATH_H
23 #define STARK_RESOURCES_PATH_H
24 
25 #include "common/rect.h"
26 #include "math/vector3d.h"
27 #include "common/str.h"
28 
29 #include "engines/stark/resources/object.h"
30 
31 namespace Stark {
32 
33 namespace Formats {
34 class XRCReadStream;
35 }
36 
37 namespace Resources {
38 
45 class Path : public Object {
46 public:
47  static const Type::ResourceType TYPE = Type::kPath;
48 
49  enum SubType {
50  kPath2D = 1,
51  kPath3D = 2
52  };
53 
55  static Object *construct(Object *parent, byte subType, uint16 index, const Common::String &name);
56 
57  Path(Object *parent, byte subType, uint16 index, const Common::String &name);
58  virtual ~Path();
59 
60  // Resource API
61  virtual void readData(Formats::XRCReadStream *stream) override;
62 
64  virtual uint getEdgeCount() const = 0;
65 
71  virtual Math::Vector3d getEdgeDirection(uint edgeIndex) const;
72 
74  virtual float getSortKey() const;
75 
77  float getWeightedEdgeLength(uint edgeIndex) const;
78 
80  Math::Vector3d getWeightedPositionInEdge(uint edgeIndex, float positionInEdge);
81 
82 protected:
83  void printData() override;
84  float getEdgeLength(uint edgeIndex) const;
85  virtual float getVertexWeight(uint vertexIndex) const = 0;
86  virtual Math::Vector3d getVertexPosition(uint vertexIndex) const = 0;
87 
88  uint32 _field_30;
89 
90 };
91 
95 class Path2D : public Path {
96 public:
97  Path2D(Object *parent, byte subType, uint16 index, const Common::String &name);
98  virtual ~Path2D();
99 
100  struct Vertex {
101  float weight;
102  Common::Point position;
103  };
104 
105  // Resource API
106  void readData(Formats::XRCReadStream *stream) override;
107 
108  // Path API
109  uint getEdgeCount() const override;
110 
111 protected:
112  float getVertexWeight(uint vertexIndex) const override;
113  Math::Vector3d getVertexPosition(uint vertexIndex) const override;
114 
115 private:
116  // Resource API
117  void printData() override;
118 
119  Common::Array<Vertex> _vertices;
120 };
121 
125 class Path3D : public Path {
126 public:
127  Path3D(Object *parent, byte subType, uint16 index, const Common::String &name);
128  virtual ~Path3D();
129 
130  struct Vertex {
131  float weight;
132  Math::Vector3d position;
133  };
134 
135  // Resource API
136  void readData(Formats::XRCReadStream *stream) override;
137 
138  // Path API
139  uint getEdgeCount() const override;
140  float getSortKey() const override;
141  Math::Vector3d getEdgeDirection(uint edgeIndex) const override;
142 
144  Math::Vector3d getVertexPosition3D(uint vertexIndex, int32 *faceIndex);
145 
146 protected:
147  float getVertexWeight(uint vertexIndex) const override;
148  Math::Vector3d getVertexPosition(uint vertexIndex) const override;
149 
150 private:
151  // Resource API
152  void printData() override;
153 
154  Common::Array<Vertex> _vertices;
155  float _sortKey;
156 };
157 
158 } // End of namespace Resources
159 } // End of namespace Stark
160 
161 #endif // STARK_RESOURCES_PATH_H
Definition: str.h:59
Definition: path.h:100
Definition: array.h:52
Definition: path.h:45
Definition: path.h:130
Definition: path.h:125
Definition: path.h:95
Definition: console.h:27
Definition: object.h:143
Definition: rect.h:45
Definition: xrc.h:45