本文整理汇总了C++中ISceneManager::addMeshSceneNode方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::addMeshSceneNode方法的具体用法?C++ ISceneManager::addMeshSceneNode怎么用?C++ ISceneManager::addMeshSceneNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::addMeshSceneNode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addRunWaySceneNode
ISceneNode* MySceneManager::addRunWaySceneNode( const core::vector3df& position /*= core::vector3df( 0 )*/,
f32 interval /*= 200*/, f32 width /*= 300*/,
const core::vector3df& colorFrom /*= core::vector3df( 0, 63, 255 )*/, const core::vector3df& colorTo /*= core::vector3df( 255, 255, 0 )*/,
s32 numOfArrows /*= 15 */ )
{
MyIrrlichtEngine* pEngine = MyIrrlichtEngine::GetEngine();
ISceneManager* smgr = pEngine->GetSceneManager();
IVideoDriver* driver = pEngine->GetVideoDriver();
u32 TimeMs = pEngine->GetDevice()->getTimer()->getTime();
f32 delay = 100;
// 跑道根节点
ISceneNode* runWay = smgr->addEmptySceneNode();
runWay->setPosition( position );
// 供复制的节点
ISceneNode* node = smgr->addMeshSceneNode( smgr->getMesh( "../media/UnitModel/UnitPlane.obj" ), runWay );
node->setScale( vector3df( 90, 176, 1 ) );
node->setRotation( vector3df( 0, 45, 0 ) );
node->setMaterialTexture( 0, driver->getTexture( "../media/UIResource/Game/arrow.png" ) );
node->setMaterialFlag( EMF_BACK_FACE_CULLING, false );
// 节点临时变量
ISceneNode* copy;
// Shader
SceneNodeShader shader;
// 色彩偏移量
vector3df colorOffset = ( colorTo - colorFrom ) / (f32)numOfArrows;
// 右跑道
for( int i=0; i<numOfArrows; i++ )
{
copy = node->clone();
copy->setPosition( vector3df( width / 2.f, 0, interval * i ) );
RunWayBlink* ani = new RunWayBlink( (u32)(delay * i), (f32)i, colorFrom, colorOffset );
copy->addAnimator( ani );
ani->drop();
}
node->setRotation( vector3df( 0, 45, 180 ) );
// 左跑道
for( int i=0; i<numOfArrows; i++ )
{
copy = node->clone();
copy->setPosition( vector3df( -width / 2.f, 0, interval * i ) );
RunWayBlink* ani = new RunWayBlink( (u32)(delay * i), (f32)i, colorFrom, colorOffset );
copy->addAnimator( ani );
ani->drop();
}
node->setVisible( false );
return runWay;
//return CreateRunWay( position, interval, width, colorFrom, colorTo, numOfArrows );
}
示例2: spawnVehicle
ISceneNode* spawnVehicle( const pdp::VehicleDesign *design, const vector3df &pos ) {
ISceneManager* smgr = irrlicht->getSceneManager();
ISceneNode *container_node = smgr->addSceneNode( "empty" );
std::list<IAnimatedMesh*>::const_iterator it = design->chassis()->meshes().begin();
std::list<IAnimatedMesh*>::const_iterator itEnd = design->chassis()->meshes().end();
for ( ; it != itEnd; ++it) {
IAnimatedMesh* mesh = *it;
IAnimatedMeshSceneNode* mesh_node = smgr->addAnimatedMeshSceneNode( mesh, container_node );
if (mesh_node) {
mesh_node->setMaterialFlag( EMF_LIGHTING, false );
mesh_node->setAnimationSpeed( 20.0f );
mesh_node->setMaterialTexture( 0, design->chassis()->texture() );
playerChassis = mesh_node;
}
}
std::list<pdp::Component*>::const_iterator tit = design->components().begin();
for (int i=0; i < design->chassis()->attachments().size(); ++i) {
pdp::Attachment a = design->chassis()->attachments()[i];
it = (*tit)->meshes().begin();
itEnd = (*tit)->meshes().end();
for (; it != itEnd; ++it) {
IAnimatedMesh *mesh = *it;
IMeshSceneNode *turr_node = smgr->addMeshSceneNode( mesh, container_node );
if (turr_node) {
turr_node->setMaterialFlag( EMF_LIGHTING, false );
turr_node->setMaterialTexture( 0, (*tit)->texture() );
turr_node->setPosition(a.offset());
if (a.type() == "Turret") {
playerTurret = turr_node;
}
}
}
++tit;
}
return container_node;
}
示例3: createBackground
void Stage::createBackground()
{
dimension2d<u32> screenSize = _game->getDevice(
)->getVideoDriver()->getScreenSize();
dimension2d<f32> screenSizeF32 = dimension2d<f32>(
(f32) screenSize.Width, (f32) screenSize.Height);
ISceneManager* scene = _game->getDevice()->getSceneManager();
const IGeometryCreator* geometry = scene->getGeometryCreator();
SMaterial material;
material.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
dimension2d<u32> textureSize = _stageConfig.BackgroundTexture->getSize();
dimension2d<f32> textureRepeats = dimension2d<f32>(
screenSizeF32.Width/textureSize.Width,
screenSizeF32.Height/textureSize.Height);
material.setTexture(0, _stageConfig.BackgroundTexture);
scene->addMeshSceneNode(geometry->createPlaneMesh(
screenSizeF32, dimension2d<u32>(1, 1), &material, textureRepeats),
_rootNode);
}
示例4: Configuration
/*!
Constructs button as a plane node and text node with shared root node.
@param game Game instance.
@param config Configuration (texture, size, etc).
@param index Index of the button (from 0 to count - 1).
*/
Button(Game* game, const MenuConfig& config, s32 index)
{
ISceneManager* scene = game->getDevice()->getSceneManager();
Root = scene->addEmptySceneNode();
scene->addTextSceneNode(
config.Font,
config.Buttons[index].Text.c_str(),
config.FontColor,
Root)->setPosition(vector3df(0, 10, 0));
SMaterial material;
material.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
material.setTexture(0, config.ButtonTextures.Default);
Plane = scene->addMeshSceneNode(
scene->getGeometryCreator()->createPlaneMesh(
dimension2df(
(f32) config.ButtonSize.Width,
(f32) config.ButtonSize.Height),
dimension2du(1, 1), &material, dimension2df(1, 1)
), Root);
};
示例5: meshTransform
// Tests mesh transformations via mesh manipulator.
bool meshTransform(void)
{
// Use EDT_BURNINGSVIDEO since it is not dependent on (e.g.) OpenGL driver versions.
IrrlichtDevice *device = createDevice(EDT_BURNINGSVIDEO, dimension2d<u32>(160, 120), 32);
assert_log(device);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager * smgr = device->getSceneManager();
IMeshSceneNode* node1 = smgr->addCubeSceneNode(50);
IAnimatedMesh* amesh = smgr->getMesh("../media/sydney.md2");
IAnimatedMesh* smesh = smgr->getMesh("../media/ninja.b3d");
assert_log(node1 && amesh && smesh);
bool result = false;
if (!node1 || !amesh || !smesh)
return false;
// node1->setPosition(core::vector3df(-60,0,150));
node1->setDebugDataVisible(scene::EDS_BBOX_ALL);
IMeshSceneNode* node2 = smgr->addMeshSceneNode(amesh->getMesh(10));
assert_log(node2);
if (!node2)
return false;
// node2->setPosition(core::vector3df(30,10,150));
node2->setDebugDataVisible(scene::EDS_BBOX_ALL);
node2->setMaterialFlag(EMF_LIGHTING, false);
IMeshSceneNode* node3 = smgr->addMeshSceneNode(smesh->getMesh(10));
assert_log(node3);
if (!node3)
return false;
// node3->setPosition(core::vector3df(10,0,0));
node3->setDebugDataVisible(scene::EDS_BBOX_ALL);
node3->setMaterialFlag(EMF_LIGHTING, false);
smgr->addCameraSceneNode()->setPosition(core::vector3df(0,0,-20));
// Just jump to the last frame since that's all we're interested in.
device->run();
driver->beginScene(true, true, SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
core::matrix4 mat;
mat.setTranslation(core::vector3df(-60,0,150));
driver->getMeshManipulator()->transform(node1->getMesh(), mat);
mat.setTranslation(core::vector3df(30,10,150));
driver->getMeshManipulator()->transform(node2->getMesh(), mat);
mat.setTranslation(core::vector3df(10,0,0));
driver->getMeshManipulator()->transform(node3->getMesh(), mat);
// Just jump to the last frame since that's all we're interested in.
device->run();
driver->beginScene(true, true, SColor(255, 60, 60, 60));
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-meshTransform.png");
device->closeDevice();
device->run();
device->drop();
return result;
}
示例6: 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"Heat Haze (with Depth dependence)", rect<s32>( 10, 10, 260, 22 ), true );
IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");
ISceneManager* smgr2 = smgr->createNewSceneManager( false );
ISceneNode* rootnode2 = smgr2->getRootSceneNode( );
IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices( );
u32 matid, matid2;
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 );
matid2 = gpu->addHighLevelShaderMaterial( GL_V_MAT, "main", EVST_VS_1_1, GL_HEATSOURCE, "main", EPST_PS_1_1, new CTexturesShaderCallback( ), EMT_TRANSPARENT_ALPHA_CHANNEL, 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 );
matid2 = gpu->addHighLevelShaderMaterial( DX_V_MAT, "main", EVST_VS_1_1, DX_HEATSOURCE, "main", EPST_PS_2_0, new CTexturesShaderCallback( ), EMT_TRANSPARENT_ALPHA_CHANNEL, 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* node2 = smgr2->addBillboardSceneNode( rootnode2, dimension2df( 30.0f, 80.0f ), vector3df( -x * 20.0f, 30.0f, i * 40.0f ) );
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setMaterialType( EMT_TRANSPARENT_ADD_COLOR );
node2->setMaterialTexture( 0, driver->getTexture("fireball.bmp") );
node2->setMaterialType( (E_MATERIAL_TYPE) matid2 );
}
ISceneNode* nodeF = smgr->addMeshSceneNode( smgr->addHillPlaneMesh( "", dimension2df( 200.0f, 200.0f ), dimension2d<u32>( 10, 10 ), NULL, 0.0f, dimension2df( 0.0f, 0.0f ), dimension2df( 100.0f, 100.0f ) ) );
nodeF->setMaterialFlag(EMF_LIGHTING, false);
nodeF->setMaterialTexture( 0, driver->getTexture("terrain-heightmap.bmp") );
nodeF->setPosition( vector3df( 0.0f, -22.0f, 0.0f ) );
nodeF->setMaterialType( (E_MATERIAL_TYPE) matid );
ICameraSceneNode* cam1 = smgr->addCameraSceneNode( 0, vector3df( 40.0f, 60.0f, -40.0f ), vector3df( 0.0f, 5.0f, 50.0f ) );
ICameraSceneNode* cam2 = smgr2->addCameraSceneNode( rootnode2, vector3df( 40.0f, 60.0f, -40.0f ), vector3df( 0.0f, 5.0f, 50.0f ) );
IPostProc* ppRenderer1 = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
IPostProc* ppRenderer2 = new CRendererPostProc( smgr2, dimension2di( 1024, 512 ), true, true, SColor( 255u, 0u, 0u, 0u ) );
CEffectPostProc* ppHaze = new CEffectPostProc( ppRenderer1, dimension2di( 1024, 512 ), PP_HAZEDEPTH );
ppHaze->setInput( 1, ppRenderer2 );
ppHaze->setTimer( device->getTimer( ) );
// These variables aren't important - they are just for showing the FPS
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->setTarget( vector3df( -(device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.2f, 50.0f ) );
cam2->setPosition( cam1->getPosition( ) );
cam2->setTarget( cam1->getTarget( ) );
cam2->setUpVector( cam1->getUpVector( ) );
driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
ppHaze->render( NULL );
guienv->drawAll( );
driver->endScene( );
// Show the current FPS
if( ++ t == 30u ) { t = 0u; swprintf(tmp, 255, L"%ls fps:%3d", driver->getName(), driver->getFPS() ); device->setWindowCaption( tmp ); }
}
delete ppHaze;
delete ppRenderer1;
delete ppRenderer2;
// Back to boring stuff
device->drop();
return 0;
}
示例7: testGeometryCreator
/** Tests that the geometry creator does what it says it does. */
bool testGeometryCreator(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50));
const IGeometryCreator * geom = smgr->getGeometryCreator();
ITexture * wall = driver->getTexture("../media/wall.bmp");
SMaterial material;
material.Lighting = false;
material.TextureLayer[0].Texture = wall;
irr::scene::IMesh * meshHill = geom->createHillPlaneMesh(dimension2df(10, 5), dimension2du(5, 5),
&material, 10, dimension2df(2, 2), dimension2df(3, 3) );
IMeshSceneNode * node = smgr->addMeshSceneNode(meshHill, 0, -1,
vector3df(0, 10, 0), vector3df(-60, 0, 0));
meshHill->drop();
irr::scene::IMesh * meshArrow = geom->createArrowMesh(4, 8, 10, 6, 3, 6,
SColor(255, 255, 0, 0), SColor(255, 0, 255, 0));
node = smgr->addMeshSceneNode(meshArrow, 0, -1, vector3df(-10, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
meshArrow->drop();
irr::scene::IMesh * meshCone = geom->createConeMesh(5.f, 10.f, 16);
node = smgr->addMeshSceneNode(meshCone, 0, -1, vector3df(-35, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
meshCone->drop();
irr::scene::IMesh * meshCube = geom->createCubeMesh();
node = smgr->addMeshSceneNode(meshCube, 0, -1, vector3df(-20, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
meshCube->drop();
irr::scene::IMesh * meshCylinder = geom->createCylinderMesh(3, 10, 16);
node = smgr->addMeshSceneNode(meshCylinder, 0, -1, vector3df(0, -20, 10), core::vector3df(45,0,0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
meshCylinder->drop();
irr::scene::IMesh * meshSphere = geom->createSphereMesh();
node = smgr->addMeshSceneNode(meshSphere, 0, -1, vector3df(10, -15, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
meshSphere->drop();
irr::scene::IMesh * meshVolumeLight = geom->createVolumeLightMesh();
node = smgr->addMeshSceneNode(meshVolumeLight, 0, -1, vector3df(20, -20, -10));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node->setScale(core::vector3df(4.f,4.f,4.f));
meshVolumeLight->drop();
bool result = false;
device->run();
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-testGeometryCreator.png", 99.994f);
}
smgr->clear();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
// add camera
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS(0,100.0f,2.0f);
camera->setPosition(core::vector3df(2000.0f,5000.f,0.0f));
camera->setTarget(core::vector3df(0.0f,0.0f,0.0f));
camera->setFarValue(20000.0f);
device->getCursorControl()->setVisible(false); // disable mouse cursor
video::IImage* colorMapImage = driver->createImageFromFile("../media/terrain-texture.jpg");
video::IImage* heightMapImage = driver->createImageFromFile("../media/terrain-heightmap.bmp");
scene::IAnimatedMesh* terrain = smgr->addTerrainMesh("TerrainMeshName",
colorMapImage, heightMapImage,
core::dimension2d<f32>(40, 40), // size of a pixel
8*40); // maximum height
colorMapImage->drop();
colorMapImage = 0;
heightMapImage->drop();
heightMapImage = 0;
scene::IAnimatedMeshSceneNode* anode = smgr->addAnimatedMeshSceneNode(terrain);
if (anode)
{
anode->setMaterialFlag(video::EMF_LIGHTING, false);
anode->setPosition(core::vector3df(-5000,0,-5000));
//.........这里部分代码省略.........
示例8: testGeometryCreator
/** Tests that the geometry creator does what it says it does. */
bool testGeometryCreator(void)
{
IrrlichtDevice *device = createDevice(video::EDT_BURNINGSVIDEO,
core::dimension2du(160,120), 32);
if (!device)
return false;
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
(void)smgr->addCameraSceneNode(0, vector3df(0, 0, -50));
const IGeometryCreator * geom = smgr->getGeometryCreator();
ITexture * wall = driver->getTexture("../media/wall.bmp");
SMaterial material;
material.Lighting = false;
material.TextureLayer[0].Texture = wall;
IMeshSceneNode * node = smgr->addMeshSceneNode(
geom->createHillPlaneMesh(dimension2df(10, 5), dimension2du(5, 5),
&material, 10, dimension2df(2, 2), dimension2df(3, 3)), 0, -1,
vector3df(0, 10, 0), vector3df(-60, 0, 0));
node = smgr->addMeshSceneNode(geom->createArrowMesh(4, 8, 10, 6, 3, 6,
SColor(255, 255, 0, 0), SColor(255, 0, 255, 0)),
0, -1, vector3df(-10, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node = smgr->addMeshSceneNode(geom->createConeMesh(5.f, 10.f, 16), 0, -1, vector3df(-35, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createCubeMesh(), 0, -1, vector3df(-20, -20, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createCylinderMesh(3, 10, 16), 0, -1, vector3df(0, -20, 10), core::vector3df(45,0,0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createSphereMesh(), 0, -1, vector3df(10, -15, 0));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node = smgr->addMeshSceneNode(geom->createVolumeLightMesh(), 0, -1, vector3df(20, -20, -10));
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture(0, wall);
node->setScale(core::vector3df(4.f,4.f,4.f));
bool result = false;
device->run();
if (driver->beginScene(true, true, video::SColor(0, 80, 80, 80)))
{
smgr->drawAll();
driver->endScene();
result = takeScreenshotAndCompareAgainstReference(driver, "-testGeometryCreator.png", 99.999f);
}
device->drop();
return result;
}