Game Development Community

dev|Pro Game Development Curriculum

Radar Control (GuiRadarCtrl) for TGEA v1.0+

by James Laker (BurNinG) · 05/14/2007 (3:05 pm) · 78 comments

Download Code File

Hey again. Just in the process of porting my old resource found here .

To install and use:
1) Backup old guiRadarCtrl.h/guiRadarCtrl.cc (If you already have it installed)
2) Add the files from this resource. I created a new folder called "Hud" in my game folder. So in guiRadarCtrl.cpp you'll find that the .h file is referenced in to that loacation. You can just change it to match yours. Look for it at the #includes at the top of the file.
3) Recompile (Full Build)
4) In the GUI editor (F10) add the GuiRadarCtrl
5) Change the properties in the GUI editor

Extra:
Randy sent me some updates to this to allow for different blip dots (which are now small images). So when a target on the Radar is higher than your player, you can have a different blip image. So you should see 3 different blip files in the Properties (Above,Below,Level). You can make them all the same if you prefer that.

The LevelRange is the variable to set when the LevelBlip should be shown. If the value is 10, then all object on the Radar 10 meters above and 10 meters below you will still be shown as level.
The default is 20.

Then there's the RadarRange variable which is how far your radar will pick up objects. The default is 2500

Community Contribution:
The Scrolling Map and Radar Compass fix has been contributed (09 August 2007) by Matt Huston and Stickman Studios. Thanx you guys!

Last Update:
10 March 2008
#21
11/21/2007 (2:46 am)
I made the mBitmapModulation change I mentioned above and changed mRadarRadiusRange from 2500.0f to 250.0f. No flickering here with TGEA 1.0.3.
#22
11/21/2007 (7:27 am)
I'm still having this problem even on vanilla TGEA 1.0.3. I just did a test and installed the resource onto a copy of my original TGEA install, with nothing else added. As soon as I added the Radar control and put in my graphics the compass started flickering.

Here is a link to the graphics I'm using (I created them as PNG files in Photoshop CS3):
www.arcanoria.com/tmp/radarctrl-graphics-arcanoria.zip

Can someone please download this zip file and try them and let me know if the graphics themselves might possibly be the problem? I've tried using the graphics from the original resource but I'm still having the issue.

Not sure if it matters but here's my system info:
ATI Radeon X1950pro, dual head 1280x1024
Athlon64 X2 4200+ dual core cpu
2.5gb RAM, 70gb of hard disk available
WinXP Media Center Edition Version 2002 SP2

It's also flickering on my test computer, which is:
ATI Radeon X1950pro, single head 1280x1024
Athlon64 X2 3800+ dual core cpu
1gb RAM, 90gb of hard disk available
WinXP Pro Version 2002, SP2
#23
11/21/2007 (11:24 am)
I've done some more testing on a 3rd system that's also ATI based, although it's an Intel dual core CPU, rather than an AMD.

One of my team members is also seeing the problem on his NVidia based system.

Here's a snippet from my gui code, if that helps:
new GuiRadarCtrl(Radar) {
      canSaveDynamicFields = "1";
      Profile = "GuiDefaultProfile";
      HorizSizing = "right";
      VertSizing = "bottom";
      Position = "7 80";
      Extent = "0 0";
      MinExtent = "192 192";
      canSave = "1";
      Visible = "1";
      tooltipprofile = "GuiDefaultProfile";
      hovertime = "1000";
      //RadarBitmap = "./radar_base.png";
      RadarBitmap = "./radarBG-blue.png";
      wrap = "0";
      blip_above = "./icons/bank_up.png";
      blip_below = "./icons/bank_dn.png";
      blip_level = "./reddot.png";
      RadarRange = "60";
      ShowRadar = "1";
      //CompassBitmap = "./compass.png";
      CompassBitmap = "./radar-compass2.png";
      ShowCompass = "1";
      //MapBitmap = "./scorchedPlanet.png";
      MapBitmap = "~/data/terrains/humezone1a4r/HumanZone1aTest2_TX.jpg";
      ShowMap = "0";
      RadarShowBots = "1";
      RadarShowPlayers = "1";
      RadarShowVehicles = "1";
      RadarShowShapeBase = "1";
      LevelRange = "1101004800";
      HideAll = "0";
   };
Can someone who has it working post their gui code so we can see if there are any differences in configuration?

