Game Development Community

Now Getting on to 3D

by Jamie McGlynn · in Torque 3D Beginner · 02/05/2013 (11:57 am) · 9 replies

Hi again guys,

My starting project's 2D drawing and window behavior assignments (window title / resizing etc) are now working, and now I'm now focussing my attention on the 3D aspects.

I know that the GameTSCtrl object acts as the master container for objects in a 3D environment, however Torsion says one or both of these when I tried adding a "Sun", "GroundPlane" and "SkyBox" objects to my GameTSCtrl:
onLightManagerActivate: Unknown command.
onLightManagerDeactivate: Unknown command.
I know that "setLightManager" has some preliminary effects as this was one of two lines of code that was preventing the GUICanvas from initialising properly in my previous thread, but am I missing something?

If it helps, this is what is in my code:
$productTitle="My Game";$productCopyright="(c) 2013 "@$productTitle@" Software Foundation, All Rights Reserved";
new GuiControlProfile(GuiDefaultProfile);
new GuiControlProfile(GuiToolTipProfile);
new RenderPassManager(DiffuseRenderPassManager);

exec($path@"materials.cs");
exec($path@"weather.cs");
new GuiCanvas(WindowMain);
WindowMain.setWindowTitle($productTitle);
setLightManager("Basic Lighting");
WindowMain.maximizeWindow();

new GameTSCtrl(GuiFrame){
	extent="800 600";
	profile="GuiDefaultProfile";

	//Common 3D objects
	new Sun();
	new SkyBox();
	new GroundPlane();

	//Title Screen Objects
	new GuiBitmapCtrl(){bitmap=$path@"img-logo.png";extent="500 300";horizSizing="right";position="5 5";vertSizing="bottom";};
	new GuiBitmapCtrl(){bitmap=$path@"img-engine.png";extent="300 100";horizSizing="right";position="0 500";vertSizing="top";};

};WindowMain.setContent(GuiFrame);
AMMENDMENT: Just so that nobody gets confused, the $path is something im using to ease the file referencing, it's value is "content/" which is just a folder sitting next to the Torque EXE and DLL.

About the author

