00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __TERRAINCOMPONENT_H__
00017 #define __TERRAINCOMPONENT_H__
00018
00019
00020 #include "../../dependencies.h"
00021 #include "SceneComponent.h"
00022
00023
00024
00033 class TerrainComponent : public SceneComponent
00034 {
00035 public:
00036
00037
00040 TerrainComponent(Entity *parent);
00048 TerrainComponent(Entity *parent, const std::string &fileName,
00049 const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f),
00050 const SColor &vertexColor = SColor(255, 255, 255, 255), s32 maxLOD = 5,
00051 s32 smoothFactor = 0);
00053 ~TerrainComponent();
00054
00055
00058 ITerrainSceneNode* getTerrainSceneNode();
00059
00061 const aabbox3df& getBoundingBox() const;
00063 const aabbox3df& getBoundingBox(s32 patchX, s32 patchZ) const;
00065 f32 getHeight(f32 x, f32 y);
00068 IMesh* getMesh();
00070 const vector3df& getTerrainCenter() const;
00071
00082 bool loadHeightMap(const std::string &fileName, const SColor &vertexColor =
00083 SColor(255, 255, 255, 255), s32 smoothFactor = 0);
00084
00100 void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f);
00101
00102
00105 void onHeightMap(void *p);
00106
00107
00110 static bool parseXML(IXMLReader *file, Entity *entity);
00111
00112 private:
00113
00114
00116 void init(const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f),
00117 const SColor &vertexColor = SColor(255, 255, 255, 255),
00118 s32 maxLOD = 5, s32 smoothFactor = 0);
00119
00120
00121 ITerrainSceneNode *mTerrainSN;
00122
00123 std::string mHeightMapFileName;
00124 SColor mVertexColor;
00125 s32 mSmoothFactor;
00126 };
00127
00128 #endif