I'd really like to get this tracked down and figure out what the difference is between my implementation and those of you who have it working. Thanks in advance!
#24
11/21/2007 (11:53 am)
No problem with your images and GuiRadarCtrl data here.
#25
11/21/2007 (12:26 pm)
Thanks for testing them Stefan. I wonder what else could be different between our systems, since we're both working with TGEA 1.0.3 as a basis. Could it be something in my build environment?

I'm using MS Visual C++ 2005 Express Edition, and I've got the following SDK's installed:
- directX October 2006
- directX December 2006
- platformSDK for windows server 2003 R2

Is that what people are commonly using, or are you using a more recent directX sdk, such as the Feb 2007, April 2007, June 2007, August 2007, or even November 2007 sdk's?
#26
11/21/2007 (1:48 pm)
there's your problem - get the latest directx update...
DX Download
You need something from April 2007 or better
#27
11/21/2007 (9:40 pm)
Alas, that's not it. I downloaded and installed the April 2007 DirectX SDK, did a rebuild solution and the compass is still flickering. Then I downloaded and installed the November 2007 DirectX SDK, rebooted, rebuilt, and I'm STILL flickering.

What else is left? What could be the difference that makes my systems flicker and others not flicker?
#28
11/22/2007 (12:08 am)
What about video settings like AA, color depth and so on?
#29
11/22/2007 (1:46 am)
have you confirmed whether the original radar png flickers?
#30
11/22/2007 (4:16 am)
@Stefan: I've got 3 computers here showing the same problem, and my team member has it too. Our systems are varied, both ATI and NVidia graphics, both AMD and Intel CPU, etc. I'm running everything at 1280x1024@60hz with standard 32bit color depth on my LCDs on my 3 systems here.

@Andy: If I install the original resource (www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10333) into TGE it doesn't flicker. If I take the graphics from that resource and put them into TGEA it flickers every time.
#31
11/25/2007 (2:28 pm)
I worked with a small map without bots so far for testing and didn't see any flickering. We've added an AIPlayer now and have that problem as well. It looks like there's a conflict with GuiShapeNameHud::drawName(). The flickering is gone if I either remove that control from playgui.gui or remove the line %player.setShapeName(%name); in AIPlayer::spawn() . I think I won't go deeper because we don't need player names to be drawn.
#32
11/26/2007 (11:10 am)
@Stefan : I have removed the guiShapeNameHud but the flickering persists .....

But the problem is in guiradar resource ??

Can anyone help us ??

I use NVIDIA GeForce 8400 GS and DX June 2007.


Bye
Andrea
#33
11/27/2007 (10:52 pm)
Can anyone confirm that they are experiencing this on another TGEA other than 1.03?
#34
11/28/2007 (3:07 am)
I just installed onto a fresh copy of TGEA 1.0.2 and it's flickering.
#35
11/28/2007 (3:38 am)
As further followup, I've just installed onto a fresh copy of TGEA 1.0.1 and it's flickering.

Are you folks who are NOT seeing the flickering trying installing onto a fresh install like this? I'm still not clear on if people have done exactly this yet.

Here's the entire procedure I'm using:

