本文整理汇总了C++中Heightmap类的典型用法代码示例。如果您正苦于以下问题:C++ Heightmap类的具体用法?C++ Heightmap怎么用?C++ Heightmap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Heightmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
void Client::ZCom_cbNodeRequest_Dynamic( ZCom_ConnID _id, ZCom_ClassID _requested_class, ZCom_BitStream *_announcedata, eZCom_NodeRole _role, ZCom_NodeID _net_id )
{
if (_requested_class == bomb_id)
{
printf("Client: Bomb requested\n");
float x = _announcedata->getFloat(POSITION_MANTISSA);
float y = _announcedata->getFloat(POSITION_MANTISSA);
float z = _announcedata->getFloat(POSITION_MANTISSA);
Bomb* bomb = new Bomb;
bomb->Register_net_node(this, bomb_id);
bomb->Set_position(Vector3(x, y, z));
play->Add_bomb(bomb);
}
if (_requested_class == player_id)
{
printf("Client: Player requested\n");
float x = _announcedata->getFloat(POSITION_MANTISSA);
float y = _announcedata->getFloat(POSITION_MANTISSA);
float z = _announcedata->getFloat(POSITION_MANTISSA);
Player* player = new Player;
player->Register_net_node(this, player_id);
player->Set_position(Vector3(x, y, z));
play->Add_player(player, _role==eZCom_RoleOwner);
}
if (_requested_class == heightmap_id)
{
printf("Client: Heightmap requested\n");
Heightmap* heightmap = new Heightmap;
heightmap->Register_net_node(this, heightmap_id);
play->Add_heightmap(heightmap);
}
}
示例2: HeightmapProxy
LandscapeEditorDrawSystem::eErrorType LandscapeEditorDrawSystem::Init()
{
if (!heightmapProxy)
{
Heightmap* heightmap = baseLandscape->GetHeightmap();
if (heightmap == NULL || heightmap->Size() == 0)
{
return LANDSCAPE_EDITOR_SYSTEM_HEIGHTMAP_ABSENT;
}
heightmapProxy = new HeightmapProxy(baseLandscape->GetHeightmap()->Clone(NULL));
}
if (!customColorsProxy)
{
customColorsProxy = new CustomColorsProxy((int32)GetTextureSize(Landscape::TEXTURE_TILE_FULL));
}
if (!visibilityToolProxy)
{
visibilityToolProxy = new VisibilityToolProxy((int32)GetTextureSize(Landscape::TEXTURE_TILE_FULL));
}
if (!rulerToolProxy)
{
rulerToolProxy = new RulerToolProxy((int32)GetTextureSize(Landscape::TEXTURE_TILE_FULL));
}
return LANDSCAPE_EDITOR_SYSTEM_NO_ERRORS;
}
示例3: update
// Updates a player based on user input:
void Player::update(const Heightmap& hmap, const Graphics::Camera& cam, double timestep) {
double height = hmap.getHeight(loc)+size;
vel -= vec3::Y()*0.008*timestep;
// If we can walk:
if(loc.y-walkTolerance < height) {
// Apply motion along cardinal directions if any of the keys are pressed, or else have them stand still:
if(KEY(17)||KEY(30)||KEY(31)||KEY(32)) {
vec3 snorm = hmap.getNormal(loc);
vel += cam.right().cross(snorm).norm() * (0.6*KEY(31) - KEY(17)) * 0.06*timestep;
vel += cam.ahead().cross(snorm).norm() * (KEY(32) - KEY(30)) * 0.05*timestep;
} else if(vel.abs2()<3) vel = vec3::zero();
} else if(loc.y-stillTolerance < height && vel.abs2()<3) {
vel = vec3::zero();
}
// Jetpack and gravity:
vel += cam.up()*KEY(57)*0.07*timestep - vec3::Y()*timestep*0.03;
// Resistance to motion:
vel *= pow(0.7, 0.001*timestep);
// Superclass update:
Agent::update(hmap, timestep);
}
示例4: GetLandscape
void LandscapePropertyControl::SaveHeightmapToPng(DAVA::BaseObject *object, void *userData, void *callerData)
{
LandscapeNode *landscape = GetLandscape();
if (!landscape)
return;
Heightmap * heightmap = landscape->GetHeightmap();
String heightmapPath = landscape->GetHeightmapPathname();
heightmapPath = FileSystem::ReplaceExtension(heightmapPath, ".png");
heightmap->SaveToImage(heightmapPath);
}
示例5: DVASSERT_MSG
bool SceneValidator::ValidateHeightmapPathname(const FilePath &pathForValidation, Set<String> &errorsLog)
{
DVASSERT_MSG(!pathForChecking.IsEmpty(), "Need to set pathname for DataSource folder");
bool pathIsCorrect = IsPathCorrectForProject(pathForValidation);
if(pathIsCorrect)
{
String::size_type posPng = pathForValidation.GetAbsolutePathname().find(".png");
String::size_type posHeightmap = pathForValidation.GetAbsolutePathname().find(Heightmap::FileExtension());
pathIsCorrect = ((String::npos != posPng) || (String::npos != posHeightmap));
if(!pathIsCorrect)
{
errorsLog.insert(Format("Heightmap path %s is wrong", pathForValidation.GetAbsolutePathname().c_str()));
return false;
}
Heightmap *heightmap = new Heightmap();
if(String::npos != posPng)
{
Image *image = CreateTopLevelImage(pathForValidation);
pathIsCorrect = heightmap->BuildFromImage(image);
SafeRelease(image);
}
else
{
pathIsCorrect = heightmap->Load(pathForValidation);
}
if(!pathIsCorrect)
{
SafeRelease(heightmap);
errorsLog.insert(Format("Can't load Heightmap from path %s", pathForValidation.GetAbsolutePathname().c_str()));
return false;
}
pathIsCorrect = IsPowerOf2(heightmap->Size() - 1);
if(!pathIsCorrect)
{
errorsLog.insert(Format("Heightmap %s has wrong size", pathForValidation.GetAbsolutePathname().c_str()));
}
SafeRelease(heightmap);
return pathIsCorrect;
}
else
{
errorsLog.insert(Format("Path %s is incorrect for project %s", pathForValidation.GetAbsolutePathname().c_str(), pathForChecking.GetAbsolutePathname().c_str()));
}
return pathIsCorrect;
}
示例6: GetEditor
void CommandDrawHeightmap::Cancel()
{
LandscapeEditorHeightmap* editor = GetEditor();
if (editor)
{
Heightmap* heightmap;
editor->GetHeightmap(&heightmap);
heightmap->Load(undoFilename);
editor->UpdateHeightmap(heightmap);
}
}
示例7: assert
void RenderDataManager::InitializeNode (TQuad *q)
{
assert (!q->renderData);
QuadRenderData *rd = q->renderData = Allocate ();
// Allocate vertex data space
int vertexSize = q->GetVertexSize ();
if (vertexSize != rd->vertexSize) {
int size = NUM_VERTICES * vertexSize;
if (rd->vertexBuffer.GetSize () != size)
rd->vertexBuffer.Init (size);
rd->vertexSize = vertexSize;
}
// build the vertex buffer
Vector3 *v = (Vector3*)rd->vertexBuffer.LockData ();
uint vda = q->textureSetup->vertexDataReq; // vertex data requirements
Heightmap *hm = roothm->GetLevel (q->depth); // get the right heightmap level
for(int y=q->hmPos.y;y<=q->hmPos.y+QUAD_W;y++)
for(int x=q->hmPos.x;x<=q->hmPos.x+QUAD_W;x++)
{
*(v++) = Vector3(x * hm->squareSize, hm->HeightAt (x,y), y * hm->squareSize);
Vector3 tangent, binormal;
CalculateTangents (hm, x,y, tangent, binormal);
Vector3 normal = binormal.cross(tangent);
normal.ANormalize ();
if (vda & VRT_Normal)
*(v++) = normal;
if (vda & VRT_TangentSpaceMatrix)
{
tangent.ANormalize ();
binormal.ANormalize ();
// orthonormal matrix, so inverse=transpose
// Take the inverse of the tangent space -> world space transformation
Vector3* tgs2ws = v;
tgs2ws[0] = Vector3(tangent.x, binormal.x, normal.x);
tgs2ws[1] = Vector3(tangent.y, binormal.y, normal.y);
tgs2ws[2] = Vector3(tangent.z, binormal.z, normal.z);
v+=3;
}
}
rd->vertexBuffer.UnlockData ();
rd->SetQuad(q);
}
示例8: return
float32 LandscapeEditorHeightmap::GetDropperHeight()
{
Vector3 landSize;
AABBox3 transformedBox;
workingLandscape->GetBoundingBox().GetTransformedBox(*workingLandscape->GetWorldTransformPtr(), transformedBox);
landSize = transformedBox.max - transformedBox.min;
Heightmap *heightmap = landscapesController->GetCurrentHeightmap();
int32 index = (int32)(landscapePoint.x + landscapePoint.y * heightmap->Size());
float32 height = heightmap->Data()[index];
float32 maxHeight = landSize.z;
return (height / Heightmap::MAX_VALUE * maxHeight);
}
示例9: SaveTextureAction
void LandscapeEditorHeightmap::SaveTextureAction(const String &pathToFile)
{
Heightmap *heightmap = landscapesController->GetCurrentHeightmap();
if(heightmap)
{
String heightmapPath = pathToFile;
String extension = FileSystem::Instance()->GetExtension(pathToFile);
if(Heightmap::FileExtension() != extension)
{
heightmapPath = FileSystem::Instance()->ReplaceExtension(heightmapPath, Heightmap::FileExtension());
}
savedPath = heightmapPath;
heightmap->Save(heightmapPath);
}
}
示例10: CreateHeightmapUndo
void LandscapeEditorHeightmap::TextureDidChanged(const String &forKey)
{
if("property.landscape.texture.heightmap" == forKey)
{
savedPath = workingLandscape->GetHeightmapPathname();
Heightmap *heightmap = landscapesController->GetCurrentHeightmap();
landscapeSize = heightmap->Size();
CreateHeightmapUndo();
}
else if("property.landscape.texture.tilemask" == forKey)
{
CreateTilemaskImage();
}
}
示例11:
Heightmap Heightmap::operator-=( Heightmap &other )
{
for(int j=0;j<Size;j++)
for(int i=0;i<Size;i++)
put(i,j,at(i,j)-other.at(i,j));
return *this;
}
示例12: CalcBetaSkeletonHeightmap
void Map::CalcBetaSkeletonHeightmap(float gamma, Heightmap &map) {
int size = towns.size();
bool hasATownInBetaSkeleton = false;
const float step_y = 0.1f;
int cmp = 0;
for (int a = 0; a < size; ++a)
{
for (int b = cmp; b < size; ++b)
{
if (a == b) continue;
bool hasATownInBetaSkeleton = false;
for (int p = 0; p < size; ++p)
{
if (p != a && p != b && IsInBetaSkeletonHeightmap(towns[p], towns[a], towns[b], gamma, map))
{
hasATownInBetaSkeleton = true;
}
}
if (!hasATownInBetaSkeleton)
{
waysPoints.push_back(towns[a]);
waysPoints.push_back(towns[b]);
waysCost.push_back(map.getDistance(towns[a], towns[b]));
waysEdges.push_back(Vector2d(waysPoints.size() - 2, waysPoints.size() - 1));
}
}
++cmp;
}
}
示例13: temp
Heightmap Heightmap::operator-( Heightmap &other )
{
Heightmap temp(Size);
for(int j=0;j<Size;j++)
for(int i=0;i<Size;i++)
temp.put(i,j,at(i,j)-other.at(i,j));
return temp;
}
示例14: GetHeightmapProxy
float32 LandscapeEditorDrawSystem::GetHeightAtPoint(const Vector2& point)
{
Heightmap *heightmap = GetHeightmapProxy();
int32 x = (int32)point.x;
int32 y = (int32)point.y;
DVASSERT_MSG((x >= 0 && x < heightmap->Size()) && (y >= 0 && y < heightmap->Size()),
"Point must be in heightmap coordinates");
int32 index = x + y * heightmap->Size();
float32 height = heightmap->Data()[index];
float32 maxHeight = GetLandscapeMaxHeight();
height *= maxHeight;
height /= Heightmap::MAX_VALUE;
return height;
}
示例15: Clamp
void LandscapeEditorHeightmap::UpdateHeightmap(const Rect &updatedRect)
{
Heightmap *heightmap = landscapesController->GetCurrentHeightmap();
Rect clippedRect;
clippedRect.x = (float32)Clamp((int32)updatedRect.x, 0, heightmap->Size()-1);
clippedRect.y = (float32)Clamp((int32)updatedRect.y, 0, heightmap->Size()-1);
clippedRect.dx = Clamp((updatedRect.x + updatedRect.dx), 0.f, (float32)heightmap->Size() - 1.f) - clippedRect.x;
clippedRect.dy = Clamp((updatedRect.y + updatedRect.dy), 0.f, (float32)heightmap->Size() - 1.f) - clippedRect.y;
if(heightmapNode)
{
heightmapNode->UpdateHeightmapRect(clippedRect);
}
landscapesController->HeghtWasChanged(clippedRect);
}