RPG Map w/Points of Interest
by Peter Simard · 08/17/2006 (11:57 am) · 16 comments
Download Code File
A mission wide overhead map for your Torque RPG. A rotated arrow will follow the player as he traverses the mission. Points of interest can be defined at specific locations and can be given a unique title, description, bitmap, and hover over. You can mark permanent areas such as buildings, merchants, landmarks, etc. In addition you can also use temporary POIs to mark non-permanent destinations such as quest givers/destinations, group members, and others.
Installation
-Extract the .cc and .h files to your engine/gui/controls folder and add these to your project.
-Copy poi.cs to your client/scripts folder
-Copy GuiMapView.gui to your client/ui folder
-Copy newPointOfInterest.gui to your client/ui folder
-Copy the maps folder into your data folder
-Create a directory called data/missions/POIs
-Copy this to your dgl.h file for drawing rotated bitmaps:
-Put this function inside of dgl.cc
That will take care of drawing the rotated arrow. You should now be able to compile your exe.
Script
-Edit common/client/missionDownload.cs:
-Execute your new scripts inside of init.cs initClient()
-Add a keybinding to your default.bind.cs for adding new POIs
Creating a map
You can either have an artist create a map as in WoW and EQ2, or you can generate one. Refer to this resource for discussions on taking a mission screenshot: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6307
Adding Points of Interest
Load up a mission and goto the area you would like to mark. Press Alt-P to bring up the new POI dialog. The description and hover bitmap are optional. It will automaticly insert your current position into the position field. It will save your POI file every time you add a new point.
Notes
-Some sizes / colors are hardcoded
-Only way to edit Points of Interest is to edit the POI file
-Some code has been picked from here and there from the community
A mission wide overhead map for your Torque RPG. A rotated arrow will follow the player as he traverses the mission. Points of interest can be defined at specific locations and can be given a unique title, description, bitmap, and hover over. You can mark permanent areas such as buildings, merchants, landmarks, etc. In addition you can also use temporary POIs to mark non-permanent destinations such as quest givers/destinations, group members, and others.
Installation
-Extract the .cc and .h files to your engine/gui/controls folder and add these to your project.
-Copy poi.cs to your client/scripts folder
-Copy GuiMapView.gui to your client/ui folder
-Copy newPointOfInterest.gui to your client/ui folder
-Copy the maps folder into your data folder
-Create a directory called data/missions/POIs
-Copy this to your dgl.h file for drawing rotated bitmaps:
void dglDrawBitmapRotated(TextureObject *texObject,
const RectI& in_rStretch,
const RectI& in_rSubRegion,
const U32 in_flip = GFlip_None,
const F32 spinAngle = 0.0f);-Put this function inside of dgl.cc
void dglDrawBitmapRotated(TextureObject *texture,const RectI& dstRect,const RectI& srcRect,const U32 in_flip,F32 spinAngle)
{
AssertFatal(texture != NULL, "GSurface::drawBitmapStretchSR: NULL Handle");
if(!dstRect.isValidRect())
return;
AssertFatal(srcRect.isValidRect() == true,
"GSurface::drawBitmapStretchSR: routines assume normal rects");
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture->texGLName);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
F32 texLeft = F32(srcRect.point.x) / F32(texture->texWidth);
F32 texRight = F32(srcRect.point.x + srcRect.extent.x) / F32(texture->texWidth);
F32 texTop = F32(srcRect.point.y) / F32(texture->texHeight);
F32 texBottom = F32(srcRect.point.y + srcRect.extent.y) / F32(texture->texHeight);
F32 screenLeft = dstRect.point.x;
F32 screenRight = dstRect.point.x + dstRect.extent.x;
F32 screenTop = dstRect.point.y;
F32 screenBottom = dstRect.point.y + dstRect.extent.y;
if(in_flip & GFlip_X)
{
F32 temp = texLeft;
texLeft = texRight;
texRight = temp;
}
if(in_flip & GFlip_Y)
{
F32 temp = texTop;
texTop = texBottom;
texBottom = temp;
}
glColor4ub(sg_bitmapModulation.red,
sg_bitmapModulation.green,
sg_bitmapModulation.blue,
sg_bitmapModulation.alpha);
F32 X = 0;
// calculate the centroid of the rectangle (to use as rotation pivot)
if (screenLeft < screenRight)
{
X = screenLeft + ((screenRight - screenLeft)*0.5f);
}
else
{
X = screenRight + ((screenLeft - screenRight)*0.5f);
};
F32 Y = 0;
if (screenTop < screenBottom)
{
Y = screenTop + ((screenBottom - screenTop)*0.5f);
}
else
{
Y = screenBottom + ((screenTop - screenBottom)*0.5f);
};
// spin angle is in degree's so convert to radians..radians = degrees * pi /180
spinAngle = spinAngle * 3.14 / 180.0f;
Point2F screenPoint(X,Y);
F32 width = dstRect.extent.x;
width *= 0.5;
MatrixF rotMatrix( EulerF( 0.0, 0.0, spinAngle ) );
Point3F offset( screenPoint.x, screenPoint.y, 0.0 );
Point3F points[4];
points[0] = Point3F(-width, -width, 0.0);
points[1] = Point3F(-width, width, 0.0);
points[2] = Point3F( width, width, 0.0);
points[3] = Point3F( width, -width, 0.0);
for( int i=0; i<4; i++ )
{
rotMatrix.mulP( points[i] );
points[i] += offset;
}
glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(texLeft,texTop);
glVertex2fv(points[0]);
glTexCoord2f(texLeft, texBottom);
glVertex2fv(points[1]);
glTexCoord2f(texRight, texBottom);
glVertex2fv(points[2]);
glTexCoord2f(texRight, texTop);
glVertex2fv(points[3]);
glEnd();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
}That will take care of drawing the rotated arrow. You should now be able to compile your exe.
Script
-Edit common/client/missionDownload.cs:
function clientCmdMissionStartPhase1(%seq, %missionName, %musicTrack)
{
// These need to come after the cls.
echo ("*** New Mission: " @ %missionName);
echo ("*** Phase 1: Download Datablocks & Targets");
onMissionDownloadPhase1(%missionName, %musicTrack);
[b]
%fileName = filePath(%missionName) @ "/POIs/" @ fileBase(%missionName) @ ".poi";
mapView.empty();
exec(%fileName);
[/b]
commandToServer('MissionStartPhase1Ack', %seq);
}That will load your saved Points of Interest when the mission starts to load.-Execute your new scripts inside of init.cs initClient()
exec("./scripts/poi.cs");
exec("./ui/mapViewGui.gui");
exec("./ui/newPointOfInterest.gui");-Add a keybinding to your default.bind.cs for adding new POIs
moveMap.bindCmd(keyboard, "alt p", "showNewPOI();", "");
Creating a map
You can either have an artist create a map as in WoW and EQ2, or you can generate one. Refer to this resource for discussions on taking a mission screenshot: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6307
Adding Points of Interest
Load up a mission and goto the area you would like to mark. Press Alt-P to bring up the new POI dialog. The description and hover bitmap are optional. It will automaticly insert your current position into the position field. It will save your POI file every time you add a new point.
Notes
-Some sizes / colors are hardcoded
-Only way to edit Points of Interest is to edit the POI file
-Some code has been picked from here and there from the community
#2
08/13/2006 (11:26 pm)
Oops, sorry about, I forgot one of the GUI files. I have reuploaded the resource.
#3
Cheers dude you made my week :-)
08/14/2006 (12:18 am)
Peter: Thanks dude. Exactly what I've been working on for a while, but I had troubles mapping the icons to the map. I'll have a look at this and see if I can base my work on it.Cheers dude you made my week :-)
#4
okay, i did that, but forgot to exe the gui's
But you made a mistake
exec("newPointOfInterest.gui"); Should be exec("./ui/newPointOfInterest.gui");
08/14/2006 (8:43 am)
edit:okay, i did that, but forgot to exe the gui's
But you made a mistake
exec("newPointOfInterest.gui"); Should be exec("./ui/newPointOfInterest.gui");
#5
08/14/2006 (2:35 pm)
Just waiting for this!
#6
08/24/2006 (3:13 pm)
Hey! This plugs right into 1.4! Kudos my friend! Nice job.
#7
Works like charm!
I love the POI client file.
Epic work.
09/26/2006 (8:07 am)
Got this wrenched into TGE 1.3.Works like charm!
I love the POI client file.
Epic work.
#8
03/12/2007 (9:05 pm)
ok I must be missing something I have tried and tried to get this into a clean 1.5 build to no avail. I have the code merged into the engine just fine and it is compiling, but I can not seem to get the actual map to work in game. Someone mind walking me though the steps to get the actual map to show in game using the strong hold mission.
#9
03/15/2007 (1:45 pm)
Im having a problem with getting my map to move underneth my arrow is their a check box or somthing that im missing to make it where i can have my map update as my player moves
#10
03/25/2007 (8:22 am)
So No one knows how to get the actual map coordinates so that the player arrow shows correctly in thwe right location on the map and moves?
#11
1) the mapArrow is not showing the correct loction of the player. (maybe something to do with the map screenshot i took)
2) POI's are not showing on the map.
06/18/2007 (5:46 pm)
ok got this working for the most part in TGE 1.3 but having a few minor issues.1) the mapArrow is not showing the correct loction of the player. (maybe something to do with the map screenshot i took)
2) POI's are not showing on the map.
#12
It wont save my pois
ShatteredEarth.Alpha/client/scripts/poi.cs (10): Unknown command addPointOfInterest.
Object mapView(4483) mapViewGui -> GuiControl -> SimGroup -> SimSet -> SimObject
ShatteredEarth.Alpha/client/scripts/poi.cs (13): Unknown command savePointsOfInterest.
Object mapView(4483) mapViewGui -> GuiControl -> SimGroup -> SimSet -> SimObject
08/29/2007 (11:02 am)
I'm getting some errors in the console.It wont save my pois
ShatteredEarth.Alpha/client/scripts/poi.cs (10): Unknown command addPointOfInterest.
Object mapView(4483) mapViewGui -> GuiControl -> SimGroup -> SimSet -> SimObject
ShatteredEarth.Alpha/client/scripts/poi.cs (13): Unknown command savePointsOfInterest.
Object mapView(4483) mapViewGui -> GuiControl -> SimGroup -> SimSet -> SimObject
#14
06/24/2008 (5:50 pm)
Peter if you are still around. this resource will not draw the players in the correct location on the map nor will it track them correctly.
#15
08/15/2009 (10:52 pm)
Also my question, is it possible to get this to work with TGEA? Looks like an awesome resource, but if it dosn't work with TGEA, than can someone point me in the right direction.
#16
11/06/2010 (7:23 pm)
I have this somewhat ported, am down to about 2-3 errors, I do not really think it is possible with how dgl was excluded/merged into GFXDrawUtil. As there is no drawBitmapRotated. Could possibly be added, but I think this is getting into a bit too much. If anyone wants to further my attempts, let me know and i'll e-mail you the files. 
Torque 3D Owner Thanhda Tie
Digital Shock Inc.
edit:
Getting error, in console