当前位置: 首页>>代码示例>>C++>>正文


C++ Heightmap类代码示例

本文整理汇总了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);
    }
}
开发者ID:trezker,项目名称:le-bomb,代码行数:32,代码来源:Client.cpp

示例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;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:26,代码来源:LandscapeEditorDrawSystem.cpp

示例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);
	}
开发者ID:jamespayor,项目名称:CubeWorld,代码行数:26,代码来源:Agent_Player.cpp

示例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);
}
开发者ID:abaradulkin,项目名称:dava.framework,代码行数:11,代码来源:LandscapePropertyControl.cpp

示例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;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:54,代码来源:SceneValidator.cpp

示例6: GetEditor

void CommandDrawHeightmap::Cancel()
{
	LandscapeEditorHeightmap* editor = GetEditor();
	if (editor)
	{
		Heightmap* heightmap;
		editor->GetHeightmap(&heightmap);

		heightmap->Load(undoFilename);
		editor->UpdateHeightmap(heightmap);
	}
}
开发者ID:dima-belsky,项目名称:dava.framework,代码行数:12,代码来源:HeightmapEditorCommands.cpp

示例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);
	}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:52,代码来源:QuadRenderData.cpp

示例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);
}
开发者ID:vilonosec,项目名称:dava.framework,代码行数:13,代码来源:LandscapeEditorHeightmap.cpp

示例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);
    }
}
开发者ID:vilonosec,项目名称:dava.framework,代码行数:15,代码来源:LandscapeEditorHeightmap.cpp

示例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();
    }
}
开发者ID:vilonosec,项目名称:dava.framework,代码行数:16,代码来源:LandscapeEditorHeightmap.cpp

示例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;
}
开发者ID:DanBrooker,项目名称:Quaffable,代码行数:7,代码来源:Heightmap.cpp

示例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;
	}
}
开发者ID:jhormanc,项目名称:TP_BetaSkeleton,代码行数:29,代码来源:Map.cpp

示例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;
}
开发者ID:DanBrooker,项目名称:Quaffable,代码行数:8,代码来源:Heightmap.cpp

示例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;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:18,代码来源:LandscapeEditorDrawSystem.cpp

示例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);
}
开发者ID:vilonosec,项目名称:dava.framework,代码行数:19,代码来源:LandscapeEditorHeightmap.cpp


注:本文中的Heightmap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。