Game Development Community

Simple guiMapOverviewCtrl

by Thomas Tomo Larsen · 08/24/2004 (8:38 am) · 37 comments

Download Code File

Here is a gui control that will give you an overview of your current mission map,
and also plot the positions of all player and vehicle objects within the missionarea.

Place the files into the following Torque directory:

torque\engine\gui\
guiMapOverviewCtrl.h
guiMapOverviewCtrl.cc

Add the guiMapOverviewCtrl.h and guiMapOverviewCtrl.cc files to your torqueDemo projects gui folder and then recompile.

Create a .png picture of your mission area.
You can paint one yourself, or take a screenshot from within Torque's world Editor.
(Not an easy task but possible)
I have made one for use with the Stronghold mission.

Name your created .png files with the name of your mission name.
For the Stonghold mission use filename stronghold.png
Place all the .png files you created into the ./client/ui folder.

Run torqueDemo.exe and go into a mission.
Press F10 and add the guiMapOverviewCtrl as a new control into the PlayGui.gui and name it 'Map'.
Resize and align the control as you like it.
Fill in the bitmap field with the .png file you created.
example: starter.fps/client/ui/stronghold.png
Save....

Here is a description of the fields of interest, which belongs to the guiMapOverviewCtrl:
extent // The size of the control.
visible // The visibility of the control.
bitmap // The nice picture that you created.
MyControlVisible // Enabling flashing dot for the local player shape.
MyControlColor // Dot color for the local player shape.
PlayersVisible // Enabling dots for all other players shape. (Incl. bots)
PlayersColor // Dot color for all other players shape. (Incl. bots)
VehiclesVisible // Enabling dots for all vehicle types.
VehiclesColor // Dot color for all vehicle types.
MapAlpha // Transparent setting for the Map. (0.0 -> 1.0)
PointSize // Size of dots.

Instead of using the graphical Editor you can also copy this code directly
into your PlayGui.gui file, just before the last '}'

new GuiMapOverviewCtrl(Map) {
profile = "GuiDefaultProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "359 16";
extent = "256 256";
minExtent = "8 2";
visible = "1";
wrap = "0";
bitmap = "starter.fps/client/ui/stronghold.png";
MyControlVisible = "1";
MyControlColor = "1.000000 0.000000 0.000000 1.000000";
PlayersVisible = "1";
PlayersColor = "0.000000 0.000000 1.000000 1.000000";
VehiclesVisible = "1";
VehiclesColor = "0.000000 1.000000 0.000000 1.000000";
MapAlpha = "1";
PointSize = "10";
};

-----------------------------------------------------------------------------------------------

If you want to use different bitmaps for different mission files,
then add this line to your PlayGui.cs file, inside function PlayGui::onWake(%this)

Map.SetBitmap(GetMapNameFromMissionArea());

And add this function down under PlayGui::onWake(%this)

function GetMapNameFromMissionArea()
{
if (isObject(ServerConnection)) {
for (%index = 0; %index < ServerConnection.getCount(); %index++) {
if (ServerConnection.getObject(%index).getClassName() $= "MissionArea") {
return(ServerConnection.getObject(%index).getMapName());
}
}
}

return("");
}


Overwrite MissionArea.h and MissionArea.cc in the engine with the one downloaded.
I have added a new field "MapName" to the MissionArea object.

Add the dynamic mapname to your mission file like this. (F11 or in your text editor)

new MissionArea(MissionArea) {
Area = "-152 -352 1040 1056";
flightCeiling = "300";
flightCeilingRange = "20";
MapName = "~/client/ui/stronghold.png";
locked = "true";
};


-----------------------------------------------------------------------------------------------

If you want to toggle the map on/off, then add these lines to your default.bind.cs file.

function toggleMapOverviewCtrl( %val )
{
if ( %val )
{
Map.Visible = !Map.Visible;
}
}

moveMap.bind(keyboard, "alt m", toggleMapOverviewCtrl);


Delete your config.cs file or just add the above moveMap.bind command to it, for this to work correctly.

-----------------------------------------------------------------------------------------------

