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.
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.
#22
Why, I don't know yet.
Add this line to the GuiCommanderHud::GuiCommanderHud() constructer.
mLastCameraQuery.ortho = false;
Thomas
09/17/2004 (8:05 am)
I had to do this little fix to get the Commander Map Resource Visible in the GUI.Why, I don't know yet.
Add this line to the GuiCommanderHud::GuiCommanderHud() constructer.
mLastCameraQuery.ortho = false;
Thomas
#23
I had again made a little improvement made to guiMapOverviewCtrl.cc
Has to do with the way getting the MissionArea object.
Download updated 18/9-2004.
Thomas
09/18/2004 (11:33 am)
Hi.I had again made a little improvement made to guiMapOverviewCtrl.cc
Has to do with the way getting the MissionArea object.
Download updated 18/9-2004.
Thomas
#24
Could be something I did, just wanted to know if anyone else is experiencing the same thing.
- Jeff
09/19/2004 (8:21 pm)
Anyone else notice the colors for MyControl and Players are funky and don't behave as expected?Could be something I did, just wanted to know if anyone else is experiencing the same thing.
- Jeff
#25
Have you solved your problem.
If not, could you take a screenshot of your problem, and E'mail it to me, then I will take a look at it.
Thomas
09/23/2004 (10:49 am)
Hi Jeff.Have you solved your problem.
If not, could you take a screenshot of your problem, and E'mail it to me, then I will take a look at it.
Thomas
#26
bool InMissionArea = !( (newCoord.x < mArea.point.x) || (newCoord.x > mArea.point.x + mArea.extent.x) || (newCoord.y < mArea.point.y) || (newCoord.y > mArea.point.y + mArea.extent.y) );
if (InMissionArea) {
int x = (((newCoord.x - mArea.point.x) / mArea.extent.x) * mBounds.extent.x) -(mBounds.extent.x / 2);
int y = mBounds.extent.y - (((newCoord.y - mArea.point.y) / mArea.extent.y) * mBounds.extent.y) -(mBounds.extent.y / 2);
was this where u were having errors before Tom?
09/27/2004 (8:28 am)
when joining a server crated by another player i crash out with an error in bool InMissionArea = !( (newCoord.x < mArea.point.x) || (newCoord.x > mArea.point.x + mArea.extent.x) || (newCoord.y < mArea.point.y) || (newCoord.y > mArea.point.y + mArea.extent.y) );
if (InMissionArea) {
int x = (((newCoord.x - mArea.point.x) / mArea.extent.x) * mBounds.extent.x) -(mBounds.extent.x / 2);
int y = mBounds.extent.y - (((newCoord.y - mArea.point.y) / mArea.extent.y) * mBounds.extent.y) -(mBounds.extent.y / 2);
was this where u were having errors before Tom?
#27
Did you download the new updated version after 18/9-2004.
The older version before this date, did not work against a dedicated server.
The problem with the old code was that the MissionArea object was not ghosted correctly to the Client.
So the code above makes and DivedeByZero exception because mArea.extent.x is 0 then executed.
Thomas
09/27/2004 (9:29 am)
Hi Synditech.Did you download the new updated version after 18/9-2004.
The older version before this date, did not work against a dedicated server.
The problem with the old code was that the MissionArea object was not ghosted correctly to the Client.
So the code above makes and DivedeByZero exception because mArea.extent.x is 0 then executed.
Thomas
#28
The old way I told you to do it, could give some trouble like "Invalid Packet from Server" then Client's connected to a dedicated server then another player is mounted in a Vehicle...
Sorry for this.
10/10/2004 (2:48 am)
I made a little change in the description of how to force PlayerObjectType and VehicleObjectType to be ghosted correctly then used in a large mission area.The old way I told you to do it, could give some trouble like "Invalid Packet from Server" then Client's connected to a dedicated server then another player is mounted in a Vehicle...
Sorry for this.
#29
1. Player and Vehicle objects is taken from the ServerConnection group instead of RootGroup. Alot faster...
2. All Vehicle dots is painted before Player dots.
3. Player objects is painted a little smaller than Vehicles.
Thomas
10/10/2004 (5:02 am)
I have again made some smaller changes to this resource.1. Player and Vehicle objects is taken from the ServerConnection group instead of RootGroup. Alot faster...
2. All Vehicle dots is painted before Player dots.
3. Player objects is painted a little smaller than Vehicles.
Thomas
#31
12/13/2005 (7:30 am)
I noticed that you mentioned you took the screenshot with TSE up there. Were you ever able to port this to TSE? I've had all sorts of trouble porting it.
#32
GameConnection* conn = GameConnection::getServerConnection();
should be:
GameConnection* conn = GameConnection::getConnectionToServer();
under 1.4 anyhow...
I have not tested yet but will do shortly.
02/13/2006 (5:12 pm)
Could it be that:GameConnection* conn = GameConnection::getServerConnection();
should be:
GameConnection* conn = GameConnection::getConnectionToServer();
under 1.4 anyhow...
I have not tested yet but will do shortly.
#33
edit: ofcourse you could color it or take a screenshot of your top view rendered interior and put it over the interior' spot
05/05/2006 (6:04 am)
I dont use this resource, but maybe i know a way how to make a map. Load up your mission, press F11 and make sure that your camera is facing down outside the missionArea! then press F10. Now click on the new control button and add "missionAreaEditor". press F10 again and you will see your new missionAreaEditor expanding. press Ctrl+P to take a screenshot and load it in a image editing program. now nicely cut the mission area out and past it in another file. Change the image size, save, maybe edit a bit and save again. I guess you should have a nice map now :-)edit: ofcourse you could color it or take a screenshot of your top view rendered interior and put it over the interior' spot
#34
Any help is appreciated.
-Andy
11/19/2006 (5:40 pm)
Has anyone had problems with their mouse not working? I added this resource (thank you!) and it works, but my mouse movement is gone.Any help is appreciated.
-Andy
#35
11/20/2006 (2:42 pm)
I'm having the same problem. I added the control but now I can't now my mouse input is ignored. Instead of looking around, I now see a mouse cursor. Deleting the control. Doesn't fix it.
#36
11/20/2006 (2:51 pm)
I found that if I set noCursor = true in the top level gui, this seems to fix the problem. I'm still not sure why this happened and if this is the correct fix. Anybody know?
#37
11/21/2006 (11:44 am)
Sounds like the mouse/noCursor problem is a known bug: www.garagegames.com/mg/forums/result.thread.php?qt=54116
Torque Owner Thomas Tomo Larsen
A few other changes has also been made:
Changed Field names. MyPlayer -> MyControl, OtherPlayers -> Players.
Changed the dot rendering order to ensure that own control is drawn as last point.
Also the documentation has been changed to the new settings.
Good luck again.
Thomas.