Game Development Community

dev|Pro Game Development Curriculum

Torque Lighting Kit - GuiObjectView

by John Kabus (BobTheCBuilder) · 03/07/2006 (11:22 am) · 26 comments

Download Code File

(This resource is designed for TLK 1.4)
(anyone using TGE 1.5.x should use this resource instead: TGE 1.5.x - Bonus Resource Bundle)



What are the changes?

This updated GuiObjectView uses it's own LightManager, allowing it to be used in-game without affecting the scene lighting, and also resolves a crash that occurred when exiting a mission.

The new GuiObjectView also supports env mapping on displayed models.


How to install it?

Just unzip the files into the 'engine/gui/game' directory, add them to your project, then rebuild your project - and your done!


How to use it?

Same as the previous GuiObjectView resources. For example; create a GuiObjectView control on your game's main menu, give it the name MainMenuObjectView, and exec this code in the main menu's onWake event:

MainMenuObjectView.setObject("name", "starter.fps/data/shapes/player/player.dts", 0, 0);

Assuming "starter.fps/data/shapes/player/player.dts" is a valid path to the player dts file, the player should appear when the main menu is displayed.

The only new script method is setEmapTexture, which accepts the path to the texture used for env mapping.

Enjoy!

-John Kabus
Page «Previous 1 2
#1
03/07/2006 (11:14 am)
Very cool John, thanks. :)
#2
03/07/2006 (10:25 pm)
Any chance someone can consolidate this one with the 'consolidated' one that has the old TLK additions in it?
#3
03/08/2006 (4:23 am)
Why whats missing from this version? This contain all of the previous changes (as of TLK 1.3.5) and env mapping. It should be the 'definitive' version.
#4
03/08/2006 (4:29 am)
thanks John!
as soon as I find free time, I'll put it into our project.. can't wait to play with it ;)
#5
03/08/2006 (2:28 pm)
Yes! One that actually WORKS!!!
#6
03/08/2006 (2:49 pm)
I'm talking about this one www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9617 that has like 3 different versions, including the old TLK version, implemented into it. I'm askin if this version has the other 2 ones besides the old TLK in it or do we have to consolidate them again?
#7
03/11/2006 (3:40 pm)
Yes, even the previous light-enabled GuiObjectView supported all of the others, but it wasn't in pre-packaged in code form - I think thats all the newer resource did was to apply the light-enabled GuiObjectView instructions to the previous resource.

This resource contains all of the previous GuiObjectView resources plus a TLK specific lighting implementation.
#8
03/13/2006 (11:56 pm)
John, thanks a lot for this resource! Finally my problem with "black" objects in guiObjectView went off.. Now it looks right the way it should be!
Thanks to SynapseGaming team from AfterWorld team ;)
#9
03/17/2006 (2:06 pm)
John, I don't mean to be ungrateful for your posting your resources here, but I couldn't help noticing that you've included the lighting pack license agreement in this pack. However, since you only own your changes to the GuiObjectView, you can't really assert ownership or control over the rest of it. I don't want to get into a huge copyright thread here, but I think it bears mentioning. Small changes like this really shouldn't come with extensive license agreements anyway, IMHO, other than perhaps a simple grant of use.
#10
03/17/2006 (2:32 pm)
Philip,

The copyright notices of the original authors are still intact and all of the TLK related code blocks are very clearly marked. The license applies only to the TLK related code, just as the license that comes with TLK only applies to the TLK code and not to the entire Torque source.

The license was included to make it clear that this is a private TLK resource and to prevent it from being posted or re-resourced in a non private area.

-John
#11
04/01/2006 (8:42 am)
This is an awesome resource, thanks for making it available. Just a quick note:

I'm using it for an inventory window, but I've found that it's hard to have objects show up at the right zoom distance. Some of the objects in my game are much larger than others, so when some objects appear in the inventory window they are either zoomed in too far, or they are so small you can hardly see them.

GuiObjectView has the ability to zoom the camera in and out with the right mouse button, which works great, but I'd rather not have to force the player to do that.

The fix I made for this is to expose the mOrbitDist variable to script. Then, I create a dynamic variable for each inventory object which stores the ideal camera orbit distance for that object. Now, when I load an object into an individual GuiObjectView instance, I also set mOrbitDist to the ideal orbit distance for that object before calling "setObject".

Thought I'd throw that out there for anyone who might have the same issue.

(edit for clarity)
#12
04/23/2006 (2:35 pm)
@ Rubes Hi :) sorry for being a dumbarse, but can you explain a bit more about how you "expose" the mOrbitDist to the scripting engine?

This is deffinately something I am looking for as I have the same issue as you do with varying sizes in an inventory window.

Thanks in advance

