Game Development Community

dev|Pro Game Development Curriculum

3D Wheel GUI (TGEA)

by Frank Bignone · 08/25/2008 (7:20 am) · 8 comments

Download Code File

This article includes the necessary code to implement a 3D Wheel Menu GUI which can display a list of texture around a 3D wheel and allow selection for a menu wheel system.


To include this inside your TGEA 1.7.1 game, first uncompress the 6 files available inside source/gui (put it inside your game folder source). Note: be sure that you can directly include file inside your game folder otherwise the include statements in the provided sources will not work.

Then to have the same effect, you can try to include the following Gui control as:
new Gui3DWheel(Menu3D) {
         canSaveDynamicFields = "0";
         Enabled = "1";
         isContainer = "0";
         HorizSizing = "relative";
         VertSizing = "relative";
         Position = "16 32";
         Extent = "338 250";
         MinExtent = "8 2";
         canSave = "1";
         Visible = "1";
         hovertime = "1000";
         Hiding = "none";
         HidingSpeed = "1";
         Grip = "10";
         GridStep = "10";
         Margin = "0 0 0 0";
         Padding = "0 0 0 0";
         AnchorTop = "1";
         AnchorBottom = "0";
         AnchorLeft = "1";
         AnchorRight = "0";
         cameraZRot = "0";
         forceFOV = "0";
         Orientation = "Horizontal";
         AngularSpeed = "45";
         SquareWidth = "10";
         SquareHeight = "10";
         Distance = "0.2";
         Tilt = "0";
         NbElements = "5";
         SelectedColor = "255 255 255 255";
         Unselectedcolor = "64 64 64 255";
      };

The important variables are:
Orientation = either "Horizontal" or "Vertical" to have an horizontal or vertical wheel
         AngularSpeed = Speed in degree / seconds for the wheel 
         SquareWidth = Width of the square on which textures are rendered
         SquareHeight = Height of the square on which textures are rendered
         Distance = positive / negative multiplier to be farther / closer to the wheel
         Tilt = Tilt angle of the wheel
         NbElements = Number of element in the wheel
         SelectedColor = Color multiplier for selected square (active menu option)
         Unselectedcolor = Color multiplier for un-selected square (not active menu)

After setting up this control, you need to pass it a list of textures that will be used by the control. To do so, you can add the following code inside the onWake method of this control:
function Menu3D::onWake(%this)
{
	%texLst = new GuiTexLst();
	%texLst.setTexture("scriptsAndAssets/data/gui/tst/tex-1.png", 0);
	%texLst.setTexture("scriptsAndAssets/data/gui/tst/tex-2.png", 1);
	%texLst.setTexture("scriptsAndAssets/data/gui/tst/tex-3.png", 2);
	%texLst.setTexture("scriptsAndAssets/data/gui/tst/tex-4.png", 3);
	%texLst.setTexture("scriptsAndAssets/data/gui/tst/tex-5.png", 4);
	%texLst.setTexture("scriptsAndAssets/data/gui/tst/tex-6.png", 5);
	%texLst.setTexture("scriptsAndAssets/data/gui/tst/tex-7.png", 6);	
	%this.setTextureLst(%texLst);
}

The use of a new object GuiTexLst is to be able to use this control with different provided of texture (for example in Pelorea we can use it to cycle around all our deck cards).

The control has few call-backs than you can use as follow:
function Gui3DWheel::onMouseEnter(%this)
{
	echo("[3D Wheel:" @ %this @ "] Enter");
}

function Gui3DWheel::onMouseLeave(%this)
{
	echo("[3D Wheel:" @ %this @ "] Leaving");
	%this.setSpin(0);
}

function Gui3DWheel::onSelection(%this, %sel)
{
	echo("[3D Wheel:" @ %this @ "] Selection " @ %sel);
}

The code inside onMouseLeave will stop wheel spinning when pointer is outside the control.
The code inside onSelection can be used for activating different actions depending on the user selection.

Enjoy it.

About 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.


#1
08/22/2008 (10:54 pm)
WOW!!! This is just awesome! Too bad I already have most of my GUI done or I would try to stick thins in there because it is just that cool. Well it looks like something to use in my next game.
#2
08/23/2008 (7:02 am)
This may actually be exactly what I need for my main menu!
#3
08/25/2008 (5:10 am)
Wicked! :)
#4
08/25/2008 (9:22 am)
I can think of an application or two immediately. Thanks for posting that!
#5
08/25/2008 (6:43 pm)
GAH! To many incentives to buy a license to TGEA and not enough money!
#6
09/07/2008 (11:12 am)
Very nice Frank.
#7
09/08/2008 (12:16 am)
I plan on trying this out! Thanks for sharing this!
#8
02/05/2009 (10:48 am)
This resource is great!

but I have some problem
When I turn on DRL, screen is splited
myschoollife.co.kr/bug/3d1.jpg