本文整理汇总了C++中Terrain类的典型用法代码示例。如果您正苦于以下问题:C++ Terrain类的具体用法?C++ Terrain怎么用?C++ Terrain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Terrain类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Intersect
//check intersection of an axis-aligned box with the terrain
bool Intersect(const Terrain &t, const WFMath::AxisBox<3> &bbox)
{
float max, min=bbox.lowCorner()[2];
int res = t.getResolution();
//determine which segments are involved
//usually will just be one
int xlow = (int) floor(bbox.lowCorner()[0] / res);
int xhigh = (int) gridceil(bbox.highCorner()[0] / res);
int ylow = (int) floor(bbox.lowCorner()[1] / res);
int yhigh = (int) gridceil(bbox.highCorner()[1] / res);
//loop across all tiles covered by this bbox
for (int x = xlow; x < xhigh; x++) {
for (int y = ylow; y < yhigh; y++) {
//check the bbox against the extent of each tile
//as an early rejection
Segment *thisSeg=t.getSegment(x,y);
if (thisSeg)
max=thisSeg->getMax();
else
max=Terrain::defaultLevel;
if (max > min) {
//entity bbox overlaps with the extents of this tile
//now check each tile point covered by the entity bbox
//clip the points to be tested against the bbox
int min_x = (int) floor(bbox.lowCorner()[0] - (x * res));
if (min_x < 0) min_x = 0;
int max_x = (int) gridceil(bbox.highCorner()[0] - (x * res));
if (max_x > res) min_x = res;
int min_y = (int) floor(bbox.lowCorner()[1] - (y * res));
if (min_y < 0) min_y = 0;
int max_y = (int) gridceil(bbox.highCorner()[1] - (y * res));
if (max_y > res) min_y = res;
//loop over each point and see if it is greater than the minimum
//of the bbox. If all points are below, the the bbox does NOT
//intersect. If a single point is above, then the bbox MIGHT
//intersect.
for (int xpt = min_x; xpt <= max_x; xpt++) {
for (int ypt = min_y; ypt <= max_y; ypt++) {
if (thisSeg) {
if (thisSeg->get(xpt,ypt) > min) return true;
}
else if (Terrain::defaultLevel > min) return true;
}
}
}
}
}
return false;
}
开发者ID:jekin-worldforge,项目名称:mercator,代码行数:59,代码来源:Intersect.cpp
示例2: glClear
void Viewer::draw()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(backgroundCol.x(), backgroundCol.y(), backgroundCol.z(), 1.0f);
if (mySky.wantSky())
mySky.Render( );
glEnable(GL_LIGHTING);
if (applyGLSL)
{
glEnable(GL_VERTEX_PROGRAM_ARB);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
light.position[3] = 1;
light.setLight();
}
else{
light.position[3] = 0;
light.setLight();
}
QVector4D ltmp(light.position[0],light.position[1],light.position[2],light.position[3]);
ltmp.normalize();
GLfloat lpos[4] = {ltmp.x(),ltmp.y(),ltmp.z(),ltmp.w()};
glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 1, lpos);
// Draws a terrain
if (curTerr>=0 && curTerr<terrains.size()){
Terrain * terrain = terrains[curTerr];
if (applyTexture) glBindTexture( GL_TEXTURE_2D, terrain->texid );
else glBindTexture( GL_TEXTURE_2D, 0);
terrain->Draw();
//glLineWidth(10.0);
//glPointSize(10.0);
//glColor3f(1.0f,0.0f,0.0f);
for (int i=0; i<terrain->artifacts.size(); i++){
glColor3f(terrain->severity[i]/2.2f, 0.0f, 0.0f);
drawFlag(terrain->artifacts[i]);
}
}
glDisable(GL_VERTEX_PROGRAM_ARB);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
glDisable(GL_LIGHTING);
//glLineWidth(1.0);
//glPointSize(1.0);
}
开发者ID:ftasse,项目名称:TerrainNavigator,代码行数:57,代码来源:interface.cpp
示例3: getTerrainHeightData
float* SnowTerrain::getTerrainHeightData()
{
Terrain *t = mTerrainGroup->getTerrain(0,0);
// Get terrain height data using official method
float* terrainHeightData = t->getHeightData();
return terrainHeightData;
}
开发者ID:pranavsureshpn,项目名称:gpusphsim,代码行数:9,代码来源:SnowTerrain.cpp
示例4: getTerrainUnderUnit
bool Map::deleteUnit(Unit* unit)
{
Terrain* pos = getTerrainUnderUnit(unit->getID());
m_unitList.erase(unit->getID());
pos->setUnit(NULL);
delete unit;
return true;
}
开发者ID:Crumbtray,项目名称:WarGames,代码行数:9,代码来源:Map.cpp
示例5: Terrain_PatchExists_uint_uint
static duk_ret_t Terrain_PatchExists_uint_uint(duk_context* ctx)
{
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
uint patchX = (uint)duk_require_number(ctx, 0);
uint patchY = (uint)duk_require_number(ctx, 1);
bool ret = thisObj->PatchExists(patchX, patchY);
duk_push_boolean(ctx, ret);
return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:TerrainBindings.cpp
示例6: Terrain_GetPoint_uint_uint
static duk_ret_t Terrain_GetPoint_uint_uint(duk_context* ctx)
{
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
uint x = (uint)duk_require_number(ctx, 0);
uint y = (uint)duk_require_number(ctx, 1);
float ret = thisObj->GetPoint(x, y);
duk_push_number(ctx, ret);
return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:TerrainBindings.cpp
示例7: GetTerrainAtPoint
bool ParaTerrain::TerrainLattice::IsHole( float x, float y )
{
Terrain *pTerrain = GetTerrainAtPoint(x, y);
if(pTerrain!=NULL)
{
return pTerrain->IsHoleW(x,y);
}
return false;
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:9,代码来源:TerrainLattice.cpp
示例8: Terrain_SetPointHeight_uint_uint_float
static duk_ret_t Terrain_SetPointHeight_uint_uint_float(duk_context* ctx)
{
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
uint x = (uint)duk_require_number(ctx, 0);
uint y = (uint)duk_require_number(ctx, 1);
float height = (float)duk_require_number(ctx, 2);
thisObj->SetPointHeight(x, y, height);
return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:TerrainBindings.cpp
示例9: SETELEVATION
void TerrainLattice::SetVertexElevation(float x, float y, float newElevation, bool recalculate_geometry)
{
/* some vertex on border needs to be duplicated. This macro set the vertex on the given terrain tile.
* it is just to make the code easy to understand
*/
#define SETELEVATION(indexX, indexY) \
pTerrain = GetTerrain((indexX), (indexY));\
if(pTerrain && (!pTerrain->IsEmpty())){\
int nIndex = pTerrain->GetVertexW(x,y);\
pTerrain->SetVertexElevation(nIndex, newElevation,recalculate_geometry);\
pTerrain->SetModified(true, MODIFIED_HEIGHTMAP);\
}
Terrain *pTerrain = NULL;
if(x<0 || y<0)
return;
int indexX = (int)(x / m_TerrainWidth);
int indexY = (int)(y / m_TerrainHeight);
SETELEVATION(indexX, indexY);
float dX = x-indexX*m_TerrainWidth;
float dY = y-indexY*m_TerrainHeight;
float fRadius = pTerrain->GetVertexSpacing()/2;
if(dX<fRadius)
{
SETELEVATION(indexX-1, indexY);
if(dY<fRadius)
{
SETELEVATION(indexX-1, indexY-1);
}
else if(dY>m_TerrainHeight-fRadius)
{
SETELEVATION(indexX-1, indexY+1);
}
}
else if(dX>m_TerrainWidth-fRadius)
{
SETELEVATION(indexX+1, indexY);
if(dY<fRadius)
{
SETELEVATION(indexX+1, indexY-1);
}
else if(dY>m_TerrainHeight-fRadius)
{
SETELEVATION(indexX+1, indexY+1);
}
}
if(dY<fRadius)
{
SETELEVATION(indexX, indexY-1);
}
else if(dY>m_TerrainHeight-fRadius)
{
SETELEVATION(indexX, indexY+1);
}
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:57,代码来源:TerrainLattice.cpp
示例10: Terrain_MakePatchFlat_uint_uint_float
static duk_ret_t Terrain_MakePatchFlat_uint_uint_float(duk_context* ctx)
{
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
uint patchX = (uint)duk_require_number(ctx, 0);
uint patchY = (uint)duk_require_number(ctx, 1);
float heightValue = (float)duk_require_number(ctx, 2);
thisObj->MakePatchFlat(patchX, patchY, heightValue);
return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:TerrainBindings.cpp
示例11: Terrain_ShouldBeSerialized_bool_bool
static duk_ret_t Terrain_ShouldBeSerialized_bool_bool(duk_context* ctx)
{
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
bool serializeTemporary = duk_require_boolean(ctx, 0);
bool serializeLocal = duk_require_boolean(ctx, 1);
bool ret = thisObj->ShouldBeSerialized(serializeTemporary, serializeLocal);
duk_push_boolean(ctx, ret);
return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:9,代码来源:TerrainBindings.cpp
示例12: sync
void TerrainEditTool::sync(Level *level)
{
// Generate Terrain object
Terrain terrain;
for(int i = 0; i < _items.size(); i++) {
terrain.append(_items.at(i)->getPolygon());
}
level->setTerrain(terrain);
}
开发者ID:cdettmering,项目名称:fancyland-editor,代码行数:9,代码来源:TerrainEditTool.cpp
示例13: create
Terrain* Terrain::create(b2World* world,Hero* hero)
{
Terrain* terrain = new Terrain;
if (terrain && terrain->init(world,hero))
{
terrain->autorelease();
return terrain;
}
return NULL;
}
开发者ID:woodpecker-3,项目名称:bear-game,代码行数:10,代码来源:Terrain.cpp
示例14: isValidLevelMove
/*
* @param xpos and ypos: The amount in pixels to check if is valid move
*/
bool Entity::isValidLevelMove(int xpos, int ypos) {
if (xpos / 32 < 0 || ypos / 32 < 0 || xpos/32 >= MAX_TERRAINS_ROW || ypos/32 >= MAX_TERRAINS_COL) return false;
Terrain* terrain = current_level->getTerrain(xpos/32, ypos/32);
if (terrain != NULL && terrain->isWalkable() && !terrain->isWater()) return true;
return false;
}
开发者ID:anthonybjturner,项目名称:YasuosQuests,代码行数:13,代码来源:Entity.cpp
示例15: SetTerrainImage
void TilesetEditor::setTerrainImage(Tile *tile)
{
Terrain *terrain = mTerrainDock->currentTerrain();
if (!terrain)
return;
mCurrentTilesetDocument->undoStack()->push(new SetTerrainImage(mCurrentTilesetDocument,
terrain->id(),
tile->id()));
}
开发者ID:zilluss,项目名称:tiled,代码行数:10,代码来源:tileseteditor.cpp
示例16: Terrain_LoadFromImageFile_String_float_float
static duk_ret_t Terrain_LoadFromImageFile_String_float_float(duk_context* ctx)
{
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
String filename = duk_require_string(ctx, 0);
float offset = (float)duk_require_number(ctx, 1);
float scale = (float)duk_require_number(ctx, 2);
bool ret = thisObj->LoadFromImageFile(filename, offset, scale);
duk_push_boolean(ctx, ret);
return 1;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:10,代码来源:TerrainBindings.cpp
示例17: SetAllLoadedModified
void TerrainLattice::SetAllLoadedModified(bool bIsModified, DWORD dwModifiedBits)
{
bool bSaveConfigFile = false;
TerrainTileCacheMap_type::iterator itCurCP, itEndCP = m_pCachedTerrains.end();
for( itCurCP = m_pCachedTerrains.begin(); itCurCP != itEndCP; ++ itCurCP)
{
Terrain* pTerrain = (*itCurCP).second.pTerrain;
pTerrain->SetModified(bIsModified, dwModifiedBits);
}
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:10,代码来源:TerrainLattice.cpp
示例18: Terrain_SetAttribute_String_Variant_AttributeChange__Type
static duk_ret_t Terrain_SetAttribute_String_Variant_AttributeChange__Type(duk_context* ctx)
{
int numArgs = duk_get_top(ctx);
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
String id = duk_require_string(ctx, 0);
Variant value = GetVariant(ctx, 1);
AttributeChange::Type change = numArgs > 2 ? (AttributeChange::Type)(int)duk_require_number(ctx, 2) : AttributeChange::Default;
thisObj->SetAttribute(id, value, change);
return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:10,代码来源:TerrainBindings.cpp
示例19: SETDATA
void TerrainLattice::SetVertexInfo(float x,float y,uint32 data,uint32 bitMask,uint32 bitOffset)
{
#define SETDATA(idxX,idxY)\
pTerrain = GetTerrain((idxX),(idxY));\
if(pTerrain && (!pTerrain->IsEmpty())){\
int idx = pTerrain->GetVertexW(x,y);\
pTerrain->SetVertexInfo(idx,data,bitMask,bitOffset);\
}
Terrain* pTerrain = NULL;
if(x<0 || y<0)
return;
int idxX = (int)(x / m_TerrainWidth);
int idxY = (int)(y / m_TerrainHeight);
SETDATA(idxX,idxY);
float dx = x - idxX * m_TerrainWidth;
float dy = y - idxY * m_TerrainHeight;
float radius = pTerrain->GetVertexSpacing() / 2;
if(dx < radius)
{
SETDATA(idxX - 1,idxY);
if(dy < radius)
{
SETDATA(idxX-1,idxY-1);
}
else if(dy > m_TerrainHeight - radius)
{
SETDATA(idxX-1,idxY+1);
}
}
else if(dx > m_TerrainWidth - radius)
{
SETDATA(idxX+1, idxY);
if(dy<radius)
{
SETDATA(idxX+1, idxY-1);
}
else if(dy>m_TerrainHeight-radius)
{
SETDATA(idxX+1, idxY+1);
}
}
if(dy<radius)
{
SETDATA(idxX, idxY-1);
}
else if(dy>m_TerrainHeight-radius)
{
SETDATA(idxX, idxY+1);
}
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:54,代码来源:TerrainLattice.cpp
示例20: Terrain_Resize_uint_uint_uint_uint
static duk_ret_t Terrain_Resize_uint_uint_uint_uint(duk_context* ctx)
{
int numArgs = duk_get_top(ctx);
Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
uint newWidth = (uint)duk_require_number(ctx, 0);
uint newHeight = (uint)duk_require_number(ctx, 1);
uint oldPatchStartX = numArgs > 2 ? (uint)duk_require_number(ctx, 2) : 0;
uint oldPatchStartY = numArgs > 3 ? (uint)duk_require_number(ctx, 3) : 0;
thisObj->Resize(newWidth, newHeight, oldPatchStartX, oldPatchStartY);
return 0;
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:11,代码来源:TerrainBindings.cpp
注:本文中的Terrain类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论