Graham
#13
04/23/2006 (8:30 pm)
@Graham: No problem. In GuiObjectView.cc, find the function GuiObjectView::initPersistFields(). This function tells the engine which C++ variables to make available to scripts. If you add the following lines shown in bold:

void GuiObjectView::initPersistFields()
{
	Parent::initPersistFields();

	addField("lightDirection", TypePoint3F, Offset(sgLightDirection, GuiObjectView));
	addField("lightColor",     TypeColorF,  Offset(sgLightColor,     GuiObjectView));
	addField("ambientColor",   TypeColorF,  Offset(sgAmbientColor,   GuiObjectView));
	addField("emapAmount",     TypeF32,     Offset(sgEmapAmount,     GuiObjectView));
[b]	addField("cameraRot",	   TypePoint3F, Offset(mCameraRot,	 GuiObjectView));
	addField("orbitDist",	   TypeF32,	Offset(mOrbitDist,	 GuiObjectView)); [/b]
}

...then you should be able to access the mCameraRot and mOrbitDist variables in script, using the fields cameraRot and orbitDist, respectively.

So if you have a GuiObjectView object called "myGuiObjectView", you can set the orbit distance by calling myGuiObjectView.orbitDist = ##.

Hope that makes sense.
#14
04/24/2006 (6:13 pm)
Thanks Rubes.. but I must be doing something wrong.

in my GuiObjectView declaration which is generated for each inv item, I added orbitDist = "x"; where x = lots of different integer values but no matter what value, the object size is always overriden to the same setting. Is there something in GuiObjectView.cc I should comment out as well which is recalculating this?

Regards

Graham
#15
04/24/2006 (6:50 pm)
I don't recall if the GuiObjectView resets the orbitDist once you add a DTS object to it...one thing to try is to load the GuiObjectView with a DTS object, and then in the console type myGuiObjectView.orbitDist = #, where "myGuiObjectView" is the name of your object and # is a number...I would try a number between 1 and 3 to start with, just to see.

That should tell you if it's working at all.
#16
04/25/2006 (3:39 am)
Thanks Rubes :)

okay lesson 1, never underestimate the stupidity of the newb :) I set the default one to orbitdist, but then generated a new one programatically for each item, and forgot to include the new variable on each generated one, just picked up the default. It works great now. Thanks so much :) New lesson learned for me, and another issue solved and written off the list.

Thanks again.

Regards

Graham
#17
05/07/2006 (4:29 am)
I can't find the main menu's onWake function, where is it? I can only see loadmainmenu
Edit: Ill just create one myself then
#18
05/16/2006 (6:49 am)
Dont know it is a bug or not?
I create select character gui by guibobjectview and try to switch 2 shapes with animation.. after few times changing shape I received an error "TSThread::selectKeyFrame:: Invalid keyframe" at tsthread.cc line 85.

It only happens when I load the object view gui after calling command "map_createServer();". If I load the object gui in main menu gui or any gui before callling above command, the error won't happen.
#19
07/09/2006 (3:38 am)
I am trying to load the player.dts into a simple dialog in game right now. I doesn't seem to be working right and gives me an "Fatal: (c:\work\ham\engine\ts\tsthread.cc @ 85) TSThread::selectKeyFrames: invalid keyframe!". Loading the default player dts.

My UI definition:
.....
   new GuiObjectView(view) {
       profile = "GuiDefaultProfile";
       horizSizing = "relative";
       vertSizing = "relative";
       position = "0 0";
       extent = "400 400";
       minExtent = "8 2";
       visible = "1";
       helpTag = "0";
       cameraZRot = "0";
       forceFOV = "0";
   };
....

My dialog onWake function:
// Set main object
   view.setObject("player", "starter.fps/data/shapes/player/player.dts", 0, 0);

   // Load dsq's
   view.loadDSQ("player","starter.fps/data/shapes/player/player_root.dsq");
   view.loadDSQ("player","starter.fps/data/shapes/player/player_forward.dsq");
   view.loadDSQ("player","starter.fps/data/shapes/player/player_back.dsq");
   view.loadDSQ("player","starter.fps/data/shapes/player/player_jump.dsq");

   // Set animation
   view.setSequence("player", "root", 1);

Everything seems OK except when I try to activate the dialog...the assert pops up. I tried commenting out the "setSequence"..that doesn't help.

I comment all the "loadDSQ"'s and the object is displayed but with no textures.

I played around with it some more and so far:
1) It seems that you CANNOT use the same dts being used as the current player or it will cause the assert
2) You MUST specify the skin name in setObject 3rd parameter in full.(Doesn't load the default skin)
3) You can use the LoadDSQ's so long as you do not use the same dts

Odd?
#20
08/18/2006 (7:37 pm)
Awesome resource ... thankfully, it went into my TLK with no trouble at all :) Thanks, John!!
Page «Previous 1 2