Ejemplo n.º 1
0
void updateToolBox()
{
	IGUIEnvironment* env = Device->getGUIEnvironment();
	IGUIElement* root = env->getRootGUIElement();
	IGUIElement* dlg = root->getElementFromId(GUI_ID_DIALOG_ROOT_WINDOW, true);
	if (!dlg )
		return;

	// update the info we have about the animation of the model
	IGUIStaticText *  aniInfo = (IGUIStaticText *)(dlg->getElementFromId(GUI_ID_ANIMATION_INFO, true));
	if (aniInfo)
	{
		if ( Model && scene::ESNT_ANIMATED_MESH == Model->getType() )
		{
			scene::IAnimatedMeshSceneNode* animatedModel = (scene::IAnimatedMeshSceneNode*)Model;

			core::stringw str( (s32)core::round_(animatedModel->getAnimationSpeed()) );
			str += L" Frame: ";
			str += core::stringw((s32)animatedModel->getFrameNr());
			aniInfo->setText(str.c_str());
		}
		else
			aniInfo->setText(L"");
	}
}
Ejemplo n.º 2
0
void IrrlichtWidget::buildIrrlichtScene(){
    scene::ISceneManager* manager = mDevice->getSceneManager();
    mDevice->setWindowCaption(L"Hello World!");

    scene::IAnimatedMesh* mesh = manager->getMesh("./media/sydney.md2");
    if(mesh == NULL){
        return;
    }
    scene::IAnimatedMeshSceneNode* node = manager->addAnimatedMeshSceneNode(mesh);
    if(node !=NULL){
        node->setMaterialFlag(EMF_LIGHTING, false);
        node->setMD2Animation(scene::EMAT_STAND);
        node->setMaterialTexture(0, mDriver->getTexture("./media/sydney.bmp"));
    }
    manager->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

    IGUIEnvironment* guienv = mDevice->getGUIEnvironment();
    gui::IGUIListBox* box = guienv->addListBox(core::rect<int>(10,10,220,120));
    box->addItem(L"OpenGL 1.5");
    box->addItem(L"Direct3D 8.1");
    box->addItem(L"Direct3D 9.0c");
    box->addItem(L"Burning's Video 0.47");
    box->addItem(L"Irrlicht Software Renderer 1.0");
    box->setSelected(true);


    m_pTimer = new QTimer(this);
    connect(m_pTimer, SIGNAL(timeout()), this, SLOT(drawIrrlichtScene()));
    m_pTimer->start(5);

}
Ejemplo n.º 3
0
    //-----------------------------------------------------------------------
    //                              a d d I t e m
    //-----------------------------------------------------------------------
    u32 TTextOverlay::addItem(const TString& text,TTextAlignment a, TColor color,
        TColor bgColor)
    {

        s32 offset = 0;
        int idx;
        IGUIEnvironment* mgr = getApplication()->getGUIManager();
        IGUIFont* font=m_panel->getOverrideFont();
        if(!font)
            font = mgr->getSkin()->getFont();

        TRecti apos = m_panel->getAbsolutePosition();

        idx = (int)m_textItems.size();
        TStrStream name;		
        name << m_name.c_str() << "-item" << idx+1;

        TStringW wstr = text.c_str();

        s32 cheight = font->getDimension(L"Ay").Height;
        cheight += font->getKerningHeight();

        TRecti tdim(0,0,apos.getWidth(),cheight);
        
        TTextElement* textArea = mgr->addStaticText(wstr.c_str(),tdim,false,false,m_panel);
        textArea->move(position2di(0,cheight*idx));
        textArea->setOverrideFont(font);
        textArea->setOverrideColor(color);
        textArea->setBackgroundColor(bgColor);

        offset = idx * (cheight);
        s32 theight = ((idx+1) * cheight) + (m_margins.Height * 2);

        EGUI_ALIGNMENT oa=EGUIA_UPPERLEFT;

        switch(a)
        {
        case taLeft:
            oa = EGUIA_UPPERLEFT;
            break;
        case taCenter:
            oa = EGUIA_CENTER;
            break;
        case taRight:
            oa = EGUIA_LOWERRIGHT;
            break;
        };

        textArea->setTextAlignment(oa,EGUIA_UPPERLEFT);

        m_panel->addChild(textArea);
        m_textItems.push_back(textArea);

        if(apos.getHeight() < theight)     
        {
            m_panel->setMinSize(TDimensionu(0,theight));
        }

        return m_textItems.size()-1;
    }
 */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetCheckBoxesSelection(
		JNIEnv* env, jclass clazz, jint handle, jint idx) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element) {
			IGUIWindow* window = (IGUIWindow*) (element);
			core::list<IGUIElement*> children = window->getChildren();
			core::list<IGUIElement*>::Iterator current = children.begin();
			int i = 0;
			do {
				if ((*current)->getType() == EGUIET_CHECK_BOX && i++ == idx) {
					break;
				}
				current++;
			} while (current != children.end());
			if (current == children.end()) {
				return;
			}
			IGUICheckBox* checkbox = (IGUICheckBox*) *current;
			checkbox->setChecked(true);
			SEvent e;
			e.EventType = EET_GUI_EVENT;
			e.GUIEvent.Caller = checkbox;
			e.GUIEvent.Element = 0;
			e.GUIEvent.EventType = EGET_CHECKBOX_CHANGED;
			window->OnEvent(e);
			irrenv->setFocus(window);
		}
	}
}
 */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeSetComboBoxSelection(
		JNIEnv* env, jclass clazz, jint handle, jint idx) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element && element->getParent()->getType() == EGUIET_COMBO_BOX) {
			IGUIComboBox* combo = (IGUIComboBox*) (element->getParent());
			core::list<IGUIElement*> children = combo->getChildren();
			core::list<IGUIElement*>::Iterator current = children.begin();
			do {
				if ((*current)->getType() == EGUIET_LIST_BOX) {
					break;
				}
				current++;
			} while (current != children.end());
			if (current == children.end()) {
				return;
			}
			IGUIListBox* list = (IGUIListBox*) *current;
			list->setSelected(idx);
			SEvent changeEvent;
			changeEvent.EventType = EET_GUI_EVENT;
			changeEvent.GUIEvent.Caller = list;
			changeEvent.GUIEvent.Element = 0;
			changeEvent.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
			combo->OnEvent(changeEvent);
		}
	}
}
Ejemplo n.º 6
0
void EsqMenuDialog::Init()
{
	if( Visible )
		return;

	GameGlobal* global = GameGlobal::Instance();

	double SizeX = 0.2, SizeY = 0.3;
	int sWidth = global->cfg->GetCfg()->Width,
		sHeight = global->cfg->GetCfg()->Height;

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


	wnd = env->addWindow(CenterRect(SizeX, SizeY, sWidth, sHeight ),true,L"Меню игры");
	wnd->getCloseButton()->setVisible( false );

	int wndSizeX = sWidth*SizeX,
		  wndSizeY = sHeight *SizeY;

	
	resume = env->addButton(ItemRect(0.5,0.2, 0.9, 0.2, wndSizeX, wndSizeY ), wnd, start_id+btn_resume_esqmenu, L"Продолжить");
	leave = env->addButton(ItemRect(0.5,0.6, 0.9, 0.2, wndSizeX, wndSizeY ), wnd, start_id+btn_leave_esqmenu, L"Покинуть");
	quit = env->addButton(ItemRect(0.5,0.8, 0.9, 0.2, wndSizeX, wndSizeY ), wnd, start_id+btn_quit_esqmenu, L"Выход из игры");

	Visible = true;
}
 */JNIEXPORT void JNICALL Java_cn_garymb_ygomobile_core_IrrlichtBridge_nativeInsertText(
		JNIEnv* env, jclass clazz, jint handle, jstring textString) {
	if (handle) {
		IrrlichtDevice* device = (IrrlichtDevice*) handle;
		IGUIEnvironment* irrenv = device->getGUIEnvironment();
		IGUIElement* element = irrenv->getFocus();
		if (element && element->getType() == EGUIET_EDIT_BOX) {
			IGUIEditBox* editbox = (IGUIEditBox*) element;
			const char* text = env->GetStringUTFChars(textString, NULL);
			wchar_t content[256];
			BufferIO::DecodeUTF8(text, content);
			editbox->setText(content);
			irrenv->removeFocus(editbox);
			irrenv->setFocus(editbox->getParent());
			SEvent changeEvent;
			changeEvent.EventType = EET_GUI_EVENT;
			changeEvent.GUIEvent.Caller = editbox;
			changeEvent.GUIEvent.Element = 0;
			changeEvent.GUIEvent.EventType = EGET_EDITBOX_CHANGED;
			editbox->getParent()->OnEvent(changeEvent);
			SEvent enterEvent;
			enterEvent.EventType = EET_GUI_EVENT;
			enterEvent.GUIEvent.Caller = editbox;
			enterEvent.GUIEvent.Element = 0;
			enterEvent.GUIEvent.EventType = EGET_EDITBOX_ENTER;
			editbox->getParent()->OnEvent(enterEvent);
			env->DeleteLocalRef(textString);
		}
	}
}
Ejemplo n.º 8
0
int main(int argc, char** argv) {
  IrrlichtDevice *device=createDevice(EDT_OPENGL,dimension2d<s32>(1024,600),16,false,false,false,0);

  device->setWindowCaption(L"FollowPathAnimator");

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

  smgr->loadScene("data/irrOdeMarble_level_.xml");
  ICameraSceneNode *pCam=smgr->addCameraSceneNode(NULL,vector3df(0.0f,0.0f,0.0f),vector3df(1.0f,0.0f,0.0f));

  CFollowPathAnimator *myAnimator=new CFollowPathAnimator(device,"pathToFollow",120,500);
  pCam->addAnimator(myAnimator);
  myAnimator->setCamParameter(pCam);

  while(device->run()) {
    driver->beginScene(true, true, SColor(0,200,200,200));

    smgr->drawAll();
    guienv->drawAll();

    driver->endScene();
  }

  device->drop();
  return 0;
}
Ejemplo n.º 9
0
int main()
{
    // we'll use the OGL driver
	IrrlichtDevice *device =
		createDevice(EDT_OPENGL, dimension2du(640, 480), 16,
			false, false, false, 0);

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

    // load sydney
	IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
    // squash her!
	CSquashingMeshSceneNode* node = new CSquashingMeshSceneNode( mesh->getMesh(0), 0, smgr, 0 );


	if (node)
	{
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setPosition( vector3df(0,0,50));
		node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
	}

	smgr->addCameraSceneNodeFPS();

    int lastFPS = -1;

	while(device->run())
	{
		driver->beginScene(true, true, SColor(255,100,101,140));

        node->render();
        node->OnPostRender(device->getTimer()->getTime());

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();

		int fps = driver->getFPS();
		if (lastFPS != fps)
		{
			core::stringw str = L"Irrlicht Mesh Deformation Contest [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}


	}

	device->drop();

	return 0;
}
Ejemplo n.º 10
0
int main()
{
	int rows = 10, colums = 10;
	printf("Number of stack rows: ");
	cin >> rows;
	printf("\nNumber of stack colums: ");
	cin >> colums;
	CReceiver receiver;
	IrrlichtDevice *device = createDevice(EDT_DIRECT3D9, dimension2d<u32>(640, 480), 16, false, false, false, &receiver);
	IVideoDriver *driver = device->getVideoDriver();
	ISceneManager *smgr = device->getSceneManager();
	IGUIEnvironment *guienv = device->getGUIEnvironment();
	device->setWindowCaption(L"HelloWorld");
	irrBulletWorld * world = createIrrBulletWorld(device, true, true);
	world->setDebugMode(EPDM_DrawAabb | EPDM_DrawContactPoints);
	world->setGravity(core::vector3df(0, -10, 0));
	createWorld(rows, colums, device, world);
	scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
	camera->setPosition(core::vector3df(50, 15, 200));
	u32 then = device->getTimer()->getTime();
	while (device->run())
	{
		const u32 now = device->getTimer()->getTime();
		const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // в секундах
		then = now;
		if (receiver.isMouseDown(EMIE_RMOUSE_PRESSED_DOWN))
		{
			core::vector3df pos(camera->getPosition().X, camera->getPosition().Y, camera->getPosition().Z);
			scene::ISceneNode *Node = smgr->addCubeSceneNode();
			Node->setScale(core::vector3df(0.2, 0.2, 0.2));
			Node->setPosition(pos);
			Node->setMaterialFlag(video::EMF_LIGHTING, false);
			Node->setMaterialTexture(0, driver->getTexture("../rockwall.jpg"));
			ICollisionShape *shape = new IBoxShape(Node, 1, true);
			IRigidBody *body = world->addRigidBody(shape);
			body->setDamping(0.2, 0.2);
			body->setFriction(0.4f);
			body->setGravity(core::vector3df(0, -10, 0));
			core::vector3df rot = camera->getRotation();
			core::matrix4 mat;
			mat.setRotationDegrees(rot);
			core::vector3df forwardDir(core::vector3df(mat[8], mat[9], mat[10]) * 120);
			body->setLinearVelocity(forwardDir);
		}

		driver->beginScene(true, true, video::SColor(255, 100, 101, 140));
		world->stepSimulation(frameDeltaTime, 120);
		world->debugDrawWorld(true);
		world->debugDrawProperties(true);
		smgr->drawAll();
		guienv->drawAll();
		driver->endScene();

		if (world) delete world;
		device->drop();
		return 0;
	}
}
Ejemplo n.º 11
0
	void GUIChat::Load() {
		IGUIEnvironment* env = mainGame->env;
		wChat = env->addWindow(rect<s32>(305, 615, 1020, 640), false, L"");
		wChat->getCloseButton()->setVisible(false);
		wChat->setDraggable(false);
		wChat->setDrawTitlebar(false);
		wChat->setVisible(false);
		ebChatInput = env->addEditBox(L"", rect<s32>(3, 2, 710, 22), true, wChat, EDITBOX_CHAT);
	}
Ejemplo n.º 12
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Lens Flare", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node2->setMaterialFlag( EMF_LIGHTING, false );
	node2->setMD2Animation( scene::EMAT_STAND );
	node2->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	node2->setPosition( vector3df( 20.0f, 0.0f, 0.0f ) );
	ICameraSceneNode* cam = smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );

	ISceneNode* sun = smgr->addSphereSceneNode( 50.0f, 16 );
	sun->setPosition( vector3df( 0.0f, 50.0f, 1000.0f ) );
	sun->setMaterialFlag( EMF_LIGHTING, false );
	sun->setMaterialTexture( 0, driver->getTexture("sun.png") );
	// Interesting stuff

	// As before, we make a renderer
	IPostProc* ppRenderer = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	// Now make a flare effect:
	// (render from, output size, sun scene node)
	// can also use a vector instead of a scene node - when using a scene node the position will follow node automatically
	CLensFlarePostProc* ppFlare1 = new CLensFlarePostProc( ppRenderer, dimension2di( 1024, 512 ), driver->getTexture("flare.png"), sun, 50.0f );
	CLensFlarePostProc* ppFlare2 = new CLensFlarePostProc( ppFlare1, dimension2di( 1024, 512 ), driver->getTexture("flare.png"), vector3df( -2000.0f, 50.0f, 1000.0f ) );
	ppFlare2->setQuality( PPQ_CRUDE ); // Setting the quality to crude avoids pixel checking, which is slow (expecially when more than one lens flare), so if you use >1 flare, set most of them to crude.

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

	while( device->run( ) ) {
		cam->setPosition( vector3df( -(device->getCursorControl( )->getPosition( ).X - 320.0f) * 0.1f, (device->getCursorControl( )->getPosition( ).Y - 240.0f) * 0.2f, -70.0f ) );
		driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
		ppFlare2->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 ppFlare1;
	delete ppFlare2;
	delete ppRenderer;

	// Back to boring stuff
	device->drop();
	return 0;
}
Ejemplo n.º 13
0
/*
Function hasModalDialog() checks if we currently have a modal dialog open.
*/
bool hasModalDialog()
{
	IGUIEnvironment* env = Device->getGUIEnvironment();
	IGUIElement * focused = env->getFocus();
	while ( focused )
	{
		if ( focused->isVisible() && focused->hasType(EGUIET_MODAL_SCREEN) )
			return true;
		focused = focused->getParent();
	}
	return false;
}
Ejemplo n.º 14
0
bool
ProcTitle::OnExit(irr::IrrlichtDevice& device)
{	
	IGUIEnvironment* env = device.getGUIEnvironment();
	env->clear();

	// should I need to clear all texture here? 
	IVideoDriver* pDriver = IrrDvc.GetDriver();
	pDriver->removeAllTextures();

	return true;
}
Ejemplo n.º 15
0
bool viewprt::checkForWindow(s32 element, s32 x, s32 y)
{
   IGUIEnvironment* env = device->getGUIEnvironment();
   IGUIElement* root = env->getRootGUIElement();
   IGUIElement* e = root->getElementFromId(element, true);
   if (e) {
            core::rect< s32 > infos;
            infos=e->getAbsolutePosition();
            return infos.isPointInside(position2d<s32>(x,y));
      }
   return false;
}
Ejemplo n.º 16
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Multiple Renders", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );

	// Interesting stuff
	// This time, we make 2 renderers for the same scene
	IPostProc* ppRenderer1 = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	IPostProc* ppRenderer2 = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	CEffectPostProc* ppBlur = new CEffectPostProc( ppRenderer2, dimension2di( 1024, 512 ), PP_BLUR, 0.005f );
	CEffectPostProc* ppOverlay = new CEffectPostProc( ppRenderer1, dimension2di( 1024, 512 ), PP_OVERLAY, 1.0f );
	ppOverlay->setInput( 1, ppBlur );

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

	while( device->run( ) ) {
		driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );

		// Because we want to have each scene render differently, we need to render them manually between changes:
		node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
		ppRenderer1->preRender( ); // Note: preRender not render, and no NULL

		node->setMaterialTexture( 0, driver->getTexture("fireball.bmp") );
		// We could call ppRender2->preRender() here, but it isn't necessary since the overlay will do that for us anyway
		ppOverlay->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 ppOverlay;
	delete ppBlur;
	delete ppRenderer1;
	delete ppRenderer2;

	// Back to boring stuff
	device->drop();
	return 0;
}
Ejemplo n.º 17
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Mixing Scenes", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );
	// Set up the second scene, object & camera - this time, use a different texture and camera angle to show some change
	ISceneManager* smgr2 = smgr->createNewSceneManager( false );
	ISceneNode* rootnode2 = smgr2->getRootSceneNode( );
	IAnimatedMeshSceneNode* node2 = smgr2->addAnimatedMeshSceneNode( smgr2->getMesh( "sydney.md2" ), rootnode2 );
	node2->setMaterialFlag( EMF_LIGHTING, false );
	node2->setMD2Animation( scene::EMAT_STAND );
	node2->setMaterialTexture( 0, driver->getTexture("fireball.bmp") );
	smgr2->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 10.0f, 5.0f, 0.0f ) );

	// Interesting stuff (see previous example for full details)
	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 ) );
	// PP_OVERLAY takes a multiplication parameter - setting this to 1.0 does a simple add, 2.0 doubles the second texture's luminosity, etc.
	CEffectPostProc* ppOverlay = new CEffectPostProc( ppRenderer1, dimension2di( 1024, 512 ), PP_OVERLAY, 2.0f );
	// The constructor can only take 1 input, but PP_OVERLAY needs 2, so set the other one now;
	ppOverlay->setInput( 1, ppRenderer2 );

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

	while( device->run( ) ) {
		driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
		// We only need to tell the final node to render - it will automatically render both scenes
		ppOverlay->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 ppRenderer1;
	delete ppRenderer2;
	delete ppOverlay;

	// Back to boring stuff
	device->drop();
	return 0;
}
Ejemplo n.º 18
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Custom Effect (Old Monitor)", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );

	// Interesting stuff

	IPostProc* ppRenderer = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	CEffectPostProc* ppMine = new CEffectPostProc( ppRenderer, dimension2di( 1024, 512 ), GL_OLDMONITOR, DX_OLDMONITOR, EPST_PS_1_2, EPST_PS_2_0, EMT_SOLID, PPF_FROMCODE, 1.0f );
	// Notes:
	//	EPST_PS_1_2	shows the minimum version required to run your shader - usually EPST_PS_1_1 for simple things
	//	EMT_SOLID	can be changed to EMT_TRANSPARENT_ALPHA_CHANNEL, EMT_TRANSPARENT_ALPHA_CHANNEL_REF, etc. If this is done, the first texture is copied to the screen, then the second drawn on top using your shader. This is much faster than using 2 dynamic textures in one shader (not sure why) so use it when you can if you have 2 inputs
	//	1.0f		is where your parameters go
	// Remember to use setTimer if your effect uses the time variable:
	ppMine->setTimer( device->getTimer( ) );
	// I hate this next line, but it needs to be set correctly to prevent MAJOR slowdown in Irrlicht when running in Direct3D mode.
	// (if not called, your shader will have all parameters set to 0. If called with values too high, your app will slow significantly)
	// Note: this is ONLY needed with custom shaders
	ppMine->setRequiredVariables( 1, true, true ); // (number of input parameters, uses time?, uses randNum?)

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

	while( device->run( ) ) {
		// The monitor effect needs to know how strong it should be
		ppMine->setParameters( min_( 1.0f, device->getTimer( )->getTime( ) * 0.0002f ) );

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

	// Back to boring stuff
	device->drop();
	return 0;
}
Ejemplo n.º 19
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Transitions", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );
	// Set up the second scene, object & camera - this time, use a different texture and camera angle to show some change
	ISceneManager* smgr2 = smgr->createNewSceneManager( false );
	ISceneNode* rootnode2 = smgr2->getRootSceneNode( );
	IAnimatedMeshSceneNode* node2 = smgr2->addAnimatedMeshSceneNode( smgr2->getMesh( "sydney.md2" ), rootnode2 );
	node2->setMaterialFlag( EMF_LIGHTING, false );
	node2->setMD2Animation( scene::EMAT_STAND );
	node2->setMaterialTexture( 0, driver->getTexture("fireball.bmp") );
	smgr2->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 10.0f, 5.0f, 0.0f ) );

	// Interesting stuff
	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 ) );
	CTransitionPostProc* ppTransition = new CTransitionPostProc( ppRenderer1, ppRenderer2, dimension2di( 1024, 512 ), driver->getTexture("terrain-heightmap.bmp") );
