Game Development Community

dev|Pro Game Development Curriculum

RPG Object Selection Hud (TGE)

by Matt Huston · 07/11/2007 (1:27 pm) · 7 comments

Download Code File

Tested with TGE 1.52
Ported from TGEA to TGE by bank

Overview

Object selection similar to Deus Ex, System Shock and other Action-RPGs. A outline rectangle is drawn and the objects name is printed at the top right corner. To add new objects, check the ObjectMask but remember you will need to make sure the object type being added has its own CastRay function or it won't be picked up. ItemObjectType for instance doesn't have one so you will need to add it yourself.

Add guiObjectSelectionHud.cc to your project in the engine/game/fps directory.

Compile!

Add the following to the bottom of you playGui.gui.

new GuiObjectSelectionHud() {
      canSaveDynamicFields = "0";
      Profile = "GuiDefaultProfile";
      HorizSizing = "relative";
      VertSizing = "relative";
      Position = "0 0";
      Extent = "640 480";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      hovertime = "1000";
      TextColor = "1 1 1 1";
      TextOutlineColor = "1 1 1 1";
      TextFillColor = "0.3 0.3 0.3 0.75";
      OutlineColor = "1 1 1 1";
      Offset = "10";
   };

OutlineColor - Object selection rectangle color.
TextColor - Object names text color.
TextOutlineColor - Text rectangles outline color.
iTextFillColor - Rectangle behind texts fill color.
Offset - Offset from the objects bounding box to the actual rectangle.

#1
07/12/2007 (10:00 am)
Nice work.
#2
09/05/2007 (2:37 pm)
Nice Work, I'm putting a link to this for my students to look at.
#3
12/01/2007 (5:04 pm)
This is just what I was looking for, thanks!

EDIT: Never mind, figured it out.
#4
01/22/2008 (7:59 am)
Great!
#5
02/01/2008 (2:07 pm)
Very cool resource.
#6
02/04/2008 (6:27 am)
Great idea - thanks!
Small problem - nothing's showing up :P Using an AIPlayer, but it should work. Maybe I've messed something else up in Torque.
Ah - I see the problem. Only named objects. Huh.
Anyway, excellent resource :)
For anyone else who wants to be able to select non-named objects:
Find the if-block beginning with
if (obj->getShapeName())
Select everything inside that if-block before the comment
//Draw!
And move it outside the if-block, before it. So you have:
Box3F bounds = obj->getRenderWorldBox();

			// Generate the 8 bounding points of the box.
			Point3F pts[8];
			U32 i = 0;
...
...
...
			if (botright.x > getWidth() - 5) botright.x = getWidth() - 5;
			if (botright.y > getHeight() - 5) botright.y = getHeight() - 5;

			// If the object has a name, we will allow it to be selected
			if (obj->getShapeName()) 
			{
				// Draw!!
				drawTargetingRect(topleft, botright, 20.0f, mOutlineColor);
				drawName(topleft, obj->getShapeName(), 1.0f);
			}
Then after all that, add:
else
				drawTargetingRect(topleft,botright,20.0f,mOutlineColor);
#7
07/26/2008 (1:28 pm)
Can anyone give an example of how this could be implemented? This looks like what what I've been looking for--a way of highlighting objects within range that the player can interact with, similar to the mechanism in the adventure game, Dreamfall: Longest Journey. I've compiled and added to my playgui.gui; I can see that it is instantiated with code like "PlayGui.getObject(%i)", but I don't see it working. I know I must be missing something important...

Never mind... I figured it out.