本文整理汇总了C++中ISceneManager::addTerrainSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::addTerrainSceneNode方法的具体用法?C++ ISceneManager::addTerrainSceneNode怎么用?C++ ISceneManager::addTerrainSceneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::addTerrainSceneNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( ) {
// Boring stuff: set up the scene, object & camera as usual
// To make things more interesting, we add many Sydneys and a textured floor this time
IrrlichtDevice* device = createDevice( DRIVER, dimension2d<s32>( 640, 480 ), 16, false, false, false, 0 );
IVideoDriver* driver = device->getVideoDriver( );
ISceneManager* smgr = device->getSceneManager( );
IGUIEnvironment* guienv = device->getGUIEnvironment( );
device->getFileSystem( )->changeWorkingDirectoryTo( MEDIA_DIRECTORY );
guienv->addStaticText( L"Sandbox", rect<s32>( 10, 10, 260, 22 ), true );
IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices( );
u32 matid;
switch( driver->getDriverType( ) ) {
case EDT_OPENGL:
matid = gpu->addHighLevelShaderMaterial( GL_V_MAT, "main", EVST_VS_1_1, GL_PLAIN, "main", EPST_PS_1_1, new CTexturesShaderCallback( ), EMT_SOLID, 1 );
break;
case EDT_DIRECT3D8:
case EDT_DIRECT3D9:
default:
matid = gpu->addHighLevelShaderMaterial( DX_V_MAT, "main", EVST_VS_1_1, DX_PLAIN, "main", EPST_PS_2_0, new CTexturesShaderCallback( ), EMT_SOLID, 0 );
}
for( u8 x = 0u; x != 2u; ++ x )
for( u8 i = 0u; i != 5u; ++ i ) {
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
node->setMaterialType( (E_MATERIAL_TYPE) matid );
node->setPosition( vector3df( -x * 20.0f, 0.0f, i * 40.0f ) );
}
ISceneNode* nodeF = smgr->addTerrainSceneNode( "terrain-heightmap.bmp" );
nodeF->setMaterialFlag(EMF_LIGHTING, false);
nodeF->setMaterialTexture( 0, driver->getTexture("terrain-heightmap.bmp") );
nodeF->setPosition( vector3df( -512.0f, -50.0f, -512.0f ) );
nodeF->setScale( vector3df( 4.0f, 0.2f, 4.0f ) );
nodeF->setMaterialType( (E_MATERIAL_TYPE) matid );
ICameraSceneNode* cam1 = smgr->addCameraSceneNode( 0, vector3df( 0.0f, 0.0f, -40.0f ), vector3df( 0.0f, 5.0f, 50.0f ) );
IPostProc* ppRenderer1 = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255, 130u, 180u, 230u ) );
CWaterPostProc* ppWater = new CWaterPostProc( ppRenderer1, dimension2di( 1024, 512 ), -22.0f );
ppWater->setTimer( device->getTimer( ) );
wchar_t tmp[255];
u8 t = 0u;
while( device->run( ) ) {
// cam1->setPosition( vector3df( 40.0f, 60.0f - (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.1f, -40.0f ) );
cam1->setPosition( vector3df( (device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.1f, -40.0f ) );
// cam1->setTarget( vector3df( (device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.1f, 0.0f ) );
// cam1->setTarget( cam1->getPosition( ) + vector3df( 0.0f, 0.0f, 10.0f ) );
// cam1->setTarget( vector3df( -(device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.2f, 50.0f ) );
driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
ppWater->render( NULL );
guienv->drawAll( );
driver->endScene( );
if( ++ t == 30u ) {
t = 0u;
swprintf(tmp, 255, L"%ls fps:%3d", driver->getName(), driver->getFPS() );
device->setWindowCaption( tmp );
}
}
delete ppWater;
delete ppRenderer1;
// Back to boring stuff
device->drop();
return 0;
}
示例2: terrainSceneNode
bool terrainSceneNode(void)
{
IrrlichtDevice *device =
createDevice(video::EDT_OPENGL, dimension2di(160, 120), 32);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../media/terrain-heightmap.bmp");
terrain->setScale(core::vector3df(40.f, .1f, 40.f));
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("../media/terrain-texture.jpg"));
terrain->setDebugDataVisible(scene::EDS_FULL);
ICameraSceneNode* camera = smgr->addCameraSceneNode();
const core::vector3df center (terrain->getBoundingBox().getCenter());
camera->setTarget (center);
// yes, Y is intentionally being set to X here
const core::vector3df above (center.X, center.X, center.Z);
camera->setPosition (above);
camera->setUpVector(vector3df(1.f, 0.f, 0.f));
camera->setFarValue(above.Y);
device->run();
smgr->drawAll();
// This shouldn't cause a recalc
camera->setUpVector(vector3df(1.f, 0.f, .01f).normalize());
device->run();
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
driver->endScene();
// Note that this has to be a slightly fuzzier than usual compare to satisfy multiple OpenGL environments
bool result = takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-1.png", 98.3f);
if(!result)
{
logTestString("Small camera up rotation caused bad recalc.\n");
assert(false);
}
// This is big enough to cause a recalc
camera->setUpVector(vector3df(1.f, 0.f, .1f).normalize());
device->run();
driver->beginScene(true, true, video::SColor(255,100,101,140));
smgr->drawAll();
driver->endScene();
result &= takeScreenshotAndCompareAgainstReference(driver, "-terrainSceneNode-2.png", 98.9f);
if(!result)
{
logTestString("Large camera up rotation caused bad recalc.\n");
assert(false);
}
device->drop();
return result;
}
示例3: main
int main()
{
/* shadowDimen = dimension2du(1024,1024);
shadowDimen = dimension2du(2048,2048);
shadowDimen = dimension2du(4096,4096);
shadowDimen = dimension2du(2048,2048);
filterType = EFT_NONE;
filterType = EFT_4PCF;
filterType = EFT_8PCF;
filterType = EFT_4PCF;
*/
dimension2du shadowDimen = dimension2du(1024,1024);
E_FILTER_TYPE filterType = EFT_4PCF;
filterType = EFT_NONE;
////
IrrlichtDevice* device = createDevice(EDT_OPENGL,dimension2du(800,600),32);
ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();
ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS(0,100,.5);
cam->setPosition(vector3df(0,10,0));
// Create the effect handler, passing the device and RTT size (as a dimension2d) .
effectHandler* effect = new effectHandler(device,shadowDimen);
ITerrainSceneNode* terrain = smgr->addTerrainSceneNode("media/terrain.bmp",0,-1,vector3df(0,0,0),vector3df(0,0,0),vector3df(1,1,1),SColor(255,255,255,255),1,ETPS_33);
terrain->setMaterialTexture(0,driver->getTexture("media/terrain.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("media/detailmap.jpg"));
terrain->scaleTexture(1,10);
terrain->setScale(core::vector3df(4, 0.01f, 4));
terrain->setPosition(vector3df(-120,-1.5f,-120));
terrain->setMaterialType(EMT_DETAIL_MAP);
// Make the terrain recieve a shadow with the specified filter type.
// (NOTE: 12PCF is only available in Direct3D9, all others work with OpenGL)
effect->addShadowToNode(terrain,filterType);
IAnimatedMeshSceneNode* sydney;
IAnimatedMesh* sydneymesh = smgr->getMesh("media/dwarf.x");
for(int g = 0;g < 1;g++)
{
for(int v = 0;v < 3;v++)
{
sydney = smgr->addAnimatedMeshSceneNode(sydneymesh);
sydney->setScale(vector3df(0.05f,0.05f,0.05f));
sydney->setPosition(vector3df(g * 4,0.5f,v * 4));
sydney->setMaterialFlag(EMF_NORMALIZE_NORMALS,true);
sydney->setAutomaticCulling(EAC_FRUSTUM_BOX);
sydney->setMaterialType(EMT_SOLID);
// Add the nodes to the depth pass so that they cast a shadow.
effect->addNodeToDepthPass(sydney);
}
}
effect->getLightCamera()->addAnimator(smgr->createFlyCircleAnimator(sydney->getPosition() + vector3df(0,15,0),25,0.0002f));
effect->getLightCamera()->setNearValue(5);
effect->setMaxShadowDistanceFromLight(120);
smgr->addLightSceneNode(effect->getLightCamera());
MyEventReceiver receiver(cam);
device->setEventReceiver(&receiver);
// Parent a sphere to the light camera so we can see its position.
smgr->addSphereSceneNode(1,8,effect->getLightCamera())->setMaterialFlag(EMF_LIGHTING,false);
while(device->run())
{
wchar_t tmp[255];
swprintf(tmp,255,L"Shadow Map Demo (FPS: %d)",driver->getFPS());
device->setWindowCaption(tmp);
driver->beginScene(true,true,SColor(0,0,0,0));
// Point the light camera at one of the nodes as it rotates around them.
effect->setLightTarget(sydney->getPosition());
// Update the effect handler, remember to always do this BEFORE smgr->drawAll and AFTER beginscene!
effect->update();
smgr->drawAll();
// If user wishes we can display the shadow map to the screen. (May not work in OpenGL)
//.........这里部分代码省略.........