Create a 2d navigation map

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ansonbx
Posts: 2
Joined: Wed Dec 09, 2009 2:04 am

Create a 2d navigation map

Post by ansonbx »

I am a new comer and learning irrlicht engine now.
I want to build a 2d navigation map throught a 3d scene!
------------------------------------------------------------------------------------
I MEAN,first load a 3d scene then generate a 2d navigation map(Bird Eye View Map) ,automatically.
------------------------------------------------------------------------------------
How to do that?
Thank you very much!
Last edited by ansonbx on Wed Dec 09, 2009 3:37 pm, edited 1 time in total.
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

ansonbx
Posts: 2
Joined: Wed Dec 09, 2009 2:04 am

Post by ansonbx »

Escen wrote:Maybe you can take a look at this.
http://irrlicht.sourceforge.net/phpBB2/ ... ght=compas
Thanks all the same!Although,it is not the wanted answer!
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You can use some of that code to render a 2d map on screen. You should also be able to use a projection matrix to draw dots on the map.

Travis
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

I MEAN,first load a 3d scene then generate a 2d navigation map(Bird Eye View Map) ,automatically.
first option:
If you want realtime camera view you can use a SplitScreen.
The image is rendered for every viewport seperately. That means, that you'll loose performance.
Take a look at the SplitScreen example and replace this code part:

Code: Select all

driver->beginScene(true,true,SColor(255,100,100,100));
		
		smgr->drawAll();
               //If SplitScreen is used
		if (SplitScreen)
		{
		    driver->clearZBuffer();
			//Activate camera1
			smgr->setActiveCamera(camera[1]);
			//Set viewpoint to the first quarter (left top)
			driver->setViewPort(rect<s32>(0,0,ResX/2,ResY/2));
			//Draw scene
			smgr->drawAll();
            //return viewport fullscreen
			driver->setViewPort(rect<s32>(0,0,ResX,ResY));
        }
driver->endScene();
To prevent intersecting both viewports you have to clear de Zbuffer between them.

second option:
If a more static overview is desired you can render a 2d map on screen, render single time.

define a texture:

Code: Select all

 video::ITexture* rt = 0;
    rt = driver->addRenderTargetTexture(core::dimension2d<u32>(256,256), "RTT1");
And again replace in the SplitScreen example the following code.
In this code we only create the texture ones by turning off SplitScreen after the first render, just to keep example code simple.

Code: Select all

driver->beginScene(true,true,SColor(255,100,100,100));
        smgr->setActiveCamera(camera[3]);
		//Draw scene
        smgr->drawAll();
		//If SplitScreen is used
		    if (SplitScreen)
		{
			//Activate camera1
			smgr->setActiveCamera(camera[1]);
			driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));

			smgr->drawAll();

            driver->setRenderTarget(0, true, true, 0);
            SplitScreen=false;
		}
		

        driver->draw2DImage(rt,vector2di(0,0),rect<s32> (0,0, 256, 256), 0);

driver->endScene();
I hope this helps you a bit.
wowdevver24
Posts: 26
Joined: Mon Jan 04, 2010 8:02 pm

Post by wowdevver24 »

is this not just an issue of rotating the camera (which btw should have an absolute function just for things like this! and yes I am writing one)

once absolute camera rotation is achieved then it should be very easy because you would just rotate looking at y at 90degrees
Remember all information is contextual and if I do not understand the context I cannot gras the information
Post Reply