mirror of https://github.com/axmolengine/axmol.git
commit
378cfa35b6
|
@ -223,7 +223,7 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags)
|
|||
#endif
|
||||
}
|
||||
|
||||
bool Terrain::initHeightMap(const char * heightMap)
|
||||
bool Terrain::initHeightMap(const std::string& heightMap)
|
||||
{
|
||||
_heightMapImage = new Image();
|
||||
_heightMapImage->initWithImageFile(heightMap);
|
||||
|
@ -630,7 +630,7 @@ cocos2d::Vec2 Terrain::convertToTerrainSpace(Vec2 worldSpaceXZ) const
|
|||
return Vec2(image_x,image_y);
|
||||
}
|
||||
|
||||
void Terrain::resetHeightMap(const char * heightMap)
|
||||
void Terrain::resetHeightMap(const std::string& heightMap)
|
||||
{
|
||||
_heightMapImage->release();
|
||||
_vertices.clear();
|
||||
|
@ -857,7 +857,7 @@ bool Terrain::initTextures()
|
|||
Texture2D::TexParams texParam;
|
||||
texParam.wrapS = GL_REPEAT;
|
||||
texParam.wrapT = GL_REPEAT;
|
||||
if(!_terrainData._alphaMapSrc)
|
||||
if(_terrainData._alphaMapSrc.empty())
|
||||
{
|
||||
auto textImage = new (std::nothrow)Image();
|
||||
textImage->initWithImageFile(_terrainData._detailMaps[0]._detailMapSrc);
|
||||
|
@ -1581,21 +1581,21 @@ Terrain::QuadTree::~QuadTree()
|
|||
if(_br) delete _br;
|
||||
}
|
||||
|
||||
Terrain::TerrainData::TerrainData(const char * heightMapsrc , const char * textureSrc, const Size & chunksize, float height, float scale)
|
||||
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc , const std::string& textureSrc, const Size & chunksize, float height, float scale)
|
||||
{
|
||||
this->_heightMapSrc = heightMapsrc;
|
||||
this->_detailMaps[0]._detailMapSrc = textureSrc;
|
||||
this->_alphaMapSrc = nullptr;
|
||||
this->_alphaMapSrc = "";
|
||||
this->_chunkSize = chunksize;
|
||||
this->_mapHeight = height;
|
||||
this->_mapScale = scale;
|
||||
_skirtHeightRatio = 1;
|
||||
}
|
||||
|
||||
Terrain::TerrainData::TerrainData(const char * heightMapsrc, const char * alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Size & chunksize, float height, float scale)
|
||||
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Size & chunksize, float height, float scale)
|
||||
{
|
||||
this->_heightMapSrc = heightMapsrc;
|
||||
this->_alphaMapSrc = const_cast<char *>(alphamap);
|
||||
this->_alphaMapSrc = alphamap;
|
||||
this->_detailMaps[0] = detail1;
|
||||
this->_detailMaps[1] = detail2;
|
||||
this->_detailMaps[2] = detail3;
|
||||
|
@ -1607,14 +1607,13 @@ Terrain::TerrainData::TerrainData(const char * heightMapsrc, const char * alpham
|
|||
_skirtHeightRatio = 1;
|
||||
}
|
||||
|
||||
Terrain::TerrainData::TerrainData(const char* heightMapsrc, const char * alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const Size & chunksize /*= Size(32,32)*/, float height /*= 2*/, float scale /*= 0.1*/)
|
||||
Terrain::TerrainData::TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1, const DetailMap& detail2, const DetailMap& detail3, const Size & chunksize /*= Size(32,32)*/, float height /*= 2*/, float scale /*= 0.1*/)
|
||||
{
|
||||
this->_heightMapSrc = heightMapsrc;
|
||||
this->_alphaMapSrc = const_cast<char *>(alphamap);
|
||||
this->_alphaMapSrc = alphamap;
|
||||
this->_detailMaps[0] = detail1;
|
||||
this->_detailMaps[1] = detail2;
|
||||
this->_detailMaps[2] = detail3;
|
||||
this->_detailMaps[3] = nullptr;
|
||||
this->_chunkSize = chunksize;
|
||||
this->_mapHeight = height;
|
||||
this->_mapScale = scale;
|
||||
|
@ -1627,7 +1626,7 @@ Terrain::TerrainData::TerrainData()
|
|||
|
||||
}
|
||||
|
||||
Terrain::DetailMap::DetailMap(const char * detailMapPath, float size /*= 35*/)
|
||||
Terrain::DetailMap::DetailMap(const std::string& detailMapPath, float size /*= 35*/)
|
||||
{
|
||||
this->_detailMapSrc = detailMapPath;
|
||||
this->_detailMapSize = size;
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
struct CC_DLL DetailMap{
|
||||
/*Constructors*/
|
||||
DetailMap();
|
||||
DetailMap(const char * detailMapSrc, float size = 35);
|
||||
DetailMap(const std::string& detailMapSrc, float size = 35);
|
||||
/*detail Image source file path*/
|
||||
std::string _detailMapSrc;
|
||||
/*detailMapSize determine how many tiles that Terrain represent*/
|
||||
|
@ -130,11 +130,11 @@ public:
|
|||
/**empty constructor*/
|
||||
TerrainData();
|
||||
/**constructor, this constructor construct a simple terrain which only have 1 detailmap*/
|
||||
TerrainData(const char* heightMapsrc, const char * textureSrc, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
|
||||
TerrainData(const std::string& heightMapsrc, const std::string& textureSrc, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
|
||||
/**constructor, this constructor construct a terrain which have 4 detailmaps, 1 alpha map*/
|
||||
TerrainData(const char* heightMapsrc, const char * alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
|
||||
TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const DetailMap& detail4, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
|
||||
/**constructor, this constructor construct a terrain which have 3 detailmaps, 1 alpha map*/
|
||||
TerrainData(const char* heightMapsrc, const char * alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
|
||||
TerrainData(const std::string& heightMapsrc, const std::string& alphamap, const DetailMap& detail1,const DetailMap& detail2, const DetailMap& detail3, const Size & chunksize = Size(32,32), float mapHeight = 2, float mapScale = 0.1);
|
||||
/**
|
||||
*determine the chunk size,chunk is the minimal subdivision of the Terrain
|
||||
*/
|
||||
|
@ -142,7 +142,7 @@ public:
|
|||
/**height Map source path*/
|
||||
std::string _heightMapSrc;
|
||||
/**the source path of the alpha map*/
|
||||
char* _alphaMapSrc;
|
||||
std::string _alphaMapSrc;
|
||||
/**detail maps*/
|
||||
DetailMap _detailMaps[4];
|
||||
/**terrain Maximum height*/
|
||||
|
@ -316,7 +316,7 @@ public:
|
|||
/**initialize all Properties which terrain need */
|
||||
bool initProperties();
|
||||
/**initialize heightMap data */
|
||||
bool initHeightMap(const char* heightMap);
|
||||
bool initHeightMap(const std::string& heightMap);
|
||||
/**initialize alphaMap ,detailMaps textures*/
|
||||
bool initTextures();
|
||||
/**create entry*/
|
||||
|
@ -392,7 +392,7 @@ public:
|
|||
/**
|
||||
* reset the heightmap data.
|
||||
*/
|
||||
void resetHeightMap(const char * heightMap);
|
||||
void resetHeightMap(const std::string& heightMap);
|
||||
|
||||
/**
|
||||
* get the terrain's minimal height.
|
||||
|
|
|
@ -319,10 +319,10 @@ void terraindata_to_luaval(lua_State* L,const cocos2d::Terrain::TerrainData& inV
|
|||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
if (nullptr != inValue._alphaMapSrc)
|
||||
if (!inValue._alphaMapSrc.empty())
|
||||
{
|
||||
lua_pushstring(L, "_alphaMapSrc");
|
||||
lua_pushstring(L, inValue._alphaMapSrc);
|
||||
lua_pushstring(L, inValue._alphaMapSrc.c_str());
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue