/// The alignment of the terrain 地形的对齐模式
enum Alignment//地形的对齐模式
{
/// Terrain is in the X/Z plane
ALIGN_X_Z = 0, //地形的对其方式
/// Terrain is in the X/Y plane
ALIGN_X_Y = 1,
/// Terrain is in the Y/Z plane
ALIGN_Y_Z = 2
};
/** Structure encapsulating(封装) import data(导入数据) that you may use to bootstrap
the terrain without loading from a native data stream.
*/
struct ImportData//导入数据
{
/// The alignment of the terrain
Alignment terrainAlign;//地形的Alignment
/// Terrain size (along one edge 沿着一个边缘) in vertices; must be 2^n+1
uint16 terrainSize;//地形的大小 terrainSize
/** Maximum batch size (along one edge) in vertices; must be 2^n+1 and <= 65
@remarks
The terrain will be divided into hierarchical tiles, and this is the maximum
size of one tile in vertices (at any LOD). 地形Tile包含最多的顶点的数目 maxBatchSize
*/
uint16 maxBatchSize;//最大批次 用来计算LOD Tile的包含的最大的顶点数目
/** Minimum batch size (along one edge) in vertices; must be 2^n+1.
@remarks
The terrain will be divided into tiles, and this is the minimum
size of one tile in vertices (at any LOD). Adjacent tiles will be
collected together into one batch to drop LOD levels once they are individually at this minimum,
so setting this value higher means greater batching at the expense
of making adjacent tiles use a common LOD.
Once the entire terrain is collected together into one batch this
effectively sets the minimum LOD.
*/
uint16 minBatchSize;
/** Position of the terrain.
@remarks
Represents the position of the centre of the terrain.
*/
Vector3 pos;//地形的中心的位置
/** The world size of the terrain. */
Real worldSize;//地形的世界大小
/** Optional heightmap(可选的高度图) providing the initial heights(初始高度) for the terrain.
@remarks
If supplied, should ideally(建议,理想的) be terrainSize * terrainSize, but if
it isn't it will be resized.
*/
Image* inputImage;//为地形提供初始的高度
/** Optional list of terrainSize * terrainSize floats defining the terrain.
The list of floats wil be interpreted such that the first row
in the array equates(相当于) to the bottom row of vertices.
*/
float* inputFloat;//
/** If neither inputImage or inputFloat are supplied, the constant
height(常量高度) at which the initial terrain should be created (flat).
*/
float constantHeight;//如果Image或者inputFloat都没有提供 那么就需要创建一个平坦的地图
/** Whether this structure should 'own' the input data (inputImage and
inputFloat), and therefore delete it on destruction.
The default is false so you have to manage your own memory. If you
set it to true, then you must have allocated the memory through
OGRE_NEW (for Image) and OGRE_ALLOC_T (for inputFloat), the latter
with the category MEMCATEGORY_GEOMETRY.
*/
bool deleteInputData;
/// How to scale the input values provided (if any)
Real inputScale;
/// How to bias the input values provided (if any)
Real inputBias;
/** Definition of the contents of each layer (required).
Most likely, you will pull a declaration from a TerrainMaterialGenerator
of your choice.
*/
TerrainLayerDeclaration layerDeclaration;
/** List of layer structures, one for each layer required.
Can be empty or underfilled if required, list will be padded with
blank textures. 能够为空,或者没有被填充的,他们的纹理江北填充为空纹理
*/
LayerInstanceList layerList;
ImportData()
: terrainAlign(ALIGN_X_Z)//地形的对其模式
, terrainSize(1025) //地形的大小
, maxBatchSize(65)//
, minBatchSize(17)//
, pos(Vector3::ZERO)//地形中心的位置
, worldSize(1000)//
, inputImage(0)
, inputFloat(0)
, constantHeight(0)
, deleteInputData(false)
, inputScale(1.0)
, inputBias(0.0)
{
}
ImportData(const ImportData& rhs)
: terrainAlign(ALIGN_X_Z)
, terrainSize(1025)
, maxBatchSize(65)
, minBatchSize(17)
, pos(Vector3::ZERO)
, worldSize(1000)
, inputImage(0)
, inputFloat(0)
, constantHeight(0)
, deleteInputData(false)
, inputScale(1.0)
, inputBias(0.0)
{
*this = rhs;
}
ImportData& operator=(const ImportData& rhs)
{
// basic copy
terrainAlign = rhs.terrainAlign;
terrainSize = rhs.terrainSize;
maxBatchSize = rhs.maxBatchSize;
minBatchSize = rhs.minBatchSize;
pos = rhs.pos;
worldSize = rhs.worldSize;
constantHeight = rhs.constantHeight;
deleteInputData = rhs.deleteInputData;
inputScale = rhs.inputScale;
inputBias = rhs.inputBias;
layerDeclaration = rhs.layerDeclaration;
layerList = rhs.layerList;
// By-value copies in ownership cases
if (rhs.deleteInputData)
{
if (rhs.inputImage)
inputImage = OGRE_NEW Image(*rhs.inputImage);
else
inputImage = 0;
if (rhs.inputFloat)
{
inputFloat = OGRE_ALLOC_T(float, terrainSize*terrainSize, MEMCATEGORY_GEOMETRY);
memcpy(inputFloat, rhs.inputFloat, sizeof(float) * terrainSize*terrainSize);
}
else
inputFloat = 0;
}
else
{
// re-use pointers
inputImage = rhs.inputImage;
inputFloat = rhs.inputFloat;
}
return *this;
}
/// Delete any input data if this struct is set to do so
void destroy()
{
if (deleteInputData)
{
OGRE_DELETE inputImage;
OGRE_FREE(inputFloat, MEMCATEGORY_GEOMETRY);
inputImage = 0;
inputFloat = 0;
}
}
~ImportData()
{
destroy();
}
};
ImportData
最新推荐文章于 2022-11-13 16:20:44 发布