Mini-map draw ins?
by Christian · in Game Design and Creative Issues · 11/20/2007 (11:17 pm) · 9 replies
I'm attempting to make a gui that uses something similar to what the RTS mini-map or radar gui does. Basically I have a picture (the example empty square). I want to fill little parts of it in with a little blotch of colors. The colors will get more or less throughout the program. What would be the simplist way of doing this? Thanks.


#2
The color blotches represent...well color blotches. I want to take a picture such as an empty box...if you press add green, it needs to add a green blotch somewhere on it, etc. I thought of using a drag and drop to have the user add their desired blotch to many different slots, but it needs to have hundreds of spots (so little tiny color blotches).
11/21/2007 (4:35 pm)
C++ is very new to me so far (learning the basics)....so reverse engineering from the radar is a little past me at this moment.The color blotches represent...well color blotches. I want to take a picture such as an empty box...if you press add green, it needs to add a green blotch somewhere on it, etc. I thought of using a drag and drop to have the user add their desired blotch to many different slots, but it needs to have hundreds of spots (so little tiny color blotches).
#3
i would make lil' png image files of all the different colors you want,
then when they press a key, dynamically create a new GuiBitmapCtrl and add it to the parent control.
no C++ needed.
here's some (untested) script code which might help set you in the right direction:
11/21/2007 (4:47 pm)
So, you want to add lil' blotches of different colors depending on what the user presses ?i would make lil' png image files of all the different colors you want,
then when they press a key, dynamically create a new GuiBitmapCtrl and add it to the parent control.
no C++ needed.
here's some (untested) script code which might help set you in the right direction:
function addRandomBlotchToControl(%parentControl)
{
%random = getRandom(0, 7); // assumes you have 8 different color swatches
%bitmapPath = "pathToMyBasicBitmap/myBitmap" @ %random;
%newCtrl = new GuiBitmapCtrl() {
position = getRandom(0, getWord(%parentControl.extent, 0) - 10) SPC getRandom(0, getWord(%parentControl.extent, 1) - 10);
extent = "10 10"; // assuming you want lil' 10 x 10 blotches
bitmap = %bitmapPath;
visible = true;
};
%parentControl.add(%newCtrl);
}
#4
11/21/2007 (4:50 pm)
Ooh, that is a great idea, thak you Orion, i'll try it out here shortly.
#5
This new control would keep a list of your spots and in the render function simply draw them. It may still get slow if you have an extreme amount of spots (in which case you probably rather want to blit the spots into a bitmap, but that gets much messier).
11/21/2007 (6:18 pm)
That should work if you have a moderate amount of "blotches".Quote:...it needs to have hundreds of spots...Doing what Orion said would create an awful lot of overhead having to create a new control for EACH spot... It may be fine, but the "proper" way to do this would be to write a new GUI control. (It's not that difficult! Most of it you could "copy" from any of the existing controls).
This new control would keep a list of your spots and in the render function simply draw them. It may still get slow if you have an extreme amount of spots (in which case you probably rather want to blit the spots into a bitmap, but that gets much messier).
#6
11/21/2007 (8:41 pm)
Good point. i've been impressed with TGE's rendering of hundreds of guiControls on-screen at the same time, but yr absolutely right, as the numbers get larger you'll want to do something like bake 'em down to a single texture.
#7
Just writing a control that does dglDrawBitmap(...) for each of your spots will get rid of the overhead of having a lot of extra GUI controls. If you're only doing 10 or 20 spots the difference may be negligible, and if you as I said above have 10,000 spots this wouldn't be a great option either.
It's something you would have to test out and see how it works for your particular situation. I'm just posing options.
11/21/2007 (8:55 pm)
You probably wouldn't have to burn it into a single texture (although that's an option if you have a LOT of spots, as in 10s of thousands of spots... I've actually done that in a prototype of mine, wanted to try out creating huge worlds in TGB, and I needed a map of the world.... some 10,000 randomly generated planets. http://blikstad.com/space_pirates/clusters.jpg, yep, the big GG logo in the background is ONE of those tiny little dots on the map =). Just writing a control that does dglDrawBitmap(...) for each of your spots will get rid of the overhead of having a lot of extra GUI controls. If you're only doing 10 or 20 spots the difference may be negligible, and if you as I said above have 10,000 spots this wouldn't be a great option either.
It's something you would have to test out and see how it works for your particular situation. I'm just posing options.
#8
dglDrawBitmap(mRenderTexture, offset, GFlip_Y);
is what's coming up in searches.
11/21/2007 (9:04 pm)
Magnus, that picture you just showed is about exactly what i'm looking for, could you point me in the right direction for using dglDrawBitmap?dglDrawBitmap(mRenderTexture, offset, GFlip_Y);
is what's coming up in searches.
#9
As for information on how to use dglDrawBitmap, just search through the source, there's a ton of examples in there.
11/21/2007 (9:07 pm)
My picture isn't using dglDrawBitmap, it's using my own blitting routines to "burn" it all to a texture. As for information on how to use dglDrawBitmap, just search through the source, there's a ton of examples in there.
Torque Owner Shaderman
2. What are the colored blotches representing? Player positions?