]> git.tdb.fi Git - r2c2.git/blob - source/3d/catalogue.h
Use GL::Resources and DirectorySource in Catalogue3D
[r2c2.git] / source / 3d / catalogue.h
1 #ifndef R2C2_3D_CATALOGUE_H_
2 #define R2C2_3D_CATALOGUE_H_
3
4 #include <msp/datafile/collection.h>
5 #include <msp/datafile/directorysource.h>
6 #include <msp/gl/mesh.h>
7 #include <msp/gl/resources.h>
8 #include "libr2c2/catalogue.h"
9 #include "typemap.h"
10
11 namespace R2C2 {
12
13 class ObjectType3D;
14
15 class Catalogue3D: public Msp::GL::Resources
16 {
17 private:
18         Catalogue &catalogue;
19         Msp::DataFile::DirectorySource src;
20         std::map<const ObjectType *, ObjectType3D *> objects;
21         std::map<const TrackAppearance *, Msp::GL::Mesh *> endpoint_meshes;
22
23 public:
24         Catalogue3D(Catalogue &);
25         ~Catalogue3D();
26
27         const Catalogue &get_catalogue() const { return catalogue; }
28 private:
29         void object_added(const ObjectType &);
30 public:
31         const ObjectType3D &get_3d(const ObjectType &) const;
32
33         template<typename T>
34         const typename TypeMap3D<T>::Type3D &get_3d(const T &ot) const
35         { return dynamic_cast<const typename TypeMap3D<T>::Type3D &>(get_3d(static_cast<const ObjectType &>(ot))); }
36
37 private:
38         void build_endpoint_mesh(const TrackAppearance &);
39 public:
40         const Msp::GL::Mesh &get_endpoint_mesh(const TrackAppearance &) const;
41 };
42
43 }
44
45 #endif