i6engine  1.0
TerrainAppearanceComponent.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_API_TERRAINAPPEARANCECOMPONENT_H__
26 #define __I6ENGINE_API_TERRAINAPPEARANCECOMPONENT_H__
27 
29 
30 namespace i6e {
31 namespace api {
32 
56  public:
57  TerrainAppearanceComponent(const int64_t id, const attributeMap & params);
59 
63  inline std::string getHeightmap() const { return _heightmap; }
64 
68  inline double getSize() const { return _size; }
69 
74  void setHeightAtPosition(size_t x, size_t z, double height);
75 
80  void setHeightAtPosition(const Vec3 & pos, double height);
81 
86  double getHeightAtPosition(size_t x, size_t z) const;
87 
92  double getHeightAtPosition(const Vec3 & pos) const;
93 
98  void saveCollisionShape(const std::string & outFile, const std::function<void(void)> & cb);
99 
103  attributeMap synchronize() const override;
104 
105  std::string getTemplateName() const override {
106  return "TerrainAppearance";
107  }
108 
109  std::vector<componentOptions> getComponentOptions() override;
110 
111  private:
112  std::string _heightmap;
113  std::vector<std::vector<double>> _heightdata;
114  double _size;
115  double _inputScale;
116  uint16_t _vertices;
117  std::vector<std::tuple<double, std::string, std::string, double, double>> _layers;
118  int64_t _minX;
119  int64_t _maxX;
120  int64_t _minY;
121  int64_t _maxY;
122 
123  void Init() override;
124 
125  void Finalize() override;
126 
127  void sendUpdateMessage();
128 
129  void convertPositionToVertex(const Vec3 & pos, size_t & x, size_t & z) const;
130  };
131 
132 } /* namespace api */
133 } /* namespace i6e */
134 
135 #endif /* __I6ENGINE_API_TERRAINAPPEARANCECOMPONENT_H__ */
136 
#define ISIXE_MODULES_API
std::map< std::string, std::string > attributeMap
Definition: attributeMap.h:42
Implements 3-dimensional vectors.
Definition: i6eVector.h:48
double getSize() const
Gets the GameObject's size.
std::string getHeightmap() const
Gets the GameObject's heightmap.
std::string getTemplateName() const override
returns the name this template was registered with
Tells the engine what heightmap and texture to use when rendering the GameObject. For creating a Terr...
Component Base Class. All Components must derive from Component.
Definition: Component.h:97