Minimap

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
Skatebone
Posts: 15
Joined: Sat Sep 01, 2012 8:23 pm

Minimap

Post by Skatebone »

Hey guys,

I ran into 2 issues when creating my minimap:

Code: Select all

Second issue:
env.AddImage(driver.GetTexture("pointer.bmp"), New Vector2Di(120,120), False, Nothing, 1)
 
First issue:
driver.Draw2DPolygon(New Vector2Di(120, 120), 120, Color.OpaqueBlack, 4)
driver.DrawPixel(120, 120, Video.Color.OpaqueRed)
The first issue is parent - child related:
What is going in in my project is that when i try to draw a square and a pixel they don't show up and I suspect that it is because the terrain is being overlapped. So how would I be able to draw the square over the terrain and the pixel over the square (like in a minimap)

The second issue is being able to move images around. I suspect that Images need some sort of identification such as node so then I can refer to them and be able to reposition the image.

Thanks alot,
Dave
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Minimap

Post by hybrid »

Speaking for native C++ Irrlicht, your first problem should work correctly as stated. When rendering via draw2d methods, only the call order matters. So Pixel would be above polygon.
With your second problem, you get an IGUIImage pointer back from that call under C++. With that handle, you can reposition the image. Or you search the GUI element tree for the element you are looking for. In case you lost the pointer or created the IGUIImage somewhere else.
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Minimap

Post by greenya »

I don't see your code, so will come up with mine. I take 12.TerrainRendering and add next two lines after env.DrawAll() call:

Code: Select all

            driver.Draw2DPolygon(new Vector2Di(120, 120), 120, Color.OpaqueBlack, 4);
            driver.DrawPixel(120, 120, Color.OpaqueRed);
This will make next image:
Image
We see it over Irrlicht logo, because logo was added to GUI environment and been drawn when we call env.DrawAll(), so if we call our two lines of code before this call, we will see it at the bottom of the image. smgr.DrawAll() draws all the 3d, in this particular example if you draw anything before it, you will not see it on the screen, since "3d" (which are terrain and skybox) covers all the screen.

If you need to move image which you added to GUI environment, you can pass necessary arg to AddImage() or save returned value of it.
In this particular example, it is:

Code: Select all

            // add irrlicht logo
            env.AddImage(driver.GetTexture("../../media/irrlichtlogoalpha2.tga"), new Vector2Di(10));
We can rewrite code next way:

Code: Select all

            // add irrlicht logo
            Texture irrLogoTexture = driver.GetTexture("../../media/irrlichtlogoalpha2.tga");
            GUIImage irrLogoGuiImage = env.AddImage(irrLogoTexture, new Vector2Di(10));
            irrLogoGuiImage.RelativePosition = new Recti(new Vector2Di(100, 10), irrLogoTexture.Size);
If you need to draw black rectangle, then image, and then a red pixel, you will have to draw texture manually. Do not add it to GUI environment. Code of drawing this will be:

Code: Select all

            driver.Draw2DPolygon(new Vector2Di(120, 120), 120, Color.OpaqueBlack, 4);
            driver.Draw2DImage(irrLogoTexture, new Vector2Di(10), new Recti(new Vector2Di(0), irrLogoTexture.Size), null, Color.OpaqueWhite, true);
            driver.DrawPixel(120, 120, Color.OpaqueRed);
Image
Skatebone
Posts: 15
Joined: Sat Sep 01, 2012 8:23 pm

Re: Minimap

Post by Skatebone »

Thank you very much guys!

Problem is that I cannot find a way to rotate the gui Image.

Also when drawing 2d, I need a pointer for every object i draw so then i can reposition/rotate ect. How would i go about doing that?

Thanks :)
Skatebone
Posts: 15
Joined: Sat Sep 01, 2012 8:23 pm

Re: Minimap

Post by Skatebone »

Let me be more clear, Say I need to draw a compass for my map:

I need a vertical line, a horizontal line crossing it (forming a cross) and a triangle on top.
I need to make this as 1 object so then I can reposition, rotate ect.
I have no idea since driver.draw... does not return anything ofcourse.

Code: Select all

driver.Draw2DLine(New Vector2Di(10, 10), New Vector2Di(10, 20), Color.OpaqueBlue)
driver.Draw2DLine(New Vector2Di(5, 15), New Vector2Di(15, 15), Color.OpaqueBlue)
driver.Draw2DPolygon(New Vector2Di(10, 5), 5, Color.OpaqueRed, 3) '(needs rotation)
Thanks

Edit: Feel free to post in C++ if you like :)
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Minimap

Post by greenya »

If you use driver.Draw2Dxxx() methods, you need to calculate all positioning manually.
If you use driver.Draw3Dxxx() methods, you can position the drawing by calling driver.SetTranform().
Skatebone
Posts: 15
Joined: Sat Sep 01, 2012 8:23 pm

Re: Minimap

Post by Skatebone »

I will try using the 3d and converting it into 2d but i need the position to be fixed on the screen not on the terrain.

Also what do you think if I add a class Line2D within the irrlicht engine (device class) and work like this:

Code: Select all

Dim line1 as new line(vector2di(5,5),vector2Di(5,10))
Line1.draw()
Line1.rotate(30)
Line1.dispose
Line1.location...
Line1.refresh...
Also i think i might switch to c++ since it seems like the way to go..

Edit: I was taking a look here: http://irrlicht.sourceforge.net/docu/cl ... 2630168d3b
Thanks for your time green.
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Re: Minimap

Post by Ravi08 »

Hi, I've got this link to a post, it is a bit old but you might find it helpful. http://irrlicht.sourceforge.net/forum/v ... p?p=105131
"Hey Baby Wobbling Wobbling"
-Russell Peters
Post Reply