My Project
 All Classes Files Functions Variables Enumerations Pages
triangle_mesh_terrain.h
Go to the documentation of this file.
1 /**************************************************************************/
2 /* Copyright 2009 Tim Day */
3 /* */
4 /* This file is part of Fracplanet */
5 /* */
6 /* Fracplanet is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* Fracplanet is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with Fracplanet. If not, see <http://www.gnu.org/licenses/>. */
18 /**************************************************************************/
19 
24 #ifndef _triangle_mesh_terrain_h_
25 #define _triangle_mesh_terrain_h_
26 
27 #include "image.h"
28 #include "parameters_terrain.h"
29 #include "triangle_mesh.h"
30 
32 
36 class TriangleMeshTerrain : virtual public TriangleMesh
37 {
38  public:
39 
41  TriangleMeshTerrain(Progress* progress);
42 
45 
47 
49  virtual void write_povray(std::ofstream& out,const ParametersSave&,const ParametersTerrain&) const
50  =0;
51 
53 
55  virtual void write_blender(std::ofstream& out,const ParametersSave&,const ParametersTerrain&,const std::string& mesh_name) const;
56 
58  virtual void render_texture(Raster<ByteRGBA>&,Raster<ushort>*,Raster<ByteRGBA>*,bool shading,float ambient,const XYZ& illumination) const;
59 
60  protected:
61 
63  std::set<uint> sea_triangles;
64 
66  std::set<uint> river_vertices;
67 
69  float max_height;
70 
72  void do_noise(const ParametersTerrain& parameters);
73 
75  void do_sea_level(const ParametersTerrain& parameters);
76 
78  void do_power_law(const ParametersTerrain& parameters);
79 
81  void do_rivers(const ParametersTerrain& parameters);
82 
84  void do_colours(const ParametersTerrain& parameters);
85 
87  void do_terrain(const ParametersTerrain& parameters);
88 };
89 
92 {
93  public:
94 
97 
100  {}
101 
103  void write_povray(std::ofstream& out,const ParametersSave&,const ParametersTerrain&) const;
104 };
105 
108 {
109  public:
110 
112  TriangleMeshTerrainFlat(const ParametersTerrain& parameters,Progress* progress);
113 
116  {}
117 
119  void write_povray(std::ofstream& out,const ParametersSave&,const ParametersTerrain&) const;
120 };
121 
122 #endif
Interface for class TriangleMesh.
void do_power_law(const ParametersTerrain &parameters)
Apply power law.
Definition: triangle_mesh_terrain.cpp:103
TriangleMeshTerrainFlat(const ParametersTerrain &parameters, Progress *progress)
Constructor.
Definition: triangle_mesh_terrain.cpp:679
Contains vertices and triangles of a triangle mesh.
Definition: triangle_mesh.h:49
TriangleMeshTerrain(Progress *progress)
Constructor.
Definition: triangle_mesh_terrain.cpp:26
void do_noise(const ParametersTerrain &parameters)
Add noise to the terrain.
Definition: triangle_mesh_terrain.cpp:35
Aggregates controllable parameters for all things related to save.
Definition: parameters_save.h:30
A subdivided icosahedron.
Definition: triangle_mesh.h:292
void do_rivers(const ParametersTerrain &parameters)
Generate river network.
Definition: triangle_mesh_terrain.cpp:128
Class for 2D raster images of a specified type.
Definition: image.h:75
~TriangleMeshTerrainPlanet()
Destructor.
Definition: triangle_mesh_terrain.h:99
void do_terrain(const ParametersTerrain &parameters)
Invokes all the above steps (sea-level through final colouring) on a pre-subdivided triangle mesh...
Definition: triangle_mesh_terrain.cpp:415
float max_height
Maximum height of terrain (used to scale to/from "normalised" height).
Definition: triangle_mesh_terrain.h:69
Interface (and implementation) for templated Image class.
std::set< uint > river_vertices
Indices of the set of vertices comprising the river network.
Definition: triangle_mesh_terrain.h:66
virtual void write_blender(std::ofstream &out, const ParametersSave &, const ParametersTerrain &, const std::string &mesh_name) const
Dump the model for Blender.
Definition: triangle_mesh_terrain.cpp:426
Class to hold vectors in 3D cartesian co-ordinates.
Definition: xyz.h:34
Mix-in class for call-backs from long operations.
Definition: progress.h:30
void do_sea_level(const ParametersTerrain &parameters)
Impose a sea level (raise lower vertices, and note sea triangles).
Definition: triangle_mesh_terrain.cpp:59
~TriangleMeshTerrainFlat()
Destructor.
Definition: triangle_mesh_terrain.h:115
TriangleMeshTerrainPlanet(const ParametersTerrain &param, Progress *progress)
Constructor.
Definition: triangle_mesh_terrain.cpp:647
This class aggregates the controllable parameters for all things related to terrain generation...
Definition: parameters_terrain.h:35
virtual void write_povray(std::ofstream &out, const ParametersSave &, const ParametersTerrain &) const =0
Dump the model as a POV scene.
Class constructing specific case of a planetary terrain.
Definition: triangle_mesh_terrain.h:91
void write_povray(std::ofstream &out, const ParametersSave &, const ParametersTerrain &) const
Specifc dump-to-povray for flat terrain area.
Definition: triangle_mesh_terrain.cpp:689
void write_povray(std::ofstream &out, const ParametersSave &, const ParametersTerrain &) const
Specifc dump-to-povray for planet terrain.
Definition: triangle_mesh_terrain.cpp:655
void do_colours(const ParametersTerrain &parameters)
Final colouration pass.
Definition: triangle_mesh_terrain.cpp:334
std::set< uint > sea_triangles
Indices of the set of triangles with all vertices at sea-level.
Definition: triangle_mesh_terrain.h:63
~TriangleMeshTerrain()
Destructor.
Definition: triangle_mesh_terrain.cpp:31
This class holds all the terrain-related methods.
Definition: triangle_mesh_terrain.h:36
Class constructing specific case of a flat-base terrain area.
Definition: triangle_mesh_terrain.h:107
virtual void render_texture(Raster< ByteRGBA > &, Raster< ushort > *, Raster< ByteRGBA > *, bool shading, float ambient, const XYZ &illumination) const
Render the mesh onto raster images (colour texture, and optionally 16-bit DEM and/or normal map)...
Definition: triangle_mesh_terrain.cpp:585
Interface for class ParametersTerrain.
A single triangle lying in the z-plane.
Definition: triangle_mesh.h:244