Caution:
Only ghosted objects are visible.
What this means is that if the distance to other players/vehicles is larger than approx 1000 units the
object isn't ghosted from the Server to the Client. Argrrrr.

A solution to this problem is to force the objects to always be ghosted, by adding 2 lines
to shapebase.cc in function ShapeBase::onCameraScopeQuery()

if (mSceneManager == NULL) {
// Scope everything...
gServerContainer.findObjects(0xFFFFFFFF,scopeCallback,cr);
return;
}
else // Add the next 2 lines to force PlayerObjectType and VehicleObjectType to always be ghostet.
gServerContainer.findObjects(PlayerObjectType | VehicleObjectType,scopeCallback,cr);


This again can give some trouble with sounds from FlyingVehicles, etc... that you have to fix afterwards. Sorry guys..
I also had this trouble...

Good luck.
Page «Previous 1 2
#1
08/24/2004 (8:49 am)
Says zip file is missing?
#2
08/24/2004 (10:45 am)
Eustacia, I think it takes awhile for the link to become active.
Looks good, may try it soon.
#3
08/24/2004 (11:00 am)
great idea .... but the zip link links to this site
#4
08/24/2004 (11:38 am)
download is still not working. maybe can you reupload it?
#5
08/24/2004 (11:41 am)
Lets give the man a chance .... he uploaded it today 24-08-2004(mayby he wants to sleep afterwards :) )
#6
08/24/2004 (12:09 pm)
Resources need to be reuploaded when the resource goes active. I think its a bug in the site source. Just delete your zip, and reupload and then it usually works
#7
08/24/2004 (12:42 pm)
I uploaded the file again. Now it works...
;-)
#8
08/24/2004 (11:16 pm)
Wow! Great job Thomas! I tried it and it works perfectly! And it's very easy to apply! I'll put your name in the credits :)

Nick
#9
08/26/2004 (1:02 am)
I guess I don't include my files right in my I use Microsoft Visual C++ v.6 (MS-VC++) and I have opened my project ( torque\vc6\Torque SDK.dsw ) and copied our files to torque\engine\gui\guiMapOverviewCtrl.cc /.h and opened them from MS-VC++ And I was asked if I wanted to add them to the project - and I did.

I tried to find the "guiMapOverviewCtrl" in the "new control" panel and it wasn't there.
I tried to make a blank space in your files (guiMapOverviewCtrl.cc /.h) and recompile the project and it didn't recompile your files - now do I wonder in whice files do I need to include it ?
Or have a made another mistake ?

regards Ole Oldhoj
#10
08/26/2004 (1:12 am)
Try doing a Rebuild. That way it will recompile all the files.

Nick
#11
08/26/2004 (1:13 am)
I should have tried that - what I don't do to save time (use
#12
08/26/2004 (1:16 am)
well well ... I haven't made a rebuild all In a long time .... 4 errors(all mine) ... but it works now thanks.
#13
09/01/2004 (8:49 am)
Thanks for this. It integrated without a hitch to my build. :)

Btw. If its not too much to ask, can you give a guideline on how to make the map image. Like whats the dimension should be. Up to which part of the actual terrain should be captured. The easiest way to build a map image.

Thanks again for this.

r/alex
#14
09/06/2004 (1:27 pm)
Hi Alex...

First I have to say that I found some fatal errors in my code.
I'm working on them, as hard I can do to resolve them.
The errors are only visible then Clients are connected to a remote server, and not then playing local.

I hope I can fix those errors soon, and upload a new version to this forum.
Maybe in a few days from now.



How to make a map?

Here is how I did it step by step.
This is maybe not the easiest way of doing it, but it works...
If anybody have a better solution, please post it to this forum.

Strip your mission file for all objects that will not be visible from up air.
Also remove all fps eat'ers.
E.g. All vehicles types, Audio emitters, fxShapeReplicator, fxGrassReplicator, etc....


First we have to modify the engine a bit, but only temporary. Remember to change back after this.

In game/main.cc find this line of code
FrameAllocator::init(3 << 20); // 3 meg frame allocator buffer

