]> git.tdb.fi Git - r2c2.git/blob - source/3d/catalogue.h
caf104e5ef146bcb9ec844dd963037bf41294ab7
[r2c2.git] / source / 3d / catalogue.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef R2C2_3D_CATALOGUE_H_
9 #define R2C2_3D_CATALOGUE_H_
10
11 #include <msp/datafile/collection.h>
12 #include <msp/fs/path.h>
13 #include <msp/gl/material.h>
14 #include <msp/gl/mesh.h>
15 #include "libr2c2/catalogue.h"
16
17 namespace R2C2 {
18
19 class TrackType3D;
20 class VehicleType3D;
21
22 class Catalogue3D: public Msp::DataFile::Collection
23 {
24 private:
25         Catalogue &catalogue;
26         std::map<const TrackType *, TrackType3D *> tracks;
27         std::map<const VehicleType *, VehicleType3D *> vehicles;
28         Msp::GL::Material ballast_material;
29         Msp::GL::Material rail_material;
30         Msp::GL::Mesh endpoint_mesh;
31
32 public:
33         Catalogue3D(Catalogue &);
34         ~Catalogue3D();
35
36         const Catalogue &get_catalogue() const { return catalogue; }
37         const TrackType3D &get_track(const TrackType &) const;
38         const VehicleType3D &get_vehicle(const VehicleType &) const;
39         const Msp::GL::Material &get_ballast_material() const { return ballast_material; }
40         const Msp::GL::Material &get_rail_material() const { return rail_material; }
41         const Msp::GL::Mesh &get_endpoint_mesh() const { return endpoint_mesh; }
42 private:
43         void track_added(const TrackType &);
44         void vehicle_added(const VehicleType &);
45         void build_endpoint_mesh();
46
47         Msp::FS::Path locate_file(const std::string &);
48
49         template<typename T>
50         T *create(const std::string &);
51
52         template<typename T>
53         T *create2(const std::string &);
54 };
55
56 }
57
58 #endif