1. install a new copy of TGEA (1.0.1, 1.0.2, or 1.0.3, doesn't matter, but it needs to be to a new folder)

2. copy the source files into the "engine/gui/game" folder (and add them to the project in Visual Studio).

3. change guiRadarCtrl.cpp line 12 to say: #include "gui/game/GuiRadarCtrl.h"

4. copy the graphics files ("radarBG-blue.png", "radar-compass2.png", "reddot.png", or any other graphics files) into the "example/demo/client/ui" folder. Again, I've made these graphics available for testing at www.arcanoria.com/tmp/radarctrl-graphics-arcanoria.zip for your download.

5. Rebuild Solution

6. start the engine, click "Interactive Walkthrough", when you see the space orc wave at you hit F10

7. add a new GuiRadarCtrl

8. set the following variables in the control: Extent "192 192", RadarBitmap "demo/client/ui/radarBG-blue.png", wrap turned off, blip_level "demo/client/ui/reddot.png", CompassBitmap "demo/client/ui/radar-compass2.png". Leave all other values as default.

9. Hit F10 and watch to see if the the control is "flickering", then post here with your results. Please note that the radar-compass2.png is NOT supposed to look black, it's supposed to have Orange letters and White crosshairs. If it appears black on your screen then you ARE seeing the flickering.

Thanks in advance to anyone who tries this procedure and posts here with your results!! It should only take about 10 minutes to do.
#36
11/29/2007 (6:11 pm)
I'm pretty unsure of why he doesn't use primbuilder and writes directly into the vertex buffer. This is probably the source of this problem. NOW for the fix!

if (mCompassTextureObject && mShowCompass)
   {
      GFX->clearBitmapModulation();

      GFXTextureObject* texture = mCompassTextureObject;
      
      GFX->setCullMode( GFXCullNone );

      GFX->setLightingEnable( false );
      GFX->setAlphaBlendEnable( true );

      GFX->setSrcBlend( GFXBlendSrcAlpha );
      GFX->setDestBlend( GFXBlendInvSrcAlpha );
      GFX->setTextureStageColorOp( 0, GFXTOPModulate );
      GFX->setTextureStageColorOp( 1, GFXTOPDisable );

      GFX->setTexture( 0, texture );
      GFX->disableShaders();

      F32 width = mCompassTextureObject.getWidth() * 0.5;

      MatrixF rotMatrix( EulerF( 0.0, 0.0, mDegToRad(cameraAngle)));

      Point3F offset( offset.x + mCompassTextureObject.getWidth() / 2, 
                      offset.y + mCompassTextureObject.getHeight() / 2, 0.0 );

      Point3F points[4];
      points[0] = Point3F(-width, -width, 0.0f);
      points[1] = Point3F(-width, width, 0.0f);
      points[2] = Point3F( width, width, 0.0f);
      points[3] = Point3F( width, -width, 0.0f);

      for(int i = 0; i < 4; i++)
      {
            rotMatrix.mulP( points[i] );
            points[i] += offset;
      }

      PrimBuild::color3f(1.0f,1.0f,1.0f);

      PrimBuild::begin(GFXTriangleFan, 4);
         PrimBuild::texCoord2f(0, 0);
         PrimBuild::vertex3fv(points[0]);
         PrimBuild::texCoord2f(0, 1);
         PrimBuild::vertex3fv(points[1]);
         PrimBuild::texCoord2f(1, 1);
         PrimBuild::vertex3fv(points[2]);
         PrimBuild::texCoord2f(1, 0);
         PrimBuild::vertex3fv(points[3]);
      PrimBuild::end();

      GFX->setAlphaBlendEnable( false );
   }

Try it and post your results! Fixed it for me.

EDIT: Tabs ate formatting. fixed.
EDIT2: Fixed texCoord issue.
#37
11/29/2007 (9:28 pm)
@Ishbuu: you're a genius! It's not flickering!!

Only correction to your fix is that it's necessary to add this to the top of guiRadarCtrl.cpp, around line 11:

#include "gfx/primBuilder.h"

Thank you!!
#38
11/30/2007 (4:38 am)
I've made some other changes to this resource myself, and cleaned up a few bugs and unimplemented features, and even added a feature or two myself. If anyone's interested in my completed version, I've put together a package which includes the following modifications to the resource:

1. fixed the "centering problem" where blips are not placed in the center of the control

2. added in the "advanced camera" fix from the old resource

3. reworked the logic where different objects are selected to be shown or not shown, including adding in the missing implementation of the "mShowShapeBase" boolean (wasn't implemented at all!)

4. added in a new boolean variable "RadarShowBots" which detects AIObjectType, for folks who use AIPlayer for their NPCs.

5. applied Ishbuu's fix to the Map graphic in addition to the Compass graphic (this was not trivial!)

6. fixed Ishbuu's fix in another way: the compass graphic was being rendered backwards, now fixed

7. changed the default location of the source files to engine/gui/controls

8. added some new colored dot graphics that were not provided by the original resource

9. added a new "insert into gui code.txt" file to help people get a quick start using the resource

10. packaged it all up again as a new download for your enjoyment at:

www.arcanoria.com/resources/guiradarctrl.tgea-working3.zip

Thanks again to everyone involved in making this happen!

edit: updated the link to point to an updated zip file, containing the correct source files! (thanks Matt Kronyak for pointing this out!)

edit2: re-updated the link and zipfile to add Matt Kronyak's compass scaling fix
#39
11/30/2007 (11:58 am)
@ Arcanor:

Great!!! :D

I cannot wait to try it... but I have to, till wednesday, I'll have an examination at the univ. after that will be the first thing I'll do. :D

And many thanks to Ishbuu as well !!! :D
#40
11/30/2007 (12:02 pm)
Thanks for your work guys. The "flickering fix" doesn't work here though :/ Seems like we have a different problem.