ScummVM API documentation
holomap_v2.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_HOLOMAPV2_H
23 #define TWINE_HOLOMAPV2_H
24 
25 #include "twine/holomap.h"
26 #include "twine/shared.h"
27 
28 namespace TwinE {
29 
30 #define HOLO_MAX_OBJECTIF 50
31 #define HOLO_MAX_CUBE 255
32 #define HOLO_MAX_ARROW (HOLO_MAX_OBJECTIF + HOLO_MAX_CUBE)
33 
34 // Globe mesh parameters (LBA2 uses 4x angle factor)
35 #define HOLO_STEP_ANGLE 128
36 #define HOLO_GLOBE_ALPHA_STEPS ((LBAAngles::ANGLE_360 / HOLO_STEP_ANGLE) + 1) // 33
37 #define HOLO_GLOBE_BETA_STEPS ((LBAAngles::ANGLE_180 / HOLO_STEP_ANGLE) + 1) // 17 (alpha from -90 to +90 = 180 degrees)
38 // Actually: alpha from -1024 to 1024 step 128 = 17 rows, beta from 0 to 4096 step 128 = 32 cols + 1 wrap = 33
39 #define HOLO_GLOBE_COLS 33
40 #define HOLO_GLOBE_ROWS 17
41 #define HOLO_GLOBE_VERTICES (HOLO_GLOBE_COLS * HOLO_GLOBE_ROWS)
42 #define HOLO_GLOBE_QUADS ((HOLO_GLOBE_COLS - 1) * (HOLO_GLOBE_ROWS - 1)) // 512
43 
44 #define HOLO_RAYON_PLANET 1000
45 #define HOLO_ZOOM_PLANET 8000
46 #define HOLO_ZOOM_INIT_PLANET 3000
47 
48 class HolomapV2 : public Holomap {
49 private:
50  using Super = Holomap;
51 
52 public:
53  struct Location {
54  int32 X = 0;
55  int32 Y = 0;
56  int32 Z = 0;
57  int32 Alpha = 0;
58  int32 Beta = 0;
59  int32 Alt = 0;
60  int32 Mess = 0;
61  int8 ObjFix = 0;
62  uint8 FlagHolo = 0u;
63  uint8 Planet = 0u;
64  uint8 Island = 0u;
65  };
66  static_assert(sizeof(Location) == 32, "Invalid Location size");
67 
68 private:
69  Location _locations[HOLO_MAX_ARROW];
70 
71  // Globe mesh data
72  IVec3 _holomapSurface[HOLO_GLOBE_VERTICES];
73 
74  struct HolomapProjectedPos {
75  int16 x1 = 0; // screen X
76  int16 y1 = 0; // screen Y
77  uint16 x2 = 0; // texture U
78  uint16 y2 = 0; // texture V
79  };
80  HolomapProjectedPos _projectedSurfacePositions[HOLO_GLOBE_VERTICES];
81 
82  struct HolomapSort {
83  int16 z = 0;
84  uint16 projectedPosIdx = 0;
85  };
86  HolomapSort _holomapSort[HOLO_GLOBE_QUADS];
87 
88  // Globe rendering state
89  int32 _holoAlpha = 0;
90  int32 _holoBeta = 0;
91  int32 _holoGamma = 0;
92  int32 _zoomPlanet = HOLO_ZOOM_INIT_PLANET;
93  int32 _zoomPlanetDest = HOLO_ZOOM_PLANET;
94 
95  // Camera interpolation
96  int32 _destAlpha = 0;
97  int32 _destBeta = 0;
98  int32 _moveTimer = 0;
99  bool _automove = false;
100 
101  // Objective/selection state
102  int32 _numObjectif = -1;
103  int32 _oldObjectif = -1;
104 
105  // UI state
106  bool _flagRedraw = true;
107  bool _flagPal = true;
108  bool _flagHoloEnd = false;
109 
110  // Holomap image
111  uint8 *_holomapImagePtr = nullptr;
112  int32 _holomapImageSize = 0;
113 
114  void computeCoorMapping();
115  void computeCoorGlobe(Common::SeekableReadStream *surfaceStream);
116  void computeGlobeProj();
117  void drawHoloMap();
118  void drawListHoloGlobe(bool frontFace);
119  void drawReticule();
120  bool goToArrow();
121 
122  int32 distance(float dist) const;
123  int32 scale(float val) const;
124 
125 public:
126  HolomapV2(TwinEEngine *engine) : Super(engine) {}
127  virtual ~HolomapV2() = default;
128 
129  bool setHoloPos(int32 locationIdx) override;
130  bool loadLocations() override;
131  const char *getLocationName(int index) const override;
132  void clrHoloPos(int32 locationIdx) override;
133  void holoTraj(int32 trajectoryIndex) override;
134  void initHoloDatas() override;
135  void holoMap() override;
136 };
137 
138 } // namespace TwinE
139 
140 #endif
Definition: holomap_v2.h:48
Definition: holomap.h:45
Definition: shared.h:127
Definition: holomap_v2.h:53
void initHoloDatas() override
Definition: stream.h:745
Definition: twine.h:207
Definition: achievements_tables.h:27
void clrHoloPos(int32 locationIdx) override
bool setHoloPos(int32 locationIdx) override
void holoMap() override