Game Development Community

what happened when selecting an item in WorldEditor/Creator/Static shape

by henry0henry · in Torque Game Engine · 07/27/2009 (4:29 am) · 2 replies

I am learning TGE now.One problem confused me for a long time ,which is how to create a static shape in front the camera just like Creator does when selecting an item in the treeview. I digged into the source codes of the mission editor and got some clue.

Below is what I found:

in
function Creator::init( %this )
there are codes :
%create = "TSStatic::create(\"" @ %file @ "\");";
      %this.insertItem( %parentId, fileBase( %file ), %create,"TSStatic" );

in the onSelect callback fuction
function Creator::onInspect(%this,%obj)
{
   if(!$missionRunning)
      return;
   
  %objId = eval(%this.getItemValue(%obj));

   // drop it from the editor - only SceneObjects can be selected...   
   Creator.removeSelection(%obj);
   
   EditorTree.clearSelection();
   EWorldEditor.clearSelection();
   EWorldEditor.selectObject(%objId);
   EWorldEditor.dropSelection();
}
in the obove callback function ,it calles TSStatic::create ,which is defined as this
function TSStatic::create(%shapeName)
{
   %obj = new TSStatic() 
   {
      shapeName = %shapeName;
   };
  return(%obj);
}
those are all for creating static shape,but I can't see how it does to put the shap just in front of the screen(the observer).

About the author

Recent Threads


#1
07/27/2009 (6:40 am)
It's done in the source code.

The line "EWorldEditor.dropSelection();" you show above calls the consolemethod that causes the world editor to move the currently selected object, your newly created object, to the center of the screen (or to the origin, or below the camera, or snapped to the ground, etc. depending on your settings).
#2
07/27/2009 (6:42 pm)
thanks for your help.