Game Development Community

StarterGame 3D Template Request

by John Kanalakis · in Torque X 2D · 12/15/2007 (7:01 am) · 6 replies

I would like to request that the following be added to the default levelData.txscene file for the StarterGame 3D template. This way, that great looking terrain is actually solid instead of being a pass-through mirage. I would add the RigidComponent to the terrain in code, but "components can't be added to registered objects". By adding these few lines, every new 3D game has a terrain capable of holding rigid shapes.

add the following under the tag under
<RigidComponent type="GarageGames.Torque.T3D.T3DRigidComponent">
  <RenderCollisionBounds>false</RenderCollisionBounds>
  <CollisionShapes>
	  <CollisionShape>
		  <Shape type="GarageGames.Torque.T3D.RigidCollision.CollisionXTerrainShape" />
	  </CollisionShape>
  </CollisionShapes>
  <GravityScale>0.0</GravityScale>
  <Immovable>true</Immovable>
  <RigidManager nameRef="RigidManager" />
  <RigidMaterial type="GarageGames.Torque.T3D.RigidCollision.RigidMaterial">
	  <Restitution>0.0</Restitution>
	  <KineticFriction>1.0</KineticFriction>
	  <StaticFriction>1.0</StaticFriction>
  </RigidMaterial>
</RigidComponent>

add the following under the tag
<RigidManager type="GarageGames.Torque.T3D.RigidCollision.RigidCollisionManager" name="RigidManager" />

John K.

About the author

John Kanalakis is the owner of EnvyGames, an independent game development studio in Silicon Valley that produces games and tools for Xbox 360, Windows, and the Web.


#1
12/16/2007 (12:54 pm)
John,

Is there a basic recommended workflow for bringing a fbx or dts object into the 3d starter game template? I figure that the product is so new that one hasn't been created yet.

Thanks,
Jeff
#2
12/16/2007 (2:07 pm)
As far as a formally recommended workflow, I don't think there is one yet. However, there seems to be three valid approaches to bringing 3D assets into a Torque X scene.

1. Create the objects and add them into the scene manually in code. For example:
public void CreatePlayer()
{
    TorqueObject objPlayer = new TorqueObject();
 
    T3DTSRenderComponent componentRender = new T3DTSRenderComponent();
    componentRender.ShapeName = @"data\shapes\player\player.dts";
 
    T3DSceneComponent componentScene = new T3DSceneComponent();
    componentScene.Position = new Vector3(1024, 1024, 300);
 
    objPlayer.Components.AddComponent(componentRender);
    objPlayer.Components.AddComponent(componentScene);
 
    TorqueObjectDatabase.Instance.Register(objPlayer);
}

2. Create the objects and add them into the scene by manually editing the levelData.txscene file. For example:
<Player type="GarageGames.Torque.Core.TorqueObject" name="Player">
<IsTemplate>false</IsTemplate>
<ObjectType>
<object objTypeRef="Player" />
</ObjectType>
<Components>
<RenderComponent type="GarageGames.Torque.T3D.T3DTSRenderComponent">
<ShapeName>data\shapes\player\player.dts</ShapeName>
</RenderComponent>
<SceneComponent type="GarageGames.Torque.T3D.T3DSceneComponent">
<Position>
<X>1024</X>
<Y>1024</Y>
<Z>300</Z>
</Position>
</SceneComponent>
</Components>
</Player>

3. A very complex process that involves copying the TGE Mission Editor into your Game project directory, then using it to layout your 3D objects and Terrain. Then, creating a reference template XML file (a .txscene file with additional "Templates" section for reference), building the provided ConvertTGEMis project, and then running it. When it runs, you can point to the TGE Mission file (.mis) and your custom template (.txscene) to produce a new final .txscene file that you can load from Torque X. This is a very long process filled with things that can go wrong - plus, its not easy to create the template file - and it's one way only... from a .mis to a .txscene file (no editing).

The first two methods are the most practical and they workwell. But, they require manual positioning of the 3D elements. As described, they specifically work with the DTS model format - to work with the FBX model format, you should replace the T3DTSRenderComponent with T3DXNARenderComponent.

Sorry that it's not really a basic 3D solution, but I'm sure some better tools are coming.

John K.
#3
02/02/2008 (1:33 pm)
I agree with John on this. If you are going to put a terrain in the scene by default. You might as well add the rigid component. My current problem is I'm trying to make my first object in Torque. So I made an object added a scene and render component. Everything is fine. I can see what I put in on screen. So I add a T3DRigidComponent and when I add this one my object disappears. I thought maybe it's falling through the world so I made it Immovable, but no luck. Here is the code:

// Other components above ^
            CollisionSphereShape sphere = new CollisionSphereShape();
            T3DRigidComponent componentRigid = new T3DRigidComponent();            
            sphere.Radius = 10.0f;  // asumming meters here?
            componentRigid.CollisionBody.AddCollisionShape(sphere);
            componentRigid.RigidManager = TorqueObjectDatabase.Instance.FindObject<RigidCollisionManager>("RigidManager");
            // is this all I have to do to see the collision bounds or do I have to do something to the rigid manager or renderer itself.
            componentRigid.RenderCollisionBounds = true;  
            componentRigid.ResolveCollisions = true;
            //componentRigid.Immovable = true;  Tried this...no luck
            componentRigid.GravityScale = 1.0f;
            obj.Components.AddComponent(componentRigid);

            //register the player object
            TorqueObjectDatabase.Instance.Register(obj);

So if I comment out the addcomponent call. I see the object. Anyone got any ideas? My txscene has what john describes above.

Awesome,
Troy
#4
04/08/2008 (1:46 pm)
Does anyone have any insight as to Troy's post?
#5
04/08/2008 (6:22 pm)
No one yet:) I did notice that if I made the object via xml that the object loaded fine. But I don't want to have to fall back on this. It would be great to get some answers.
#6
04/14/2008 (9:04 pm)
Ok, so I got the Pro edition of TorqueX. Debugged what I was doing wrong. I wasn't giving the Rigid comp the scenegroupname. so it wouldn't make my object. So that problem is solved.

-Troy