ScummVM API documentation
pathfinding3d.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 TRECISION_PATHFINDING_H
23#define TRECISION_PATHFINDING_H
24
25#include "trecision/struct.h"
26#include "common/serializer.h"
27
28namespace Trecision {
29
30struct SSortPan {
31 int _num;
32 float _min;
33};
34
35struct SPathNode {
36 float _x, _z;
37 float _dist;
38 int16 _oldPanel;
39 int16 _curPanel;
40
41 void clear() {
42 _x = _z = 0.0f;
43 _dist = 0.0f;
44 _oldPanel = 0;
45 _curPanel = 0;
46 }
47};
48
49struct SPan {
50 float _x1, _z1;
51 float _x2, _z2;
52 float _h;
53 int _flags;
54 int16 _nearPanel1;
55 int16 _nearPanel2;
56 int8 _col1;
57 int8 _col2;
58
59 void clear() {
60 _x1 = _z1 = 0.0f;
61 _x2 = _z2 = 0.0f;
62 _h = 0.0f;
63 _flags = 0;
64 _nearPanel1 = _nearPanel2 = 0;
65 _col1 = _col2 = 0;
66 }
67};
68
69struct SStep {
70 float _px, _pz;
71 float _dx, _dz;
72 float _theta;
73 int _curAction;
74 int _curFrame;
75 int16 _curPanel;
76
77 void clear() {
78 _px = _pz = 0.0f;
79 _dx = _dz = 0.0f;
80 _theta = 0.0f;
81 _curAction = 0;
82 _curFrame = 0;
83 _curPanel = 0;
84 }
85};
86
87class TrecisionEngine;
88
90 TrecisionEngine *_vm;
91
92 SPathNode _pathNode[MAXPATHNODES];
93 float _invP[3][3];
94 int _numPathNodes;
95 float _x3d, _y3d, _z3d;
96 float _curX, _curZ;
97 float _lookX, _lookZ;
98 int32 _panelNum;
99 int16 _oldPanel;
100 int _actorPos;
101 int _forcedActorPos;
102
103 bool pointInside(int pan, float x, float z) const;
104 void sortPanel();
105 void pointOut();
106 void invPointProject(int x, int y);
107 bool intersectLinePanel(SPan *p, float x, float y, float z);
108 bool intersectLineFloor(float x, float y, float z);
109 bool intersectLineLine(float xa, float ya, float xb, float yb, float xc, float yc, float xd, float yd);
110 void findShortPath();
111 float evalPath(int a, float destX, float destZ, int nearP);
112 void lookAt(float x, float z);
113 void buildFramelist();
114 void displayPath();
115 bool findAttachedPanel(int16 srcPanel, int16 destPanel);
116 void sortPath();
117
118public:
121
122 int _curStep;
123 int _lastStep;
124 int16 _curPanel;
125 int _numSortPanel;
126
127 int8 _characterGoToPosition;
128 bool _characterInMovement;
129 SSortPan _sortPan[32];
130 SStep _step[MAXSTEP];
131 SPan _panel[MAXPANELSINROOM];
132
133 void findPath();
134 void setPosition(int num);
135 void goToPosition(int num);
136 int nextStep();
137 void initSortPan();
138 void read3D(Common::SeekableReadStreamEndian *ff);
139 void reset(uint16 idx, float px, float pz, float theta);
140 void whereIs(int px, int py);
141 void actorOrder();
142 void syncGameStream(Common::Serializer &ser);
143 int getActorPos() const { return _actorPos; }
144 void setForcedActorPos(int actorPos) { _forcedActorPos = actorPos; }
145};
146
147} // End of namespace Trecision
148#endif
149
Definition: stream.h:944
Definition: serializer.h:80
Definition: pathfinding3d.h:89
Definition: trecision.h:112
Definition: pathfinding3d.h:49
Definition: pathfinding3d.h:35
Definition: pathfinding3d.h:30
Definition: pathfinding3d.h:69