dungeon_crawler
view prototype/src/tile.h @ 53:1ea56011c1ff
stuff + streaming start
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 19 Sep 2012 01:08:41 +0300 |
parents | c40efa9cf844 |
children | 6a471c87f9ca |
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 float volume;
37 float ref_dist;
38 };
40 private:
41 TileSet *tset;
43 AudioSample *samples[MAX_TILE_SAMPLES];
45 std::vector<Mesh*> meshes;
46 std::vector<unsigned int> mesh_side, light_side, psys_side;
47 std::vector<Light*> lights;
48 // attributes for gridcell-unique particle systems
49 std::vector<struct psys_attributes*> psattr;
50 // global particle systems (simulated once, drawn for each tile instance).
51 std::vector<struct psys_emitter*> psys_global;
52 long last_upd;
54 // audio sources
55 std::vector<AudioSourceDesc> ausrc;
57 int load_lights(const aiScene *scn);
58 int load_meshes(const aiScene *scn, const std::map<aiMesh*, aiNode*> &nmap);
60 public:
61 Tile(TileSet *tileset = 0);
62 ~Tile();
64 AudioSample *get_sample(int sidx) const;
66 int get_audio_source_count() const;
67 const AudioSourceDesc &get_audio_source(int idx) const;
69 int get_unique_psys_count() const;
70 struct psys_attributes *get_unique_psys(int idx);
71 const struct psys_attributes *get_unique_psys(int idx) const;
73 bool load(const char *fname);
75 void update(unsigned long msec, float dt);
77 void draw(unsigned int drawmask) const;
78 void draw_lights(unsigned int drawmask) const;
79 void draw_post(unsigned int drawmask) const;
80 };
83 #endif // TILE_H_