]> git.tdb.fi Git - r2c2.git/blob - source/3d/catalogue.h
ea4182893b36a3b1f3823b36e99f08e66577fbbe
[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/fs/path.h>
6 #include <msp/gl/material.h>
7 #include <msp/gl/mesh.h>
8 #include "libr2c2/catalogue.h"
9 #include "typemap.h"
10
11 namespace R2C2 {
12
13 class ObjectType3D;
14
15 class Catalogue3D: public Msp::DataFile::Collection
16 {
17 private:
18         Catalogue &catalogue;
19         std::map<const ObjectType *, ObjectType3D *> objects;
20         std::map<const TrackAppearance *, Msp::GL::Mesh *> endpoint_meshes;
21
22 public:
23         Catalogue3D(Catalogue &);
24         ~Catalogue3D();
25
26         const Catalogue &get_catalogue() const { return catalogue; }
27 private:
28         void object_added(const ObjectType &);
29 public:
30         const ObjectType3D &get_3d(const ObjectType &) const;
31
32         template<typename T>
33         const typename TypeMap3D<T>::Type3D &get_3d(const T &ot) const
34         { return dynamic_cast<const typename TypeMap3D<T>::Type3D &>(get_3d(static_cast<const ObjectType &>(ot))); }
35
36 private:
37         void build_endpoint_mesh(const TrackAppearance &);
38 public:
39         const Msp::GL::Mesh &get_endpoint_mesh(const TrackAppearance &) const;
40
41 private:
42         Msp::FS::Path locate_file(const std::string &);
43
44         template<typename T>
45         T *create(const std::string &);
46
47         template<typename T>
48         T *create2(const std::string &);
49 };
50
51 }
52
53 #endif