//	ppTransition->setQuality( PPQ_CRUDE );

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

	while( device->run( ) ) {
		ppTransition->setBlend( sinf( device->getTimer( )->getTime( ) * 0.0005f - 2.0f ) * 2.0f + 0.5f );

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

	// Back to boring stuff
	device->drop();
	return 0;
}
Ejemplo n.º 20
0
void StateNetwork::Init()
{
	//일단 GUI부터 그리고 그다음에 초기화 하면서 넘어간다!!
	IVideoDriver* pDriver = Irrdevice::GetInstance()->GetVideoDriver();
	IGUIEnvironment* env  = Irrdevice::GetInstance()->GetGUIEnvironment();
	IGUISkin	   * skin = env->getSkin();

	IGUIFont* font = env->getFont("media/fonthaettenschweiler.bmp");
	if(font)
		skin->setFont(font);

	skin->setFont(env->getBuiltInFont(),EGDF_TOOLTIP);

	env->addButton(rect<s32>(10,240,110,240 + 32), 0, GUI_ID_SERVER_BUTTON,
		L"SERVER", L"HELL SERVER");
	env->addButton(rect<s32>(10,280,110,280 + 32), 0, GUI_ID_CLIENT_BUTTON,
		L"CLIENT", L"HELL CLIENT");

	m_pConnectButton = env->addButton(rect<s32>(500,280,610,280 + 32), 0, GUI_ID_CONNECT_BUTTON,
		L"CONNECT", NULL);
	m_pConnectButton ->setVisible(false);
	m_pServerIpBox = env->addEditBox(L"192.168.0.3",rect<s32>(200,280,480,280 + 32),true,0,GUI_ID_TEXT_BOX);
	m_pServerIpBox->setVisible(false);

	m_bSelectState = false;

	//배경화면

	m_pBackGround = pDriver->getTexture("media/network.jpg");

	

}
Ejemplo n.º 21
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Single Effect", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );

	// Interesting stuff

	// We make 2 objects - a scene renderer, and a blur. both render to textures with size 1024x512 (always use powers of 2)
	// When setting up the renderer, the parameters are:
	// SceneManager to render, size of output, clearBackBuffer?, clearZBuffer?, background colour
	IPostProc* ppRenderer = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	// When setting up the effect, the parameters are:
	// Input, size of output, effect ID (see CEffectPostProc.h for full list), effect parameters (in this case, blur size)
	CEffectPostProc* ppBlur = new CEffectPostProc( ppRenderer, dimension2di( 1024, 512 ), PP_BLUR, 0.01f );
	// Change to a better quality - not all shaders will respect these, but they can be used to hint the rendering standard required.
	ppBlur->setQuality( PPQ_GOOD );
	// Options (worst to best): PPQ_CRUDE, PPQ_FAST, PPQ_DEFAULT, PPQ_GOOD, PPQ_BEST
	// You can also call setOverallQuality( PPQ_WHATEVER ) to change the quality of all effects which are in the chain.

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

	while( device->run( ) ) {
		// What's happened to beginScene? well we want to use beginScene( false, false ) for speed, but this makes Irrlicht complain (wrongly) when using Direct3D9, so use ( false, true ) in that case.
		driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
		// The rendering is as normal, except smgr->drawAll(); is replaced with this line:
		ppBlur->render( NULL ); // NULL = render to screen. Can also take a texture to render to, or no parameter (renders to an internal texture)
		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 ppBlur;
	delete ppRenderer;

	// Back to boring stuff
	device->drop();
	return 0;
}
Ejemplo n.º 22
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Splitscreen", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );
	// Set up the second scene, object & camera - this time, use a different texture and camera angle to show some change
	ISceneManager* smgr2 = smgr->createNewSceneManager( false );
	ISceneNode* rootnode2 = smgr2->getRootSceneNode( );
	IAnimatedMeshSceneNode* node2 = smgr2->addAnimatedMeshSceneNode( smgr2->getMesh( "sydney.md2" ), rootnode2 );
	node2->setMaterialFlag( EMF_LIGHTING, false );
	node2->setMD2Animation( scene::EMAT_STAND );
	node2->setMaterialTexture( 0, driver->getTexture("fireball.bmp") );
	smgr2->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 10.0f, 5.0f, 0.0f ) );

	// Interesting stuff
	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 ) );
	// Splitscreen objects can be given up to 4 views. The rects at the end are optional - if not given, an arrangement will be created to fit the given number of views
	CSplitPostProc* ppSplit = new CSplitPostProc( ppRenderer1, ppRenderer2, dimension2di( 1024, 512 ), rect<f32>( -0.5f, -1.0f, 0.5f, 0.0f ), rect<f32>( -0.7f, 0.0f, 0.3f, 1.0f ) );
	ppSplit->setVoidColor( SColor( 255u, 128u, 128u, 128u ) ); // Change the colour shown where there are no views. Call setVoidColor() to use no color (slightly faster, but should only be used if the views entirely cover the screen)

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

	while( device->run( ) ) {
		driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
		ppSplit->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 ppRenderer1;
	delete ppSplit;
	delete ppRenderer2;

	// Back to boring stuff
	device->drop();
	return 0;
}
Ejemplo n.º 23
0
/**
 * Irrlicht描画処理
 * @param destRect 描画先領域
 * @param srcRect 描画元領域
 * @param destDC 描画先DC
 * @return 描画された
 */
