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


C++ SMesh::setHardwareMappingHint方法代码示例

本文整理汇总了C++中SMesh::setHardwareMappingHint方法的典型用法代码示例。如果您正苦于以下问题:C++ SMesh::setHardwareMappingHint方法的具体用法?C++ SMesh::setHardwareMappingHint怎么用?C++ SMesh::setHardwareMappingHint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMesh的用法示例。


在下文中一共展示了SMesh::setHardwareMappingHint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createTerrain

// Create a new tile. From 0.3+ Tiles will be parametric and will not use the reference mesh.
void TerrainTile::createTerrain(ISceneNode* parent, vector3df pos, stringc name, bool param)
{
	stringc tilename = TerrainManager::getInstance()->getTileMeshName();

	if (tilename=="")
		tilename="../media/land.obj";

	IMesh* baseMesh = NULL;

	if (!param)
	{
		baseMesh = smgr->getMesh(tilename.c_str());
	}
	else
	{

		//Tries to create a mesh that is 1024 in size (mesh size), scaled then by IRB.
		//"tilesegment" is used to determine the density of the mesh, smaller=less dense

		f32 size = TerrainManager::getInstance()->getScale();
		f32 calc = App::getInstance()->terraindensity/size;
		u32 tilesegment = (u32)(calc*size);
		if (tilesegment < 10)
            tilesegment = 10;
		//u32 tilesegment = (u32)(0.024414f*size); Old fixed density
		baseMesh = smgr->addHillPlaneMesh( "myHill",
		    core::dimension2d<f32>(f32(1024/tilesegment),f32(1024/tilesegment)),
			core::dimension2d<u32>(tilesegment,tilesegment), 0, 0,
			core::dimension2d<f32>(0,0),
			core::dimension2d<f32>(1,1));
	}

	SMesh* newMesh = NULL;

	newMesh = smgr->getMeshManipulator()->createMeshCopy(baseMesh);
	newMesh->setHardwareMappingHint(EHM_STATIC);

	if (node)
		node->drop();

	// Create the terrain mesh node
	node = smgr->addMeshSceneNode(newMesh,parent,100);
	node->setMaterialFlag(EMF_LIGHTING,false);
	//node->setMaterialFlag(EMF_WIREFRAME,true);
	// node->setMaterialFlag(EMF_BLEND_OPERATION,true);
	// Create the terrain mesh node

	//Add shadow to this in the XEffect
	if (EffectsManager::getInstance()->isXEffectsEnabled())
	{
		node->setMaterialFlag(EMF_LIGHTING,false);
		EffectsManager::getInstance()->addShadowToNode(node);
	}

	nodescale = node->getBoundingBox().getExtent().X;
	TerrainManager::getInstance()->setTileMeshSize(nodescale);
	node->setName(name);

	node->setScale(vector3df(scale/nodescale,scale/nodescale,scale/nodescale));

	node->setPosition(pos*scale);
    selector = smgr->createTriangleSelector(newMesh,node);
    node->setTriangleSelector(selector);

	assignTerrainShader(node);

	// Create the water mesh, using the same reference as the terrain, applied shader will use the vertices informations to set the transparency of the water.
	ocean=smgr->addMeshSceneNode(newMesh,node,0); // use "newMesh" as the same reference. Will use the vertices height to get the transparency for the water.
	//
	assignWaterShader(ocean);
	ocean->getMaterial(0).MaterialType = video::EMT_SOLID;
	ocean->getMaterial(0).BlendOperation = EBO_ADD;
	ocean->getMaterial(0).BlendFactor = pack_textureBlendFunc(EBF_SRC_ALPHA, EBF_ONE_MINUS_SRC_ALPHA);


	meshBuffer = ((IMeshSceneNode*)node)->getMesh()->getMeshBuffer(0);
	mb_vertices = (S3DVertex*) meshBuffer->getVertices();
	mb_indices  = meshBuffer->getIndices();

	/*
	// Reset the vertices height of the mesh to 0.0f (Y axis)
	for (unsigned int j = 0; j < meshBuffer->getVertexCount(); j += 1)
	{
	   mb_vertices[j].Pos.Y = 0.0f;
	} */

	driver = smgr->getGUIEnvironment()->getVideoDriver();

	recalculate();

	custom = false;
	storeUndo();
}
开发者ID:kcuzner,项目名称:irrrpgbuilder,代码行数:94,代码来源:TerrainTile.cpp


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