Change this to
FrameAllocator::init(3 << 22); // 12 meg frame allocator buffer

This prevent a assert (or a crash) from happening then you look a your terrain from up air.
You can raise this number if it isn't enough.


In game/camera.cc find this line of code
#define MaxPitch 1.3962

Change this to
#define MaxPitch 1.5707

Now you can look straight down in camera viewing mode. The value equals to Pi/2.




Next compile and start Torque in debug mode.

Start your mission from which you want your mission bitmap created from.

Press F11 to enter the World Editor inspector.

Choose Edit->WorldEditor Settings...

Uncheck Render Object Text and Render Object Handle.

Chose Camera->Drop Camera at player... or Alt-Q
With your mouse, turn view to look straight down into the ground.

Expand your MissionGroup and find your MissionArea object,
Calculate the center of your MissionArea by looking at the Area property. (Normally X=0, Y=0)
Example: -1024 -1024 2048 2048
StartX = -1024
StartY = -1024
WidthX = 2048
WidthY = 2048

CenterX = (WidthX / 2) + StartX
CenterY = (WidthY / 2) + StartY



Expand your Sky object.

Set the value of the fogDistance property to a large number. e.g. 10000

Set the value of the visibleDistance property to a large number. e.g. 5000

Switch to Visual Studio (or another enviroment) and create a breakpoint at this line in camera.cc
setPosition(pos,mRot);

Then execution stops, add a watch for both the 'pos' and 'mRot' variables.
In your watch window change the following values for 'pos' and 'mRot'.

pos.x = Your calculated CenterX
pos.y = Your calculated CenterY
pos.z = 1000

mRot.x = 1.5714
mRot.y = 0
mRot.z = 0

Remove breakpoint again, and continue execution (F5)

Now you are standing in the middle of your mission area, looking straight down from 1000 unit up air.

Press your down-cursor to move up, until you can see all of the mission area at one time.
You maybe have to investigate your mission area before doing this to know where to stop.

If you suddenly se that your terrain gets misrendered before you get high enough, you have some big trouble like I did.

My solution to this problem was to use the new TSE engine to create the map in the same way as described above.
This new rendering machine (DirectX instead of OpenGL) doesn't have this problem. :-)

Then your map overview is big enough + 10% extra, create a screenshot with your PrintScreen key.

Paste this screenshot into your favorite painting program.


Now you have to find the corners of your mission area in your new pasted bitmap.
Change back the value of the visibleDistance property to 500 to prevent an assert form happening, then moving the camera around.
Go to each corner (Above it) in your mission area, from within the World Editor and examine it carefully.
Try finding the same dot in your pasted bitmap. Write down the x,y coordinate. Do the same for all 4 corners.

After this, select and crop the bitmap at the 4 corners you found. After that, resize bitmap to 512*512 or 256*256.
Save it as a .png picture.
Finish.....

As I told. This was not an easy task... :-)

Hope this has been a help to you. Good luck.

Thomas
#15
09/16/2004 (4:51 pm)
Works beautifully. Thanks Thomas!

Wish there was a better way to make the map png though.

- Jeff
#16
09/16/2004 (6:34 pm)
@Thomas.

I spent some time jumping through the hoops as you described it just to get my overview map. It worked but I wouldn't want to do it again if I can help it. Maybe somebody got an easier way though. ;)

Still, thanks.

r/Alex
#17
09/17/2004 (12:35 am)
I was thinking somthing about making a camera fly at the top of the figurer - so it would follow the player around - this camera should not see the figures on the map , but only the objects and the ground.


Is anyone up for this challange ? :) .... perhaps should I make it myself.
#18
09/17/2004 (4:10 am)
How about install the Commander Map resource and take a screen shot?
#19
09/17/2004 (5:18 am)
Hi Eustacia Green.

I have just tested the resource.
You are right. With this resource it is possible to make a screenshot without manipulating the engine.
Super :-)

Thanks for this Link.

Thomas
#20
09/17/2004 (5:54 am)
nice ---
Page «Previous 1 2