Torque 3D Game Development Cookbook is Now Available
by David Wyand · 01/30/2013 (7:32 am) · 26 comments
I am proud to announce that my Torque 3D Game Development Cookbook has recently been published.

When I started writing the book, the MIT licensed version of Torque 3D was only a concept, and the retail version of T3D 1.2 was all that was available. Therefore, the book is based on using Torque 3D from a TorqueScript and built-in editor perspective. It really is amazing how much can be done in Torque 3D without needing to touch the source code.
Since then Torque 3D has gone open source and we saw the release of v2.0 in December 2012. Through the magic of really fast book printing, I was able to make sure my book was updated for the 2.0 open source release, making this the most current Torque 3D book to date.
Note: One recipe in Chapter 2 makes use of the FPS Example template that is currently only available in the retail release of Torque 3D 1.2. However, the concepts in that recipe will easily carry over to all other projects, which has to do with placing decals.
Chapter 1: TorqueScript: The Only Script You Need to Know
Accessing delimited fields within a string
Iterating on words in a string list
Retrieving components of a variable using accessors
Iterating on objects in a SimSet or SimGroup collection
Getting a random object from a SimSet or SimGroup collection
Finding an object in a SimSet or SimGroup collection using its internal name
Executing a method on a SimSet or SimGroup collection
Creating a new SimObject instance
Creating a new internal name only SimObject instance
Creating a new Datablock object
Creating a new singleton
Extending a SimObject instance using the class property
Using a variable to access methods or properties of a SimObject instance
Using call() to call a variable method on a SimObject instance with arguments
Using call() to call a variable function with arguments
Using script arrays as dictionaries
Using ArrayObject and custom script sorting callbacks
Scheduling SimObject methods
Scheduling functions
Activating and deactivating a package
Chapter 2: Working with Your Editors
Setting up fogging of the level
How to cover seams and texture changes using decals placed in the World Editor
Copying the transform of an object to another in the World Editor window
How to change the material of an object in the World Editor
Setting up a glow mask using the Material Editor window
Using a convex shape as a zone
Setting zone-specific ambient lighting
Grouping adjacent zones together
Chapter 3: Graphical User Interface
Creating a password text edit box
Using pushDialog() and popDialog() and setting up the UI file to work with them
Displaying metrics (such as FPS) from the console
Displaying a list of all game objects
Displaying a level at the main menu
Dragging and dropping between two windows
Chapter 4: Camera and Mouse Controls
Locking and hiding the mouse while the right mouse button is down
Clicking on an object in the scene (client-side)
Clicking on an object in the scene (server-side)
Picking up an item in the scene while the mouse is locked and hidden
Changing the camera's view and control mode
Giving the camera smooth movement
Having the camera follow a path
Chapter 5: Your Graphics Evolved
Using the built-in video recording
Changing the material of a ShapeBase object using script
Building a custom material
Building a custom material using advanced lighting
Building a postFX
Chapter 6: Make That Sound Happen
Playing a quick 2D or 3D sound on all clients
Using SFXEmitter to create networked sound effects
Playing a sound on a ShapeBase object
Playing music while a level is loading
How to have a background sound for a level
How to have music change according to the mood
Triggering an event during sound playback
Chapter 7: Game Objects
Playing an animation sequence on a TSStatic class
Playing an animation sequence on a ShapeBase class
How to make it rain using a Precipitation object
Using the Lightning object to automatically create a thunderstorm
Using the TimeOfDay object to generate events
Chapter 8: Multiplayer Servers
How to start a dedicated server
What ports are needed to be open or forwarded for a multiplayer server
Passing arbitrary parameters from the client to the server
How to become an admin on a server
Kicking and banning people from the server
Stopping a server from restarting when the last player leaves
Accessing the server connection from the client
How to access all client connections from the server
Broadcasting a message to all clients and having it displayed in the center of the screen
Chapter 9: Importance of Networking
Sending a network event from the client to the server
Sending a network event from the server to the client
Connecting as a TCP client
Setting up a TCP server
Connecting as an HTTP client
Using an RSS feed for game news, message of the day, or other client messages
How to activate, deactivate, and use Telnet for console access
Chapter 10: Miscellaneous Gameplay Features
How to have a sprinting player use up energy
Enabling and disabling air control
How to jump jet
Adjusting the fire spread of a weapon
Changing the number of shots fired from a weapon
Making a weapon use energy rather than ammo
Finding objects in range
Using the message producer/consumer system
For most of these recipes I've gone into great detail about the topic. For example, in Chapter 5: Your Graphics Evolved I provide a list of all available texture samplers and constants when making your own custom materials. This information is only currently available by going through the source code. The same is true for the postFX recipe, as postFX have a different set of available texture samplers and constants.

