Quick Guide to Getting 3D Assets into Torque X
by John Kanalakis · in Torque X 2D · 01/22/2008 (11:14 pm) · 12 replies
By popular request, here's a quick guide for getting your 3D art assets into a Torque X game, using the current Torque X 1.5 Beta. In this example, I will create a static 3D model in 3DS Max, export it as a DTS model, bring it into XNA Game Studio Express, and then add it into a brand new Torque X game. I'll post it into TDN once I get a chance.
1. Creating the 3D Model
a. Start 3D Studio Max.
b. Open the reference shape and adopt the file's unit scale. I use a reference shape to give me a consistent sense of player scale for creating players and building corridors. Go ahead and delete the reference box as needed.
c. Use 6 boxes to create basic humanoid figure as shown below.
d. Rename each box. They can not end with a number. Change the names to something like: Body, Head,LeftArm,RightArm, Left Leg, Right Leg.
e. Go into the Schematic View and change the hierarchy so that all appendages of the model become children to the Body box as shown below.
f. Open the Material Editor, select a bitmap file. Try to rename the texture file to match your shape's name before importing it. For example, if your player shape will be called Player.max (and eventually Player.dts), then name the texture to Player.png to match.
2. Exporting the 3D Model
a. Setup the shape for export. Select the Body parent node and open the DTS Exporter. With the Body node selected, click the Quick Setup button as shown below. TheDTS Exporter I use can be downloaded from here. Note: this is the Dark Industries Exporter for 3DS Max 7 & 8. If you are looking for an exporter for 3DS Max 9, you will need to know if you are in 32 or 64 bit mode.
b. Verify the new shape hierarchy in the Schematic View

c. Select all of the boxes that make up the shape (Body,Head,Arms,Legs) and click the Quick Export button.
Set the filename consistent with the texture file, for example Player.dts
d. Preview the exported shape in Torque ShowTool (highly recommended). This verifies that the export was succesful and that the texure, rigging, and nodes are all where you expect them to be.

1. Creating the 3D Model
a. Start 3D Studio Max.
b. Open the reference shape and adopt the file's unit scale. I use a reference shape to give me a consistent sense of player scale for creating players and building corridors. Go ahead and delete the reference box as needed.
c. Use 6 boxes to create basic humanoid figure as shown below.
d. Rename each box. They can not end with a number. Change the names to something like: Body, Head,LeftArm,RightArm, Left Leg, Right Leg.
e. Go into the Schematic View and change the hierarchy so that all appendages of the model become children to the Body box as shown below.
f. Open the Material Editor, select a bitmap file. Try to rename the texture file to match your shape's name before importing it. For example, if your player shape will be called Player.max (and eventually Player.dts), then name the texture to Player.png to match.
2. Exporting the 3D Model
a. Setup the shape for export. Select the Body parent node and open the DTS Exporter. With the Body node selected, click the Quick Setup button as shown below. TheDTS Exporter I use can be downloaded from here. Note: this is the Dark Industries Exporter for 3DS Max 7 & 8. If you are looking for an exporter for 3DS Max 9, you will need to know if you are in 32 or 64 bit mode.
b. Verify the new shape hierarchy in the Schematic View

