19 #ifndef HEIGHTMAP_LOADER_H
20 #define HEIGHTMAP_LOADER_H
23 #include "../loader.h"
34 Mesh* terrain =
nullptr;
41 float one_over_grid_spacing;
47 return height_at_xz(
Vec2(x, z));
54 return triangle_at_xz(
Vec2(x, z));
61 typedef std::function<void (
float height,
const Vec3&,
float& weight1,
float& weight2,
float& weight3,
float& weight4)> AlphaMapWeightFunc;
63 void recalculate_terrain_normals(smlt::MeshPtr terrain);
64 void smooth_terrain(smlt::MeshPtr terrain, uint32_t iterations=20);
65 AssetID generate_alphamap(smlt::MeshPtr terrain, AlphaMapWeightFunc func);
70 float min_height = -64.0f;
71 float max_height = 64.0f;
73 uint32_t smooth_iterations = 0;
74 bool calculate_normals =
true;
75 float texcoord0_repeat = 4.0f;
88 Loader(
"", std::make_shared<std::istringstream>()),
91 void into(
Loadable& resource,
const LoaderOptions& options = LoaderOptions());
94 TexturePtr texture_ =
nullptr;
95 void smooth_terrain_iteration(
Mesh *mesh,
int width,
int height);
102 add_hint(LOADER_HINT_MESH);
107 const char* name()
override {
return "heightmap_loader"; }
109 bool supports(
const Path& filename)
const override {
110 return filename.ext() ==
".tga" || filename.ext() ==
".png";
113 Loader::ptr loader_for(
const Path& filename, std::shared_ptr<std::istream> data)
const override {
122 #endif // HEIGHTMAP_LOADER_H