Recent Threads

  • Me Getting Started

  • #1
    02/05/2013 (12:02 pm)
    I think onLightManagerActivate and onLightManagerDeactivate are probably callbacks to get "something" those objects need. You may search through the original TS codebase to see if those are defined.

    It might also have something to do with advanced lighting. Maybe try changing the light manager to see if this makes a difference.

    When in doubt though get the full template project and search through scripts.
    #2
    02/15/2013 (10:16 am)
    I've spent a few days looking at the default templates, but i'm just constantly getting drowned with so many file redirections (i.e. "#include" and "exec"). These template are REALLY user-unfriendly ones, i hate to say, nor can I find ANYTHING meaningful that meets up with that you said.

    I did try changing the mode from Basic to Advanced as you said, but nothing happened and I did guess this would happen. But I wouldn't have been able to notice this anyways because all i'm getting is a magenta-coloured window with just a pair of title screen graphics.

    I also tried performing a "text search" for the criterias "onLightManagerActivate" and "onLightManagerDeactivate" on the four templates that accompanied torque when i downloaded, no results were returned.

    I REALLY have no clue whatsoever on what i'm looking for. I HAD hoped Torsion would help me out, but the really vague details has just diverted me from one brick wall to another.
    #3
    02/15/2013 (12:19 pm)
    Quote:
    I did try changing the mode from Basic to Advanced as you said, but nothing happened and I did guess this would happen.
    Are you executing the necessary scripts for the lighting manager? Guessing by the error messages and the described symptoms then no you haven't.

    Quote:
    But I wouldn't have been able to notice this anyways because all i'm getting is a magenta-coloured window with just a pair of title screen graphics.
    Your DefaultGuiProfile needs to be filled out, all you are doing is creating an empty container of data with that name. You are then overlaying the "title screen graphics" on top. All gui controls inherit default properties from the default or some other profile. Expected behavior.

    Quote:
    I also tried performing a "text search" for the criterias "onLightManagerActivate" and "onLightManagerDeactivate" on the four templates that accompanied torque when i downloaded, no results were returned.
    Look again: core/scripts/client/lighting.cs

    Anyone who ever attempts a minimalist approach to executing Torque will face these types of hurdles. Most of what you need can be found in the core script directory. Just keep in mind that certain subsystems use script as an interface with the engine.

    I would recommend learning how Torque operates through the existing template(s) -- the Empty Template would probably be the simplest even though it too is still a bit bloated -- just so you learn what the necessary bits are before taking the minimalist approach. Torque is not an API or an SDK, it is a game engine with example projects in a game prototype format to get you started.
    #4
    02/15/2013 (12:46 pm)
    You are exceeding the limits of my experience.

    ...and yes, I get lost trying to navigate the scripts.
    #5
    02/15/2013 (9:56 pm)
    @Jamie,
    I feel your pain as to trying to figure things out. This is the way doing anything is at times. It is that pain right before you discover how things work. I am feeling that pain right now trying to blindly figure out the rendering pipeline for custom rendering using FFT. I have had some success, but I am still getting stuck on minor things due to a bad mental model. I know time, experimentation, and struggle will reveal all. But I still feel that pain. :)

    One thing to watch out for is "packages". They are chunks of code that when activated replace other function calls with other calls. They work in a stack manner. Also, do you have a copy of the Torque Script reference? That can help. It is somewhere at GG website. Just search for Torque Script ref, or pdf or something.

    One thing is you may want to treat the TSCtrl as a sub control of a main window for learning. Then you can place buttons to try code out. I would also setup a separate script that you edit for testing. Then make a button the compiles that script so you can see changes in game.

    Also, look at the game loading script in the full/minimal templates. It shows how objects are loaded into a scene using the multistage loading. I still have trouble getting my head around that part. The book "3D Game Programming All in One" by Kenneth Finney covers the mission load process really well. It is a bit dated on the book, but it does cover the concepts quite well.

    As you discover this look at condensing the knowledge you gain into a resource. That way the next person will have an easier time.

    Some script ref:
    docs.garagegames.com/torque-3d/reference/index.html

    There was at one time for TGE a minimal app/gui series that might be helpful. It is dated, but it may cover some of these concepts such as loading things, and what does what. A game engine is a complicated animal and can be just as complicated to train to do your bidding.

    Keep asking questions and sharing knowledge and others will do in kind.

    Edit:
    I found it!
    www.garagegames.com/community/resources/view/5091
    It covers mostly gui stuff, but it should help with your understanding. Now this was written for TGE which is a different game engine (older), but a lot of the concepts should be similar. ie, it will include head scratching.
    #6
    02/21/2013 (10:46 am)
    Quote:
    I would recommend learning how Torque operates through the existing template(s) -- the Empty Template would probably be the simplest even though it too is still a bit bloated -- just so you learn what the necessary bits are before taking the minimalist approach. Torque is not an API or an SDK, it is a game engine with example projects in a game prototype format to get you started.
    Michael, can I please underline that I am nowhere near as knowleable as you are in regards to torque, and I would appreciate it if you would communicate without using enigmatic wording, and to not keep redirecting me to places i've already said i've looked at in previous posts!
    function onLightManagerActivate(%lmName){$pref::lightManager=%lmName;};
    Frank, I think this is what is causing the problem, but i inserted it just before the "setLightManager("Basic Lighting");" line, the engine still crashes, but this time, without any errors whatsoever showing up in Torsion's log. My guess was that if this was declared before the call for this function/procedure, it would rectify it.
    #7
    02/21/2013 (11:29 am)
    Ok - the thing is, if you read core/scripts/client/lighting.cs you'd notice a few things. I noticed that it is not executed in your script at the head of this post. Here it is again, for your re-perusal:

    function initLightingSystems()
    {
       echo( "n--------- Initializing Lighting Systems ---------" );
    
       // First exec the scripts for the different light managers
       // in the lighting folder.
       
       %pattern = "./lighting/*/init.cs";   
       %file = findFirstFile( %pattern );
       if ( %file $= "" )
       {
          // Try for DSOs next.
          %pattern = "./lighting/*/init.cs.dso";
          %file = findFirstFile( %pattern );
       }
       
       while( %file !$= "" )
       {      
          exec( %file );
          %file = findNextFile( %pattern );
       }
       
       // Try the perfered one first.
       %success = setLightManager( $pref::lightManager );
       if ( !%success )
       {
          // The perfered one fell thru... so go thru the default
          // light managers until we find one that works.
          %lmCount = getFieldCount( $lightManager::defaults );
          for ( %i = 0; %i < %lmCount; %i++ )
          {         
             %lmName = getField( $lightManager::defaults, %i );
             %success = setLightManager( %lmName );
             if ( %success )
                break;
          }
       }
       
       // Did we completely fail to initialize a light manager?   
       if ( !%success )
       {
          // If we completely failed to initialize a light 
          // manager then the 3d scene cannot be rendered.
          quitWithErrorMessage( "Failed to set a light manager!" );
       }
          
       echo( "n" );
    }
    
    //---------------------------------------------------------------------------------------------
    
    function onLightManagerActivate( %lmName )
    {
       $pref::lightManager = %lmName;
       echo( "Using " @ $pref::lightManager );
       
       // Call activation callbacks.
       
       %activateNewFn = "onActivate" @ getWord( %lmName, 0 ) @ "LM";   
       if( isFunction( %activateNewFn ) )
          eval( %activateNewFn @ "();" );
    }
    
    //---------------------------------------------------------------------------------------------
    
    function onLightManagerDeactivate( %lmName )
    {
       // Call deactivation callback.
       
       %deactivateOldFn = "onDeactivate" @ getWord( %lmName, 0 ) @ "LM";
       if( isFunction( %deactivateOldFn ) )
          eval( %deactivateOldFn @ "();" );
    }

    I know you didn't want to be asked to read things that you had already read, but seriously; if you read and understand this then you know that you have initLightingSystems() that is called and it runs through several different folders that contain the various initialization scripts for the different lighting systems. Since your "search of the entire engine scriptbase" didn't turn up onLightManagerActivate() I can only assume that you have deleted these scripts. Undo that heinous mistake now. If you have simply moved them, then ensure that they are properly loaded somewhere - but unless you moved them into a folder that is not included in the torsion project structure the function should still have shown up in the search.
    #8
    02/21/2013 (10:10 pm)
    Quote:enigmatic wording
    That would be called jargon of game development and the Garage Games community. If you intend to solicit any help from people in any organization it would be good to learn the jargon used within that community. It would also be good to take heed to Michael's words. He is one of the most knowledgeable people here and he only has so much time to help people.

    BTW, when searching the forums I often read the same words many, many times before what is being said is interpreted by my mind at times. This is a skill every programmer must learn. If someone says something you don't understand then ask for a clarification of what is not understood. I do this all the time because I miss understand things all the time.
    #9
    02/25/2013 (10:07 am)
    Oh, one thing. You have to explicitly load the Torsion project for the engine to be able to search properly. There is one available with the MIT version.