c. Select all of the boxes that make up the shape (Body,Head,Arms,Legs) and click the Quick Export button.
Set the filename consistent with the texture file, for example Player.dts
d. Preview the exported shape in Torque ShowTool (highly recommended). This verifies that the export was succesful and that the texure, rigging, and nodes are all where you expect them to be.

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.
#2
01/23/2008 (3:41 am)
Jesus John! You're a machine! More great work as usual. Thanks so much for doing this.
#3
01/23/2008 (7:04 am)
Very, very cool stuff!
#4
01/23/2008 (10:11 pm)
John- Please quit trying to kill us with awesomeness : )
#5
John K.
01/23/2008 (11:32 pm)
Davey, I thought for sure you would be laughing at my cheesy sample model...the ultimate in 'developer-art'.John K.
#6
01/24/2008 (3:16 am)
Nah, we love gimp-man!
#7
01/24/2008 (10:23 am)
Thank you
#8
05/14/2008 (5:06 pm)
This works great. Any chance you could add a tutorial on how to use 3D animations from the mesh? The FPS Demo is way to complicated and bloated to figure it out.
#9
I am trying to run this example in my xbox 360 (in windows it works just fine), but I get an UnauthorizedAccessException in:
//create the render component
T3DTSRenderComponent componentRender = new T3DTSRenderComponent();
------> componentRender.ShapeName = @"data\shapes\player\player.dts";
Is there anything wrong in my xbox connection configuration? is some engine issue?
Any idea will be welcome.
Thanks a lot,
Kique
This is the Call Stack:
mscorlib.dll!System.IO.__Error.WinIOError(int errorCode = -2147483644, string str = "T:\\584E07D1\\data\\shapes\\player\\player.dts") + 0x9a bytes
mscorlib.dll!System.IO.FileStream.FileStream(string path = "data\\shapes\\player\\player.dts", System.IO.FileMode mode = Open, System.IO.FileAccess access = Read | Write, System.IO.FileShare share = Read, int bufferSize = 128, bool useAsync = false, string msgPath = "player.dts") + 0xe2 bytes
mscorlib.dll!System.IO.FileStream.FileStream(string path = "data\\shapes\\player\\player.dts", System.IO.FileMode mode = Open) + 0x1d bytes
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.T3D.T3DTSRenderComponent.ShapeName.set(string value = "data\\shapes\\player\\player.dts") + 0x2f bytes
> Game.exe!StarterGame3D.Game.CreatePlayer() Line 69 + 0xb bytes C#
Game.exe!StarterGame3D.Game.BeginRun() Line 101 + 0x6 bytes C#
Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Run() + 0x46 bytes
Game.exe!StarterGame3D.Game.Main() Line 44 + 0xa bytes C#
10/08/2008 (2:57 pm)
Hello all,I am trying to run this example in my xbox 360 (in windows it works just fine), but I get an UnauthorizedAccessException in:
//create the render component
T3DTSRenderComponent componentRender = new T3DTSRenderComponent();
------> componentRender.ShapeName = @"data\shapes\player\player.dts";
Is there anything wrong in my xbox connection configuration? is some engine issue?
Any idea will be welcome.
Thanks a lot,
Kique
This is the Call Stack:
mscorlib.dll!System.IO.__Error.WinIOError(int errorCode = -2147483644, string str = "T:\\584E07D1\\data\\shapes\\player\\player.dts") + 0x9a bytes
mscorlib.dll!System.IO.FileStream.FileStream(string path = "data\\shapes\\player\\player.dts", System.IO.FileMode mode = Open, System.IO.FileAccess access = Read | Write, System.IO.FileShare share = Read, int bufferSize = 128, bool useAsync = false, string msgPath = "player.dts") + 0xe2 bytes
mscorlib.dll!System.IO.FileStream.FileStream(string path = "data\\shapes\\player\\player.dts", System.IO.FileMode mode = Open) + 0x1d bytes
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.T3D.T3DTSRenderComponent.ShapeName.set(string value = "data\\shapes\\player\\player.dts") + 0x2f bytes
> Game.exe!StarterGame3D.Game.CreatePlayer() Line 69 + 0xb bytes C#
Game.exe!StarterGame3D.Game.BeginRun() Line 101 + 0x6 bytes C#
Microsoft.Xna.Framework.Game.dll!Microsoft.Xna.Framework.Game.Run() + 0x46 bytes
Game.exe!StarterGame3D.Game.Main() Line 44 + 0xa bytes C#
#10
10/10/2008 (2:17 am)
It's an engine issue. maybe you can resolve it if you have PRO...the problem is that the dts file is not accessed readonly, which is not allowed on Xbox. You can change it with the source, there is a thread in the PRO Forums about it.
#11
Thanks for the guide!
03/24/2009 (1:45 pm)
John - you rock! My goal is to be similar to you in the next 5-6 years =} Owning a small gaming company and writing books.Thanks for the guide!
#12
05/12/2009 (7:04 pm)
So can i then open this in Torque 2d and it would be in the scrollers? or would i have to go farther?
Associate John Kanalakis
EnvyGames
Time to create the new Torque X project.
a. Start XNA Game Studio Express, select New Project and then pick the StarterGame 3D template.
b. Add the shape and texture to the project. From the Solution Explorer, expand the data folder and create a new sub-folder called shapes. Then, create another subfolder under that one, named Player. Next, copy your player.dts and player.png files into the new \data\shapes\player folder. Then, from within Game Studio Express, expand the folder structure and select the new player sub-folder. Next, right-click and select Add + Existing Item. Navigate to the player folder and select the "All Files(*.*)" file type filter. Select both the player.dts and player.png files.
c. Change the player.dts properties. Select only the Player.dts file and then open the properties view. Change the "Build Action" to Content and set the "Copy to OutputDirectory" property to Copy if newer.
d. Rebuild the Project
4. Loading the 3D Shape in Code
Time to add some code to load the 3D shape into the game. Open the Game.cs file and add the following method. Be sure to add the necessary namespace reference at the top of the source file:
using Microsoft.Xna.Framework;
public void CreatePlayer() { //create the simple torque object TorqueObject objPlayer = new TorqueObject(); //create the render component T3DTSRenderComponent componentRender = new T3DTSRenderComponent(); componentRender.ShapeName = @"data\shapes\player\player.dts"; //create the scene component T3DSceneComponent componentScene = new T3DSceneComponent(); componentScene.Position = new Vector3(1024, 1024, 300); //add both of the components objPlayer.Components.AddComponent(componentRender); objPlayer.Components.AddComponent(componentScene); //register the object TorqueObjectDatabase.Instance.Register(objPlayer); }Now, all you have to do is call the CreatePlayer() method. Add the method call to the end of the BeginRun() method. For example:
protected override void BeginRun() { base.BeginRun(); SceneLoader.Load(@"data\levels\levelData.txscene"); // all 3D scene views must have a camera set GUISceneview sceneView = TorqueObjectDatabase.Instance.FindObject<GUISceneview>("DefaultSceneView"); T3DCameraComponent camera = TorqueObjectDatabase.Instance.FindObject<T3DCameraComponent>("CameraComponent"); sceneView.Camera = camera; CreatePlayer(); }That's it. Build and Run the game to see the new player.
You can download the sample project from here.
John K.