コード例 #1
0
ファイル: MySceneManager.cpp プロジェクト: HermanYang/Scar
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
0
ファイル: main.cpp プロジェクト: silnarm/PDJ
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
0
ファイル: Stage.cpp プロジェクト: titarenko/Pathman
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
0
ファイル: Menu.cpp プロジェクト: titarenko/Pathman
	/*!
		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
0
// 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
0
ファイル: main.cpp プロジェクト: tecan/IrrlichtDemos
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
0
ファイル: main.cpp プロジェクト: tecan/IrrlichtDemos
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"Depth of Field", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMesh* mesh = smgr->getMesh("sydney.md2");

	// Create the required material. This is a simple shader which draws the texture with no lights.
	// Use GL_PLAIN1 / DX_PLANE1 or GL_PLAIN2 / DX_PLANE2 to support 1 or 2 basic point-lights
	u32 matid;
	IGPUProgrammingServices* gpu = driver->getGPUProgrammingServices( );
	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* node2 = 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 ) ) );
	node2->setMaterialFlag(EMF_LIGHTING, false);
	node2->setMaterialTexture( 0, driver->getTexture("terrain-heightmap.bmp") );
	node2->setMaterialType( (E_MATERIAL_TYPE) matid );
	node2->setPosition( vector3df( 0.0f, -22.0f, 0.0f ) );
	ICameraSceneNode* cam = smgr->addCameraSceneNode( 0, vector3df( 40.0f, 60.0f, -40.0f ), vector3df( 0.0f, 5.0f, 50.0f ) );

	IPostProc* ppRenderer = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	CEffectPostProc* ppBlurDOF = new CEffectPostProc( ppRenderer, dimension2di( 1024, 512 ), PP_BLURDOF );
	// We could set parameters on creation, but no need since we will animate it anyway.
	// Parameters are: near blur, near focus, far focus, far blur, blur level
	// You can also use PP_BLURDOFNEAR or PP_BLURDOFFAR to have only near or far blurring

	// These variables aren't important - they are just for showing the FPS
	wchar_t tmp[255]; u8 t = 0u;

	while( device->run( ) ) {
		// Change the camera angle
		cam->setTarget( vector3df( -(device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.2f, 0.0f ) );

		// Animate the depth of field:
		f32 p = sinf( device->getTimer( )->getTime( ) * 0.0005f ) * 0.5f - 0.2f;
		ppBlurDOF->setParameters( p * 100.0f + 80.0f, p * 100.0f + 110.0f, p * 100.0f + 160.0f, p * 100.0f + 240.0f, 0.01f );

		driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
		ppBlurDOF->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 ppBlurDOF;
	delete ppRenderer;

	// Back to boring stuff
	device->drop();
	return 0;
}
コード例 #8
0
ファイル: main.cpp プロジェクト: tecan/IrrlichtDemos
int main()
{
	IrrlichtDevice* device = createDevice( video::EDT_OPENGL, core::dimension2d<s32>(640, 480),
		16, false, false, false);

	if (device == 0)
		return 1;

	ISceneManager *smgr = device->getSceneManager();
	IVideoDriver *driver= device->getVideoDriver();

	IMesh* mesh = smgr->getMesh("media/cube.obj")->getMesh(0);
	mesh->getMeshBuffer(0)->getMaterial().setTexture(0, driver->getTexture("media/grass.png"));
	CBatchingMesh* BatchingMesh = new CBatchingMesh();
	s32 x,y,z;
	// let's add a grassy floor, 20x20
	for (x=-10; x<11; ++x)
		for (z=-10; z<11; ++z)
			if ( abs(x) > 5 || abs(z) > 5)
				BatchingMesh->addMesh(mesh, core::vector3df(x*2,-4,z*2));

	mesh->getMeshBuffer(0)->getMaterial().setTexture(0, driver->getTexture("media/stone.png"));
	// add some walls
	for (y=-1; y<7; ++y)
		for (x=-5; x<6; ++x)
			for (z=-5; z<6; ++z)
				if (((abs(z) == 5 || abs(x) == 5) && (abs(x)>1 || y > 3 )) || y==6)
					BatchingMesh->addMesh(mesh, core::vector3df(x*2,y*2-2,z*2));

	mesh->getMeshBuffer(0)->getMaterial().setTexture(0, driver->getTexture("media/tile.png"));
	// a nice tiled interior
	for (x=-5; x<6; ++x)
		for (z=-5; z<6; ++z)
			BatchingMesh->addMesh(mesh, core::vector3df(x*2,-4,z*2));

	BatchingMesh->update();
	BatchingMesh->setMaterialFlag(EMF_LIGHTING, false);

	ISceneNode *node = smgr->addMeshSceneNode(BatchingMesh);
	node->setScale(core::vector3df(10,10,10));
	node->setDebugDataVisible(EDS_BBOX_BUFFERS);
	BatchingMesh->drop();


	/*
	To be able to look at and move around in this scene,
	we create a first person shooter style camera and make the
	mouse cursor invisible.
	*/
	smgr->addCameraSceneNodeFPS(0, 100.0f, 0.1f);
	device->getCursorControl()->setVisible(false);


	int lastFPS = -1;

	while(device->run())
		if (device->isWindowActive())
	{
		driver->beginScene(true, true, video::SColor(255,113,113,133));
		smgr->drawAll();
		driver->endScene();

		int fps = driver->getFPS();

		if (lastFPS != fps)
		{
			core::stringw tmp(L"CBatchingMesh [");
			tmp += driver->getName();
			tmp += L"] fps: ";
			tmp += fps;
			tmp += L", mesh count: ";
			tmp += BatchingMesh->getSourceBufferCount();

			device->setWindowCaption(tmp.c_str());
			lastFPS = fps;
		}
			device->sleep(5,0);
	}

	/*
	In the end, delete the Irrlicht device.
	*/
	device->drop();

	return 0;
}
コード例 #9
0
/** 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));
	}

	driver->beginScene();
	smgr->drawAll();
	driver->endScene();

	// This screenshot shows some mipmap problems, but this seems to be
	// no fault of the mesh
	result = takeScreenshotAndCompareAgainstReference(driver, "-testTerrainMesh.png", 99.989f);

	device->closeDevice();
	device->run();
	device->drop();

	return result;
}
コード例 #10
0
/** 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;
}