Map HUD
by Frank Bignone · 04/03/2002 (1:33 pm) · 40 comments
Download Code File
This new control can be used to display the terrain either in gray-shade or gradient shade + the player location & orientation.
In order to add it to your project, put the .cc & .h file into your project (in the gui directory). You can then add the following datablock to your main PlayGui.gui :
- color : modulation color for the map
- alpha : transparency of the display
- type : 0 (Gray shaded) & 1 (Gradient shaded)
- icon : B&W icon displayed at the center of the control
If you load missions dynamically in your game, you can use the reset method such that the control will update its terrain view.
Here is a small screenshot :
(From left to right) gray shaded terrain & gradient one
This new control can be used to display the terrain either in gray-shade or gradient shade + the player location & orientation.
In order to add it to your project, put the .cc & .h file into your project (in the gui directory). You can then add the following datablock to your main PlayGui.gui :
new GuiMapCtrl(HudMap) {
profile = "GuiDefaultProfile";
horizSizing = "left";
vertSizing = "bottom";
position = "500 12";
extent = "128 128";
minExtent = "8 8";
visible = "1";
helpTag = "0";
color = "0.5000000 1.000000 0.000000 1.000000";
alpha = "0.4";
type = "0";
icon = "~/map/icon.png";
};The meaning of the different attributes is :- color : modulation color for the map
- alpha : transparency of the display
- type : 0 (Gray shaded) & 1 (Gradient shaded)
- icon : B&W icon displayed at the center of the control
If you load missions dynamically in your game, you can use the reset method such that the control will update its terrain view.
Here is a small screenshot :
(From left to right) gray shaded terrain & gradient oneAbout the author
Real programmers don't waste time recompiling; they patch the binary files... ... Real programmers don't waste time patching binary files; they patch memory.
#2
Ooops...the download link seems to be broken. Nevermind, I DLd from your post :)
04/03/2002 (11:30 am)
Excellent! I think I'll add a toggle to it.Ooops...the download link seems to be broken. Nevermind, I DLd from your post :)
#3
Well Done :)
04/03/2002 (2:04 pm)
How difficult would it be to alter this to show the outline of interior objects as well? I think that would be quite good if possible.Well Done :)
#4
the function dglDrawBitmapRotated() you use doesn't seem to be defined anywhere in the engine... could you please provide it?
Thanks!! :-)
04/03/2002 (2:09 pm)
Frank,the function dglDrawBitmapRotated() you use doesn't seem to be defined anywhere in the engine... could you please provide it?
Thanks!! :-)
#5
04/04/2002 (12:22 am)
dglDrawBitmapRotated is defined in an early resources posted here (did not remember if it's Phil or Matt who posted it). Here is the code BTW ://*********
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::drawBitmapRotated: 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);
glDisable(GL_LIGHTING);
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);
}
#6
Really great control, thanks very much!! I was planning to write something similar, cause I always wanted to have such cool maps as in Tribes2... and now I can use yours! :-))
04/04/2002 (12:40 am)
Thanks, Frank, I got it already working - Matt told us about the function in the forum thread.Really great control, thanks very much!! I was planning to write something similar, cause I always wanted to have such cool maps as in Tribes2... and now I can use yours! :-))
#7
04/05/2002 (12:45 pm)
showing the outline of interior objects in the map would really ROCK, by the way... ;-) Any chance of giving it a try?
#8
Given that our levels will be fairly small compared to some of the landscapes we've seen under discussion, 'interior objects' support would be a boon here.
I'll enter it into our Bugzilla queue and see if someone jumps on it.
Mychal McCabe
Badlands Games
04/07/2002 (12:45 pm)
Really cool stuff Frank.Given that our levels will be fairly small compared to some of the landscapes we've seen under discussion, 'interior objects' support would be a boon here.
I'll enter it into our Bugzilla queue and see if someone jumps on it.
Mychal McCabe
Badlands Games
#9
04/20/2002 (3:25 am)
I can't get it to toggle?
#10
04/24/2002 (12:52 pm)
I've got a quick and dirty Interior objects solution ... take a look at this thread...
#11
am I doing something wrong?
thanks..
04/25/2002 (3:47 am)
HI.. I was trying to put a map gui, I added the 'dglDrawBitmapRotated' function in the dgl.cc and the declaration in dgl.h but it returns a fatal error: unresolved external link in linking it to the MapGui.cc when I try to build it.. am I doing something wrong?
thanks..
#12
04/25/2002 (9:02 am)
@ Architecture@UOA: have you tried CLEAN + REBUILD ALL?
#13
06/21/2002 (7:58 pm)
how can I get it so I can send commands to something eg. it gets the coonditits and sends it to a AI object and moves to that position?
#14
06/21/2002 (7:58 pm)
how can I get it so I can send commands to something eg. it gets the coonditits and sends it to a AI object and moves to that position?
#15
07/09/2002 (8:34 pm)
Like a popup command map, the maps in the middle and you have a cursor and you pick a spot on the map and it sends the coor's to the AI object, and it moves there?
#16
What you are displaying in the map hud is basicly the heightmap for the terrain correct?
I have yet to look at the code indepth, but how hard would it be to display the The final generated texture terrain?
Regards,
Ron
11/04/2002 (11:52 am)
Frank,What you are displaying in the map hud is basicly the heightmap for the terrain correct?
I have yet to look at the code indepth, but how hard would it be to display the The final generated texture terrain?
Regards,
Ron
#17
03/06/2003 (1:57 pm)
Im an ultra newbie to Torque and have no idea where to put dglDrawBitmapRotated, can someone tell me please. Sorry for my stupidity.
#18
03/06/2003 (2:05 pm)
dgl.cc
#19
1) Put guiMapCtrl.h and guiMapCtrl.cc into "torque\engine\gui"
2) Pasted the dglDrawBitmapRotated code at the bottom of dgl.cc
3) Added both files in step 1 to the project by selecting "Project -> Add to Project -> Files...".
4) Tried to build by selecting "Build", then I tried all these choices:
-"Rebuild All"
-"Build Torquedemo_DEBUG.exe"
-"Clean" then each one of the above.
I keep getting identifier errors.
Sorry I am being lame, but this is pretty new to me. I am very much a step by step guy. I am sure I missed something, or there is a fundamental step that I wasn't aware of.
Thanks,
-Jeff
03/27/2003 (3:58 am)
I am sorry, but I am having a terrible time getting this to compile. Here is what I did:1) Put guiMapCtrl.h and guiMapCtrl.cc into "torque\engine\gui"
2) Pasted the dglDrawBitmapRotated code at the bottom of dgl.cc
3) Added both files in step 1 to the project by selecting "Project -> Add to Project -> Files...".
4) Tried to build by selecting "Build", then I tried all these choices:
-"Rebuild All"
-"Build Torquedemo_DEBUG.exe"
-"Clean" then each one of the above.
I keep getting identifier errors.
Sorry I am being lame, but this is pretty new to me. I am very much a step by step guy. I am sure I missed something, or there is a fundamental step that I wasn't aware of.
Thanks,
-Jeff
#20
if not add this
after
03/27/2003 (4:22 am)
did you add the function declaration in dgl.h ?if not add this
//*******
void dglDrawBitmapRotated(TextureObject *texObject,
const RectI& in_rStretch,
const RectI& in_rSubRegion,
const U32 in_flip = GFlip_None,
const F32 spinAngle = 0.0f,
const Point2F spinOffset = Point2F(0,0) );
//*******after
void dglDrawBitmap(TextureObject* texObject,
const Point2I& in_rAt,
const U32 in_flip = GFlip_None); 
Torque Owner Edward Gardner
Seriiously, I had been trying to get the existing terrain editor control to do exactly that, and all I ever got was a black screen with a nice arrown on it :)
Thanks!!