DIE Engine
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1
11
12#ifndef MAP_H
13#define MAP_H
14
15#include "mapobjects_eq.h"
16#include "env.h"
17
18#include <QList>
19#include <QVector3D>
20#include <QImage>
21
22#include <stdio.h>
23#include <stdint.h>
24
25class QSpatialSound;
26
27/*****************************************************************************/
31struct MapState {
32 QList<Node> nodes;
33 QList<Wall> walls;
34 QList<Submap> submaps;
35 QList<Door> doors;
36 QList<Lift> lifts;
37 QList<Sprite> sprites;
38 QList<Staircase> staircases;
39 QList<Light> lights;
40 QList<Speaker> speakers;
41 QList<Path> paths;
44};
45
46bool operator==(const MapState & a, const MapState & b);
47
48/*****************************************************************************/
49class Map
50{
51public:
52 Map();
53
54 void init();
55 void terminate();
56
58 void update();
59
66 bool save(const QString & filename, bool submap);
67
73 bool load(const QString & filename);
74
76 void pass(const QVector3D & camPos);
77
79 void performAction(const QVector3D & pos);
80
81 void doorOpen(uint16_t dId);
82 void doorClose(uint16_t dId);
83 void doorShake(uint16_t dId);
84
85 void liftStart(uint16_t eId);
86 void liftStop(uint16_t eId);
87
88 void speakerApplyFlags(uint16_t sId);
89
91 void computeAllWalls();
92 void computeWall(uint16_t wId);
93
94 QString getRelativePath(const QString & subMapPath);
95 QString resolveRelativePath(const QString & subMapPath);
96
97// Object lookups, by tag name and by object name
98 QList<Node> findNodesByTag(const char * tagName) const;
99 QList<Submap> findSubmapsByTag(const char * tagName) const;
100 QList<Door> findDoorsByTag(const char * tagName) const;
101 QList<Lift> findLiftsByTag(const char * tagName) const;
102 QList<Sprite> findSpritesByTag(const char * tagName) const;
103 QList<Light> findLightsByTag(const char * tagName) const;
104 QList<Speaker> findSpeakersByTag(const char * tagName) const;
105 QList<Path> findPathsByTag(const char * tagName) const;
106
107 int findSubmapByName(const char * name) const;
108 int findDoorByName(const char * name) const;
109 int findLiftByName(const char * name) const;
110 int findSpriteByName(const char * name) const;
111 int findSpeakerByName(const char * name) const;
112 int findPathByName(const char * name) const;
113
115 MapState captureState() const;
116
118 void restoreState(const MapState & state);
119
120 QVector3D origin;
121 float pan;
122 float scale;
123
124 QString path;
125 QImage textures;
128 QList<Node> nodes;
129 QList<Wall> walls;
130 QList<Submap> submaps;
131 QList<Door> doors;
132 QList<Lift> lifts;
133 QList<Sprite> sprites;
134 QList<Staircase> staircases;
135 QList<Light> lights;
136 QList<Speaker> speakers;
137 QList<Path> paths;
138
139 QList<Map> maps;
140 QList<QSpatialSound *> sounds;
141
142private:
143 void clearObjects();
144 void resetEnvironment();
145
146 void passAsSub(const QVector3D & camPos);
147 void passNodes();
148 void passWalls(int nodeBase, int textureBase);
149 void passDoors(int textureBase);
150 void passLifts(int textureBase);
151 void passSprites(int textureBase, const QVector3D & camPos);
152 void passStaircases(int textureBase);
153 void passLights(int nodeBase);
154
155 void updateAllDoors();
156 void updateAllLifts();
157
158 bool loadSubmaps();
159 bool loadSounds();
160
161// Geometry & parsing utilities
162 QVector3D getAbsCoords(const QVector3D & pos);
163 static QVector3D rotateAroundY(const QVector3D & v, float angle);
164 static QVector2D rotateAroundY(const QVector2D & v, float angle);
165 static void skipLine(FILE * file);
166};
167
168#endif // MAP_H
int findSpriteByName(const char *name) const
Definition map.cpp:806
void computeWall(uint16_t wId)
Definition map.cpp:730
void terminate()
Definition map.cpp:76
Map()
Definition map.cpp:42
QList< Node > findNodesByTag(const char *tagName) const
Definition map.cpp:793
QList< Path > findPathsByTag(const char *tagName) const
Definition map.cpp:800
int findDoorByName(const char *name) const
Definition map.cpp:804
void doorShake(uint16_t dId)
Definition map.cpp:249
QImage textures
Definition map.h:125
void pass(const QVector3D &camPos)
Push the map geometry and lights to the renderer.
Definition map.cpp:305
QList< QSpatialSound * > sounds
Definition map.h:140
QString resolveRelativePath(const QString &subMapPath)
Definition map_io.cpp:39
int findPathByName(const char *name) const
Definition map.cpp:808
int findSubmapByName(const char *name) const
Definition map.cpp:803
void liftStop(uint16_t eId)
Definition map.cpp:273
QList< Submap > submaps
Definition map.h:130
float pan
Definition map.h:121
float scale
Definition map.h:122
QList< Speaker > findSpeakersByTag(const char *tagName) const
Definition map.cpp:799
void doorClose(uint16_t dId)
Definition map.cpp:242
bool load(const QString &filename)
Load the map, then its submaps, sounds and textures.
Definition map_io.cpp:193
QString getRelativePath(const QString &subMapPath)
Definition map_io.cpp:31
QList< Sprite > sprites
Definition map.h:133
QList< Path > paths
Definition map.h:137
QList< Sprite > findSpritesByTag(const char *tagName) const
Definition map.cpp:797
QList< Door > doors
Definition map.h:131
QList< Map > maps
Definition map.h:139
QList< Staircase > staircases
Definition map.h:134
QList< Light > lights
Definition map.h:135
QList< Lift > findLiftsByTag(const char *tagName) const
Definition map.cpp:796
void performAction(const QVector3D &pos)
Trigger the actionable objects (doors, lifts) close to a position.
Definition map.cpp:168
QList< Lift > lifts
Definition map.h:132
QString path
Definition map.h:124
void update()
Animate the doors and the lifts.
Definition map.cpp:97
bool save(const QString &filename, bool submap)
Save the map to a file.
Definition map_io.cpp:48
Fog fog
Definition map.h:127
QList< Door > findDoorsByTag(const char *tagName) const
Definition map.cpp:795
int findLiftByName(const char *name) const
Definition map.cpp:805
Sun sun
Definition map.h:126
void init()
Definition map.cpp:67
QList< Wall > walls
Definition map.h:129
QList< Submap > findSubmapsByTag(const char *tagName) const
Definition map.cpp:794
void doorOpen(uint16_t dId)
Definition map.cpp:234
QList< Speaker > speakers
Definition map.h:136
MapState captureState() const
Snapshot the persistent map data (see MapState).
Definition map.cpp:811
void speakerApplyFlags(uint16_t sId)
Definition map.cpp:283
QList< Node > nodes
Definition map.h:128
void liftStart(uint16_t eId)
Definition map.cpp:257
void restoreState(const MapState &state)
Restore a snapshot of the map data.
Definition map.cpp:829
QList< Light > findLightsByTag(const char *tagName) const
Definition map.cpp:798
int findSpeakerByName(const char *name) const
Definition map.cpp:807
QVector3D origin
Definition map.h:120
void computeAllWalls()
Recompute the cached wall geometry (dir, normal, length).
Definition map.cpp:724
bool operator==(const MapState &a, const MapState &b)
Definition map.cpp:846
Distance fog properties.
Definition env.h:38
Snapshot of the persistent map data, used for the undo history.
Definition map.h:31
QList< Node > nodes
Definition map.h:32
QList< Lift > lifts
Definition map.h:36
QList< Light > lights
Definition map.h:39
QList< Path > paths
Definition map.h:41
QList< Staircase > staircases
Definition map.h:38
Sun sun
Definition map.h:42
QList< Wall > walls
Definition map.h:33
QList< Door > doors
Definition map.h:35
QList< Submap > submaps
Definition map.h:34
QList< Sprite > sprites
Definition map.h:37
Fog fog
Definition map.h:43
QList< Speaker > speakers
Definition map.h:40
Sun lighting properties.
Definition env.h:22