示例#1
0
/** The result should be as follows: We have three times the same image, a billboard with a cube and the text in front.
They are replicated three times, one centered in the screen without viewport, one in the upper left (qurter screen) and
one on the right (half screen). The latter is stretched due to the changed aspect ratio.
The two viewport scenes get the texture drawn over the center as well, using draw2dimage. This should mark the proper
image position with the top left corner of the texture.
Finally, each scene has a checkbox drawn at the left side, vertically centered. This will show whether GUI elements adhere
to viewports as well. */
static bool viewPortText(E_DRIVER_TYPE driverType)
{
	IrrlichtDevice *device = createDevice( driverType, dimension2d<u32>(160, 120), 32);
	if (!device)
		return true; // Treat a failure to create a driver as benign; this saves a lot of #ifdefs

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

	stabilizeScreenBackground(driver);

	env->addCheckBox(true, core::recti(10,60,28,82));

	logTestString("Testing driver %ls\n", driver->getName());

	IBillboardSceneNode * bnode = smgr->addBillboardSceneNode(0,dimension2d<f32>(32,32),core::vector3df(0,0,10));
	bnode->setMaterialFlag(video::EMF_LIGHTING, false);
	bnode->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	bnode->setMaterialTexture(0, driver->getTexture("../media/fire.bmp"));

	smgr->addTextSceneNode(device->getGUIEnvironment()->getBuiltInFont(), L"TEST", video::SColor(255,255,255,255), 0);
	smgr->addCubeSceneNode();
	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

	driver->beginScene(video::ECBF_COLOR | video::ECBF_DEPTH, SColor(255,100,101,140));
	smgr->drawAll();
	env->drawAll();
	driver->setViewPort(rect<s32>(0,0,160/2,120/2));
	smgr->drawAll();
	env->drawAll();
	driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2));
	driver->setViewPort(rect<s32>(160/2,0,160,120));
	smgr->drawAll();
	env->drawAll();
	driver->draw2DImage(driver->getTexture("../media/fire.bmp"), core::vector2di(160/2,120/2));
	driver->endScene(); 

	bool result = takeScreenshotAndCompareAgainstReference(driver, "-viewPortText.png", 98.71f);

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

	return result;
}
示例#2
0
ActionManager::ActionManager(IrrlichtDevice* dev, ISceneNode* root, Craft* f, SETTINGS_STRUCT* set) 
	: device(dev), rootNode(root), SETTINGS(set) {
	//if(!scene) log << "NULL cout" << endl;
	leftShotTime = 0;
	rightShotTime = 0;
	currentTime = 0;
	gameOverTime = 0;
	currentScore = 0;
	delay = 5;
	inGame = true;
	leftPressed = false;
	rightPressed = false;

	ISceneManager* scene = device->getSceneManager();

	fighter = scene->getSceneNodeFromId(NEWGAME_ELEMENT::NEWGAME_FIGHTER);
	//fighter->setDebugDataVisible(scene::EDS_BBOX);
	craftPool.push_back(f);

	enemyRoot = scene->addEmptySceneNode(rootNode); //scene node that contains all enemy crafts

	//open sound effects
	rocketSound = OpenSoundEffect(audioDevice, "../res/sound/rocket.wav", MULTIPLE);
	rocketSound->setPan(0);       // 0 Left, 1 Right
	rocketSound->setPitchShift(1.5);

	explosionSound = OpenSoundEffect(audioDevice, "../res/sound/explosion.wav", MULTIPLE);
	explosionSound->setPan(0);       // 0 Left, 1 Right
	explosionSound->setPitchShift(2.0);

	IGUIFont* font = device->getGUIEnvironment()->getFont("button_font.xml");
	score = scene->addTextSceneNode(font, L"", SColor(100,255,255, 255), rootNode, vector3df(0,SH_SF - 20,0));
	updateScore();

	/*
	ISceneNode* sphere_1 = scene->addSphereSceneNode();
	sphere_1->setPosition(vector3df(0,0,0));

	ISceneNode* sphere_2 = scene->addSphereSceneNode();
	sphere_2->setPosition(vector3df(-10,-10,0));
	*/
	
	enemyGenerator = new EnemyGenerator(SETTINGS->gameMode, device, enemyRoot, craftPool);
}
示例#3
0
	/*!
		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);
	};