Packt Publishing eBook and physical copies
Amazon.com physical copy
Amazon.com Kindle edition
Barnes & Noble physical copy
Thanks for reading!
- Dave

Introduction
In the Spring of 2012, I was contacted by Packt Publishing to write a cookbook-style book on Torque 3D. For those that don't know, a technical cookbook is very similar to a food cookbook. It is full of recipes of specific tasks or problem solutions, some short and some long.When I started writing the book, the MIT licensed version of Torque 3D was only a concept, and the retail version of T3D 1.2 was all that was available. Therefore, the book is based on using Torque 3D from a TorqueScript and built-in editor perspective. It really is amazing how much can be done in Torque 3D without needing to touch the source code.
Since then Torque 3D has gone open source and we saw the release of v2.0 in December 2012. Through the magic of really fast book printing, I was able to make sure my book was updated for the 2.0 open source release, making this the most current Torque 3D book to date.
Note: One recipe in Chapter 2 makes use of the FPS Example template that is currently only available in the retail release of Torque 3D 1.2. However, the concepts in that recipe will easily carry over to all other projects, which has to do with placing decals.
Table of Contents
Here is the complete recipe list for the book:Chapter 1: TorqueScript: The Only Script You Need to Know
Accessing delimited fields within a string
Iterating on words in a string list
Retrieving components of a variable using accessors
Iterating on objects in a SimSet or SimGroup collection
Getting a random object from a SimSet or SimGroup collection
Finding an object in a SimSet or SimGroup collection using its internal name
Executing a method on a SimSet or SimGroup collection
Creating a new SimObject instance
Creating a new internal name only SimObject instance
Creating a new Datablock object
Creating a new singleton
Extending a SimObject instance using the class property
Using a variable to access methods or properties of a SimObject instance
Using call() to call a variable method on a SimObject instance with arguments
Using call() to call a variable function with arguments
Using script arrays as dictionaries
Using ArrayObject and custom script sorting callbacks
Scheduling SimObject methods
Scheduling functions
Activating and deactivating a package
Chapter 2: Working with Your Editors
Setting up fogging of the level
How to cover seams and texture changes using decals placed in the World Editor
Copying the transform of an object to another in the World Editor window
How to change the material of an object in the World Editor
Setting up a glow mask using the Material Editor window
Using a convex shape as a zone
Setting zone-specific ambient lighting
Grouping adjacent zones together
Chapter 3: Graphical User Interface
Creating a password text edit box
Using pushDialog() and popDialog() and setting up the UI file to work with them
Displaying metrics (such as FPS) from the console
Displaying a list of all game objects
Displaying a level at the main menu
Dragging and dropping between two windows
Chapter 4: Camera and Mouse Controls
Locking and hiding the mouse while the right mouse button is down
Clicking on an object in the scene (client-side)
Clicking on an object in the scene (server-side)
Picking up an item in the scene while the mouse is locked and hidden
Changing the camera's view and control mode
Giving the camera smooth movement
Having the camera follow a path
Chapter 5: Your Graphics Evolved
Using the built-in video recording
Changing the material of a ShapeBase object using script
Building a custom material
Building a custom material using advanced lighting
Building a postFX
Chapter 6: Make That Sound Happen
Playing a quick 2D or 3D sound on all clients
Using SFXEmitter to create networked sound effects
Playing a sound on a ShapeBase object
Playing music while a level is loading
How to have a background sound for a level
How to have music change according to the mood
Triggering an event during sound playback
Chapter 7: Game Objects
Playing an animation sequence on a TSStatic class
Playing an animation sequence on a ShapeBase class
How to make it rain using a Precipitation object
Using the Lightning object to automatically create a thunderstorm
Using the TimeOfDay object to generate events
Chapter 8: Multiplayer Servers
How to start a dedicated server
What ports are needed to be open or forwarded for a multiplayer server
Passing arbitrary parameters from the client to the server
How to become an admin on a server
Kicking and banning people from the server
Stopping a server from restarting when the last player leaves
Accessing the server connection from the client
How to access all client connections from the server
Broadcasting a message to all clients and having it displayed in the center of the screen
Chapter 9: Importance of Networking
Sending a network event from the client to the server
Sending a network event from the server to the client
Connecting as a TCP client
Setting up a TCP server
Connecting as an HTTP client
Using an RSS feed for game news, message of the day, or other client messages
How to activate, deactivate, and use Telnet for console access
Chapter 10: Miscellaneous Gameplay Features
How to have a sprinting player use up energy
Enabling and disabling air control
How to jump jet
Adjusting the fire spread of a weapon
Changing the number of shots fired from a weapon
Making a weapon use energy rather than ammo
Finding objects in range
Using the message producer/consumer system
For most of these recipes I've gone into great detail about the topic. For example, in Chapter 5: Your Graphics Evolved I provide a list of all available texture samplers and constants when making your own custom materials. This information is only currently available by going through the source code. The same is true for the postFX recipe, as postFX have a different set of available texture samplers and constants.
Sample Chapter
Packt Publishing has a history of providing a sample chapter from each of their books. Chapter 6: Make That Sound Happen was chosen as the sample chapter you may all download and read right now. You can find it by clicking on the Sample Chapters tab on the Packt Publishing page for the book. This sample chapter is in black and white, while the eBook version of Torque 3D Game Development Cookbook has all images in color.
Where to Buy the Book
Here are some direct links for purchasing Torque 3D Game Development Cookbook:Packt Publishing eBook and physical copies
Amazon.com physical copy
Amazon.com Kindle edition
Barnes & Noble physical copy
Thanks for reading!
- Dave
About the author
A long time Associate of the GarageGames' community and author of the Torque 3D Game Development Cookbook. Buy it today from Packt Publishing!
#2
Ron
01/30/2013 (8:00 am)
Dave, as you know I already grabbed a copy and it's really great. Lays things out well and makes things I thought were confusing clear. Nice work!Ron
#3
01/30/2013 (9:33 am)
Congrats Dave!
#4
01/30/2013 (10:23 am)
Will defiantly be buying this ebook friday. I need more in the ebooks for torque
#5
01/30/2013 (11:25 am)
Going to pick this up when I have a chance.
#6
01/30/2013 (11:28 am)
Great release! Congrats!
#8
01/30/2013 (1:14 pm)
Going to read it tonight :)
#9
01/30/2013 (3:11 pm)
Congrats, Dave! A fantastic read!
#10
01/30/2013 (5:18 pm)
Way to go Dave! Lets push this to Amazon's best seller list! It certainly is a great read. Can't wait to get my hands on my copy.
#11
02/01/2013 (12:18 am)
Congrats. ..and by one of the best to ever meander these rooms!
#12
02/01/2013 (8:34 am)
Congratulations, David! I will definitely be picking this up later today.
#13
on the release!
May i ask what is different/ better when following/ reading the book
regarding Torque3D/ Weapon Setups - Chapter10: Making a weapon use energy rather than ammo.
Are u describing the stateMachine inDepth and are u describing the WeaponImage::onFire/onMount... stuff aswell?
So far all my tries getting a energy based weapon do what i want, ended up not good enough(i mean they work but just not how they should :/ ).
Note: Am not askin here for hints, just want to make sure (get my hopes up) that the book can actually help me in my current struggle aswell.
either way i do plan to get it, would be nice if you could elaborate on the energy weapon - matter.
02/02/2013 (10:09 am)
Congratz Daveon the release!
May i ask what is different/ better when following/ reading the book
regarding Torque3D/ Weapon Setups - Chapter10: Making a weapon use energy rather than ammo.
Are u describing the stateMachine inDepth and are u describing the WeaponImage::onFire/onMount... stuff aswell?
So far all my tries getting a energy based weapon do what i want, ended up not good enough(i mean they work but just not how they should :/ ).
Note: Am not askin here for hints, just want to make sure (get my hopes up) that the book can actually help me in my current struggle aswell.
either way i do plan to get it, would be nice if you could elaborate on the energy weapon - matter.
#14
I shall now go back to my mountain and isolate myself with an evil grin on my face while digging into this tome of great secrets from the wizard himself. Muhahhahah!!
02/02/2013 (2:36 pm)
Well the dwarf decided to show his respect by spending some of his hard earned gold coins on this book. I really like that I got an ebook copy as soon(Packt) as I clicked on place order... I shall now go back to my mountain and isolate myself with an evil grin on my face while digging into this tome of great secrets from the wizard himself. Muhahhahah!!
#15
@J0linar:
That recipe does touch a little on all of those things. To convert a weapon over to use the player's energy pool you need to modify its datablock, its state machine, as well as its onFire() method.
Unfortunately, there wasn't space in the book to actually cover the Torque 3D weapon system's state machine and standard methods/callbacks in any detail. I only had enough space to cover converting the standard Lurker weapon from using ammo to energy.
- Dave
02/02/2013 (5:14 pm)
Thanks again, everyone!@J0linar:
That recipe does touch a little on all of those things. To convert a weapon over to use the player's energy pool you need to modify its datablock, its state machine, as well as its onFire() method.
Unfortunately, there wasn't space in the book to actually cover the Torque 3D weapon system's state machine and standard methods/callbacks in any detail. I only had enough space to cover converting the standard Lurker weapon from using ammo to energy.
- Dave
#16
02/04/2013 (11:51 am)
This book is really good!!
#17
Seriously, anyone starting out with T3D should buy this book. It lays it all out and builds from one recipe to the next. It's as good as any documentation on the engine could be.
Ron
02/04/2013 (4:53 pm)
Just an update, I have worked through each recipe from the beginning using the MIT version of T3D and other than a few minor spelling errors (editors?), it all works perfectly. Keep in mind I am hand typing the code from the book. (Yes, I am a decent typist) Not sure how things go with the downloaded scripts and info, but it has helped me understand a great deal more than I thought I did. The sections concerning PostFx and custom materials have been especially good, and don't miss the main menu project, I don't want to ruin it, but no excuses for simplistic main menu screens anymore. On to sound....Seriously, anyone starting out with T3D should buy this book. It lays it all out and builds from one recipe to the next. It's as good as any documentation on the engine could be.
Ron
#18
just got the book and even if it doesnt get in dpeth regarding the statemachine, it is allready helping a great deal.
Great Book!
02/05/2013 (3:47 am)
Aye thx @ Davidjust got the book and even if it doesnt get in dpeth regarding the statemachine, it is allready helping a great deal.
Great Book!
#19
Is there an online reference to the scripts in the book? I have the kindle version using the PC kindle viewer and when I copy the script from the book it loses all line ends. I have to go through the script and put line ends back in. It is just a pain to do if the script is long.
Edit:
The kindle copy also puts in a bunch of strange whitespace that prevents compilation of the script. I was able to turn on show whitespace in torsion and delete the wonky whitespace, but I don't what kind of whitespace it was. Perhaps kindle spits out whitespace that is supposed to be line ends/carriage returns, but it is not being detected/converted properly.
02/10/2013 (4:35 pm)
@David,Is there an online reference to the scripts in the book? I have the kindle version using the PC kindle viewer and when I copy the script from the book it loses all line ends. I have to go through the script and put line ends back in. It is just a pain to do if the script is long.
Edit:
The kindle copy also puts in a bunch of strange whitespace that prevents compilation of the script. I was able to turn on show whitespace in torsion and delete the wonky whitespace, but I don't what kind of whitespace it was. Perhaps kindle spits out whitespace that is supposed to be line ends/carriage returns, but it is not being detected/converted properly.
#20
Thanks!
@Frank:
You may download the code from the Packt Publishing web page for the book: www.packtpub.com/torque-3d-game-development-cookbook/book. Click on the Support tab and you should see a Download Now button.
- Dave
02/11/2013 (10:13 pm)
@J0linar:Thanks!
@Frank:
You may download the code from the Packt Publishing web page for the book: www.packtpub.com/torque-3d-game-development-cookbook/book. Click on the Support tab and you should see a Download Now button.
- Dave

Torque Owner Jules
Something2Play