本文整理汇总了C++中g3d::Array::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::size方法的具体用法?C++ Array::size怎么用?C++ Array::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类g3d::Array
的用法示例。
在下文中一共展示了Array::size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildTile
void MapBuilder::buildTile(int mapID, int tileX, int tileY, dtNavMesh* navMesh)
{
MeshData meshData;
// get heightmap data
m_terrainBuilder->loadMap(mapID, tileX, tileY, meshData, m_magic);
// get model data
m_terrainBuilder->loadVMap(mapID, tileY, tileX, meshData);
// if there is no data, give up now
if (!meshData.solidVerts.size() && !meshData.liquidVerts.size())
{ return; }
// remove unused vertices
TerrainBuilder::cleanVertices(meshData.solidVerts, meshData.solidTris);
TerrainBuilder::cleanVertices(meshData.liquidVerts, meshData.liquidTris);
// gather all mesh data for final data check, and bounds calculation
G3D::Array<float> allVerts;
allVerts.append(meshData.liquidVerts);
allVerts.append(meshData.solidVerts);
if (!allVerts.size())
{ return; }
// get bounds of current tile
float bmin[3], bmax[3];
getTileBounds(tileX, tileY, allVerts.getCArray(), allVerts.size() / 3, bmin, bmax);
m_terrainBuilder->loadOffMeshConnections(mapID, tileX, tileY, meshData, m_offMeshFilePath);
printf(" Building map %03u - Tile [%02u,%02u]\n", mapID, tileX, tileY);
buildMoveMapTile(mapID, tileX, tileY, meshData, bmin, bmax, navMesh);
}
示例2: generateRealObj
void IntermediateValues::generateRealObj(uint32 mapID, uint32 tileX, uint32 tileY, MeshData meshData)
{
char objFileName[255];
sprintf(objFileName, "meshes/map%03u.obj", mapID);
FILE* objFile = fopen(objFileName, "wb");
if (!objFile)
{
char message[1024];
sprintf(message, "Failed to open %s for writing!\n", objFileName);
perror(message);
return;
}
G3D::Array<float> allVerts;
G3D::Array<int> allTris;
allTris.append(meshData.liquidTris);
allVerts.append(meshData.liquidVerts);
TerrainBuilder::copyIndices(allTris, meshData.solidTris, allVerts.size() / 3);
allVerts.append(meshData.solidVerts);
float* verts = allVerts.getCArray();
int* tris = allTris.getCArray();
for (int i = 0; i < allVerts.size() / 3; i++)
fprintf(objFile, "v %f %f %f\n", verts[i*3], verts[i*3 + 1], verts[i*3 + 2]);
for (int i = 0; i < allTris.size() / 3; i++)
fprintf(objFile, "f %i %i %i\n", tris[i*3] + 1, tris[i*3 + 1] + 1, tris[i*3 + 2] + 1);
fclose(objFile);
}
示例3: generateObjFile
void IntermediateValues::generateObjFile(uint32 mapID, uint32 tileX, uint32 tileY, MeshData meshData)
{
generateRealObj(mapID, tileX, tileY, meshData);
char tileString[25];
sprintf(tileString, "[%02u,%02u]: ", tileY, tileX);
printf("%sWriting debug output... \r", tileString);
char objFileName[255];
sprintf(objFileName, "meshes/%03u.map", mapID);
FILE* objFile = fopen(objFileName, "wb");
if (!objFile)
{
char message[1024];
sprintf(message, "Failed to open %s for writing!\n", objFileName);
perror(message);
return;
}
char b = '\0';
fwrite(&b, sizeof(char), 1, objFile);
fclose(objFile);
sprintf(objFileName, "meshes/%03u%02u%02u.mesh", mapID, tileY, tileX);
objFile = fopen(objFileName, "wb");
if (!objFile)
{
char message[1024];
sprintf(message, "Failed to open %s for writing!\n", objFileName);
perror(message);
return;
}
G3D::Array<float> allVerts;
G3D::Array<int> allTris;
allTris.append(meshData.liquidTris);
allVerts.append(meshData.liquidVerts);
TerrainBuilder::copyIndices(allTris, meshData.solidTris, allVerts.size() / 3);
allVerts.append(meshData.solidVerts);
float* verts = allVerts.getCArray();
int vertCount = allVerts.size() / 3;
int* tris = allTris.getCArray();
int triCount = allTris.size() / 3;
fwrite(&vertCount, sizeof(int), 1, objFile);
fwrite(verts, sizeof(float), vertCount*3, objFile);
fflush(objFile);
fwrite(&triCount, sizeof(int), 1, objFile);
fwrite(tris, sizeof(int), triCount*3, objFile);
fflush(objFile);
fclose(objFile);
}
示例4: loadMap
bool TileBuilder::loadMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData, Spot portion)
{
char mapFileName[255];
sprintf(mapFileName, "maps/%03u%02u%02u.map", mapID, tileY, tileX);
FILE* mapFile = fopen(mapFileName, "rb");
if(!mapFile)
return true;
GridMapFileHeader fheader;
fread(&fheader, sizeof(GridMapFileHeader), 1, mapFile);
if(fheader.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)))
{
fclose(mapFile);
printf("%s is the wrong version, please extract new .map files\n", mapFileName);
return false;
}
GridMapHeightHeader hheader;
fseek(mapFile, fheader.heightMapOffset, SEEK_SET);
fread(&hheader, sizeof(GridMapHeightHeader), 1, mapFile);
bool haveTerrain = !(hheader.flags & MAP_HEIGHT_NO_HEIGHT);
bool haveLiquid = fheader.liquidMapOffset && !m_skipLiquid;
// no data in this map file
if(!haveTerrain && !haveLiquid)
{
fclose(mapFile);
return true;
}
// data used later
uint16 holes[16][16];
uint8* liquid_type = 0;
G3D::Array<int> ltriangles;
G3D::Array<int> ttriangles;
// terrain data
if(haveTerrain)
{
int i;
float heightMultiplier;
float V9[V9_SIZE_SQ], V8[V8_SIZE_SQ];
if(hheader.flags & MAP_HEIGHT_AS_INT8)
{
uint8 v9[V9_SIZE_SQ];
uint8 v8[V8_SIZE_SQ];
fread(v9, sizeof(uint8), V9_SIZE_SQ, mapFile);
fread(v8, sizeof(uint8), V8_SIZE_SQ, mapFile);
heightMultiplier = (hheader.gridMaxHeight - hheader.gridHeight) / 255;
for(i = 0; i < V9_SIZE_SQ; ++i)
V9[i] = (float)v9[i]*heightMultiplier + hheader.gridHeight;
if(m_hiResHeightMaps)
for(i = 0; i < V8_SIZE_SQ; ++i)
V8[i] = (float)v8[i]*heightMultiplier + hheader.gridHeight;
}
else if(hheader.flags & MAP_HEIGHT_AS_INT16)
{
uint16 v9[V9_SIZE_SQ];
uint16 v8[V8_SIZE_SQ];
fread(v9, sizeof(uint16), V9_SIZE_SQ, mapFile);
fread(v8, sizeof(uint16), V8_SIZE_SQ, mapFile);
heightMultiplier = (hheader.gridMaxHeight - hheader.gridHeight) / 65535;
for(i = 0; i < V9_SIZE_SQ; ++i)
V9[i] = (float)v9[i]*heightMultiplier + hheader.gridHeight;
if(m_hiResHeightMaps)
for(i = 0; i < V8_SIZE_SQ; ++i)
V8[i] = (float)v8[i]*heightMultiplier + hheader.gridHeight;
}
else
{
fread(V9, sizeof(float), V9_SIZE_SQ, mapFile);
if(m_hiResHeightMaps)
fread(V8, sizeof(float), V8_SIZE_SQ, mapFile);
}
// hole data
memset(holes, 0, fheader.holesSize);
fseek(mapFile, fheader.holesOffset, SEEK_SET);
fread(holes, fheader.holesSize, 1, mapFile);
int count = meshData.solidVerts.size() / 3;
float xoffset = (float(tileX)-32)*GRID_SIZE;
float yoffset = (float(tileY)-32)*GRID_SIZE;
float coord[3];
for(i = 0; i < V9_SIZE_SQ; ++i)
{
getHeightCoord(i, GRID_V9, xoffset, yoffset, coord, V9);
meshData.solidVerts.append(coord[0]);
meshData.solidVerts.append(coord[2]);
meshData.solidVerts.append(coord[1]);
//.........这里部分代码省略.........