]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/terraintype.cpp
Rework article numbers
[r2c2.git] / source / libr2c2 / terraintype.cpp
1 #include <stdexcept>
2 #include "terraintype.h"
3
4 using namespace std;
5 using namespace Msp;
6
7 namespace R2C2 {
8
9 TerrainType::TerrainType():
10         tile_size(1),
11         elevation_granularity(0.1)
12 { }
13
14 const TerrainType::SurfaceType &TerrainType::get_surface_type(unsigned i) const
15 {
16         if(i>=surface_types.size())
17                 throw out_of_range("TerrainType::get_surface_type");
18         return surface_types[i];
19 }
20
21
22 TerrainType::SurfaceType::SurfaceType():
23         r(0.8),
24         g(0.8),
25         b(0.8)
26 { }
27
28
29 TerrainType::Loader::Loader(TerrainType &tt):
30         DataFile::DerivedObjectLoader<TerrainType, ObjectType::Loader>(tt)
31 {
32         add("elevation_granularity", &TerrainType::elevation_granularity);
33         add("surface", &Loader::surface);
34         add("tile_size", &TerrainType::tile_size);
35 }
36
37 void TerrainType::Loader::surface()
38 {
39         SurfaceType srf;
40         load_sub(srf);
41         obj.surface_types.push_back(srf);
42 }
43
44
45 TerrainType::SurfaceType::Loader::Loader(SurfaceType &st):
46         DataFile::ObjectLoader<SurfaceType>(st)
47 {
48 }
49
50 } // namespace R2C2