dungeon_crawler

view prototype/src/tile.h @ 50:c40efa9cf844

torches sound
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 18 Sep 2012 04:45:46 +0300
parents 303743485aba
children d57df51f6b50
line source
1 #ifndef TILE_H_
2 #define TILE_H_
4 #include <vector>
5 #include <map>
6 #include <assimp/scene.h>
7 #include <psys/psys.h>
8 #include "mesh.h"
9 #include "light.h"
10 #include "audio/sample.h"
11 #include "audio/source.h"
13 enum {
14 TILE_NORTH = 1,
15 TILE_SOUTH = 2,
16 TILE_EAST = 4,
17 TILE_WEST = 8,
18 TILE_ALL = 0xffff
19 };
21 enum {
22 TILE_SAMPLE_WALK,
23 TILE_SAMPLE_RUN,
25 MAX_TILE_SAMPLES
26 };
28 class TileSet;
30 class Tile {
31 public:
32 struct AudioSourceDesc {
33 unsigned int dirmask;
34 Vector3 pos;
35 AudioSample *sample;
36 };
38 private:
39 TileSet *tset;
41 AudioSample *samples[MAX_TILE_SAMPLES];
43 std::vector<Mesh*> meshes;
44 std::vector<unsigned int> mesh_side, light_side, psys_side;
45 std::vector<Light*> lights;
46 // attributes for gridcell-unique particle systems
47 std::vector<struct psys_attributes*> psattr;
48 // global particle systems (simulated once, drawn for each tile instance).
49 std::vector<struct psys_emitter*> psys_global;
50 long last_upd;
52 // audio sources
53 std::vector<AudioSourceDesc> ausrc;
55 int load_lights(const aiScene *scn);
56 int load_meshes(const aiScene *scn, const std::map<aiMesh*, aiNode*> &nmap);
58 public:
59 Tile(TileSet *tileset = 0);
60 ~Tile();
62 AudioSample *get_sample(int sidx) const;
64 int get_audio_source_count() const;
65 const AudioSourceDesc &get_audio_source(int idx) const;
67 int get_unique_psys_count() const;
68 struct psys_attributes *get_unique_psys(int idx);
69 const struct psys_attributes *get_unique_psys(int idx) const;
71 bool load(const char *fname);
73 void update(unsigned long msec, float dt);
75 void draw(unsigned int drawmask) const;
76 void draw_lights(unsigned int drawmask) const;
77 void draw_post(unsigned int drawmask) const;
78 };
81 #endif // TILE_H_