bool
IrrlichtBase::show(irr::core::rect<irr::s32> *destRect, irr::core::rect<irr::s32> *srcRect, HDC destDC)
{
	if (device) {
		// 時間を進める XXX tick を外部から与えられないか?
		device->getTimer()->tick();
		
		IVideoDriver *driver = device->getVideoDriver();
		// 描画開始
		if (driver && driver->beginScene(true, true, irr::video::SColor(0,0,0,0))) {
			
			if ((eventMask & EMASK_BEFORE_SCENE)) {
				sendTJSEvent(L"onBeforeScene");
			}
			
			/// シーンマネージャの描画
			ISceneManager *smgr = device->getSceneManager();
			if (smgr) {
				smgr->drawAll();
			}

			if ((eventMask & EMASK_AFTER_SCENE)) {
				sendTJSEvent(L"onAfterScene");
			}
			
			// 固有処理
			update(driver);

			if ((eventMask & EMASK_BEFORE_GUI)) {
				sendTJSEvent(L"onBeforeGUI");
			}
			
			// GUIの描画
			IGUIEnvironment *gui = device->getGUIEnvironment();
			if (gui) {
				gui->drawAll();
			}

			if ((eventMask & EMASK_AFTER_GUI)) {
				sendTJSEvent(L"onAfterGUI");
			}
			
			// 描画完了
			driver->endScene(0, srcRect, destRect, destDC);
			return true;
		}
	}
	return false;
};
Ejemplo n.º 24
0
VectorEditElement::VectorEditElement(gui::IGUIElement* parent, int x, int y, const vector3df& vector): target(vector)
{
	
	IGUIEnvironment* env = EditorEnvironment::getInstance()->getGUI();
	
	int editBoxWidth = 70;
	
	int pos = x;
	env->addSpinBox( core::stringw(vector.X).c_str() , core::rect<s32>(pos,y,pos+editBoxWidth,y+getHeight()),true, parent);
	pos += editBoxWidth+5;
	env->addSpinBox( core::stringw(vector.Y).c_str() , core::rect<s32>(pos,y,pos+editBoxWidth,y+getHeight()),true, parent);
	pos += editBoxWidth+5;
	env->addSpinBox( core::stringw(vector.Z).c_str() , core::rect<s32>(pos,y,pos+editBoxWidth,y+getHeight()),true, parent);

}
Ejemplo n.º 25
0
int main()
{
    IrrlichtDevice *device =
            createDevice( video::EDT_BURNINGSVIDEO, dimension2d<u32>(640, 480), 16,
                    false, false, false, 0);
    if (!device)    return 1;

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

// Add Light to the Scene
    ILightSceneNode *light = smgr->addLightSceneNode( 0, vector3df() );
    light->getLightData().AmbientColor = SColorf( 0.2f, 0.2f, 0.2f );
    light->getLightData().SpecularColor = SColorf( 1.0f, 1.0f, 1.0f );
    light->getLightData().DiffuseColor = SColorf( 0.8f, 0.8f, 0.8f );
    light->setLightType( ELT_DIRECTIONAL );
    light->setRotation( vector3df( 45.0f, 45.0f, 0.0f ));
    smgr->setAmbientLight( SColorf( 0.2f, 0.2f, 0.2f ));

//    scene::IMeshSceneNode* node = smgr->addCubeSceneNode(20);
//    if (node){
//        node->setMaterialFlag(EMF_LIGHTING, false);
//        smgr->getMeshManipulator()->setVertexColors(node->getMesh(),SColor(250,250,0,0));
//        node->setPosition(core::vector3df(0,0,0) );
//        node->setVisible(false);
//    }

    smgr->addCameraSceneNode(0, vector3df(0,0,-50), vector3df(0,0,0));

    while(device->run())
    {
        core::aabbox3df box;
        box.MinEdge.set(vector3df(-100,-100,-100));
        box.MaxEdge.set(vector3df(100,100,100));

        driver->beginScene(true, true, SColor(250, 100, 150, 150));
        smgr->drawAll();
        guienv->drawAll();
        criaGizmosBicos(driver);

//        criaRegiaAnalise(box, driver);

        driver->endScene();
    }
    device->drop();
    return 0;
}
Ejemplo n.º 26
0
void NBEditor::load()
{
	IGUIStaticText* sidebar = state->menu->sidebar;
	IGUIEnvironment* guienv = state->device->getGUIEnvironment();

	if (sidebar) {
		sidebar->setText(L"Node Box Tool");
		IGUIStaticText* t = guienv->addStaticText(L"No node selected",
				rect<s32>(20, 30, 140, 100),
				false, true, sidebar, ENB_GUI_MAIN_MSG);
		
		IGUIListBox* lb = guienv->addListBox(rect<s32>(20, 30, 230, 128),
				sidebar, ENB_GUI_MAIN_LISTBOX, true);

		if (lb) {
			lb->setVisible(false);
			IGUIButton* b1 = guienv->addButton(rect<s32>(0, 100, 50, 125),
					lb, GUI_PROJ_NEW_BOX, L"+", L"Add a node box");
			IGUIButton* b2 = guienv->addButton(rect<s32>(60, 100, 110,125),
					lb, GUI_PROJ_DELETE_BOX, L"-", L"Delete node box");
			b1->setNotClipped(true);
			b2->setNotClipped(true);
		}

		// Create nodebox properties
		t = guienv->addStaticText(L"Properties",
				rect<s32>(0, 170, 120, 190),
				false, true, sidebar, ENB_GUI_PROP);
		t->setVisible(false);

		// Add name properties box
		guienv->addStaticText(L"Name:", rect<s32>(10, 30, 50, 50), false,
				true, t)->setNotClipped(true);
		guienv->addEditBox(L"", rect<s32>(60, 30, 210, 50), true,
				t, ENB_GUI_PROP_NAME)->setNotClipped(true);

		// Add positioning
		addXYZ(t, guienv, vector2di(10, 60),  ENB_GUI_PROP_X1);
		addXYZ(t, guienv, vector2di(10, 160), ENB_GUI_PROP_X2); // 60

		// Add buttons
		guienv->addButton(rect<s32>(30, 250, 100, 280), t, ENB_GUI_PROP_UPDATE,
				L"Update", L"")->setNotClipped(true);
		guienv->addButton(rect<s32>(110, 250, 180, 280), t, ENB_GUI_PROP_REVERT,
				L"Revert", L"")->setNotClipped(true);
	}
	load_ui();
}
Ejemplo n.º 27
0
void viewprt::drawViewPorts(float scale2, float scale3, float scale4, float scalepers)
{
     // Left top view
    video::IVideoDriver* driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    IGUIEnvironment* env = device->getGUIEnvironment();

         s32 screenx = driver->getScreenSize().Width;
         s32 screeny = driver->getScreenSize().Height;
         screenx-=viewrightspace;
         bool skyb = SkyBox->isVisible();


         // Right top view - perspective
         driver->beginScene(true, true, video::SColor(150,50,50,50));
         if (skyb) SkyBox->setVisible(true); else SkyBox->setVisible(false); // show the skybox

         drawPerspectiveView();
         driver->setViewPort(core::rect<s32>((screenx/2),50,screenx,(screeny/2)-5));
         smgr->drawAll();
          // hide the skybox not working for ortho viewports
         drawTopView();
         driver->setViewPort(core::rect<s32>(0,50,screenx/2,(screeny/2)-5));
         smgr->drawAll();

         drawSideView();
         driver->setViewPort(core::rect<s32>(0,(screeny/2),screenx/2,screeny));
         smgr->drawAll();

         drawFrontView();
         driver->setViewPort(core::rect<s32>((screenx/2),(screeny/2)+2,screenx,screeny));
         smgr->drawAll();

         // restore the view for GUI drawing
         driver->setViewPort(core::rect<s32>(0,0,driver->getScreenSize().Width,screeny));
         bill->setVisible(false);
         // draw the viewport boundary
         smgr->setActiveCamera(Camera[0]);
         driver->draw2DRectangle(video::SColor(255,20,20,20),
				core::rect<s32>(0, screeny/2-5, screenx, screeny/2-1));
         driver->draw2DRectangle(video::SColor(255,20,20,20),
				core::rect<s32>(screenx/2-2, 50, screenx/2+2, screeny));
		 if (skyb) SkyBox->setVisible(true); else SkyBox->setVisible(false); // redisplay the viewport

		 env->drawAll();
		 driver->endScene();
}
Ejemplo n.º 28
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;
}
Ejemplo n.º 29
0
/*!
	Startup a Windows Mobile Device
*/
IrrlichtDevice *startup()
{
	// both software and burnings video can be used
	E_DRIVER_TYPE driverType = EDT_SOFTWARE; // EDT_BURNINGSVIDEO;

	// create device
	IrrlichtDevice *device = 0;

#if defined (_IRR_USE_WINDOWS_CE_DEVICE_)
	// set to standard mobile fullscreen 240x320
	device = createDevice(driverType, dimension2d<u32>(240, 320), 16, true );
#else
	// on PC. use window mode
	device = createDevice(driverType, dimension2d<u32>(240, 320), 16, false );
#endif		
	if ( 0 == device )
		return 0;

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

	// set the filesystem relative to the executable
#if defined (_IRR_WINDOWS_)
	{
		wchar_t buf[255];
		GetModuleFileNameW ( 0, buf, 255 );

		string<c16> base = buf;
		base = base.subString ( 0, base.findLast ( '\\' ) + 1 );
		device->getFileSystem()->registerFileArchive ( base );
	}
#endif

	IGUIStaticText *text = guienv->addStaticText(L"FPS: 25",
		rect<s32>(140,15,200,30), false, false, 0, 100 );

	guienv->addButton(core::rect<int>(200,10,238,30), 0, 2, L"Quit");

	// add irrlicht logo
	guienv->addImage(driver->getTexture("../../media/irrlichtlogo3.png"),
					core::position2d<s32>(0,-2));
	return device;
}
Ejemplo n.º 30
0
int main( ) {
	// Boring stuff: set up the scene, object & camera as usual
	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"Combined Effects", rect<s32>( 10, 10, 260, 22 ), true );
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( smgr->getMesh( "sydney.md2" ) );
	node->setMaterialFlag( EMF_LIGHTING, false );
	node->setMD2Animation( scene::EMAT_STAND );
	node->setMaterialTexture( 0, driver->getTexture("sydney.bmp") );
	smgr->addCameraSceneNode( 0, vector3df( 40.0f, 30.0f, -40.0f ), vector3df( 0.0f, 5.0f, 0.0f ) );

	// Interesting stuff (see previous example for full details)
	IPostProc* ppRenderer = new CRendererPostProc( smgr, dimension2di( 1024, 512 ), true, true, SColor( 255u, 100u, 101u, 140u ) );
	CEffectPostProc* ppInvert = new CEffectPostProc( ppRenderer, dimension2di( 1024, 512 ), PP_INVERT );
	// The second effect is made exactly the same way, but takes ppInvert as the input instead of ppRenderer
	CEffectPostProc* ppBlur = new CEffectPostProc( ppInvert, dimension2di( 1024, 512 ), PP_BLUR, 0.01f );

//	delete ppInvert;

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

	while( device->run( ) ) {
		driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9 );
		ppBlur->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 ); }
	}

	// The effects can be deleted in any order
	delete ppBlur;
	delete ppInvert;
	delete ppRenderer;

	// Back to boring stuff
	device->drop();
	return 0;
}