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!
#22
I contacted Amazon and they are going to look into the issue with proper pasting. However in the interim I have a solutions:
The issue amounted to them using two unicode characters 'x0Ax0A' instead of carriage return 'x0D'. So that should fix the issue if they decide to implement it.
Thanks for the link, Amazon said they did not have a way to get the source. I also did not know you had replied as I forgot to click the notify me checkbox. Doh!
Edit:
Updated code to remove more unicode characters. Not a complete fix, but is better than nothing.
02/11/2013 (10:40 pm)
@Dave,I contacted Amazon and they are going to look into the issue with proper pasting. However in the interim I have a solutions:
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.5 (standalone edition) on Mon Feb 11 22:40:58 2013
#
# Kindle Paste
# Converts 2 '\x0A' Unicode characters to '\x0D'
# This fixes formatting errors when pasting.
# Please add this fix to the 'Kindle for PC' software.
#
import wx
# begin wxGlade: extracode
# end wxGlade
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE | wx.HSCROLL)
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_TEXT, self.evtTextEdit, self.text_ctrl_1)
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("Kindle Paste")
self.SetSize((500, 400))
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.text_ctrl_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
def evtTextEdit(self, event): # wxGlade: MyFrame.<event_handler>
#print dir(event)
obj = event.GetEventObject()
t1 = event.String
#print dir(temp)
t2 = t1.replace(u'\xA0\xA0',u'\x0D')
s = t2.replace(u'\xA0','')
#print s
obj.SetValue(s)
obj.Refresh()
def runapp():
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
# end of class MyFrame
if __name__ == "__main__":
runapp()This is a Python program tested with Python 2.7 and wxPython (any unicode version that works with Python 2.7). You paste the text into the text windows and it just fixes the text and you can copy it again. I should figure out how to make it select everything again and add some simple menu, but it works. I also sent this snippet to Amazon to fix their pasting code.The issue amounted to them using two unicode characters 'x0Ax0A' instead of carriage return 'x0D'. So that should fix the issue if they decide to implement it.
Thanks for the link, Amazon said they did not have a way to get the source. I also did not know you had replied as I forgot to click the notify me checkbox. Doh!
Edit:
Updated code to remove more unicode characters. Not a complete fix, but is better than nothing.
#23
Upate: due to some technical my order was not processed and they will now make sure to tell my local department to ship the book....
Thanks I guess O_o
02/13/2013 (6:26 am)
Any other people ordered from Packt and still did not receive their physical copy? Mine was ETA the 9th of February and still no sign of the book. Sent them three emails and no answer has been given... Upate: due to some technical my order was not processed and they will now make sure to tell my local department to ship the book....
Thanks I guess O_o
#24
03/05/2013 (6:00 pm)
Ordered mine through Amazon and got it yesterday. what I've flicked through looks good.
#25
05/02/2013 (1:13 pm)
Started reading this yesterday and didn't complete the first chapter. The book seems well detailed. :)
#26
Google's agreement with Packt to offer part of the book for free reading online, convinced us this was the best book out for what we are building. We got it from Packt because when I went to their website, a popup offered me a 20% off code Packt20 and it gave us $5 off the $29.99 eBook.
The $24 price and included a download of the code in individual files was just like finding a cookie in a game you didn't expect. The book has good decomposition, just enough but not to much. I would say a person who only has the most limited knowledge of programming could follow this book.
I actually Googled "Torque 3D How do I display inventory in a window or GUI" and google loaded in at Chapter 3 with the page showing; Dragging and Dropping Between Two Windows with the following paragraph that stated; ...The first window will stand for an RPG Inventory... and I got this relieved feeling I was looking at a page in a book that might just have everything we were looking for.
01/16/2016 (5:59 pm)
Hoping this book is still usable. Just got it from the Packt publishing website in eBook. Our family of four spent weeks looking for suitable sources for making a game that plays like an MMORPG, but it plays offline in the old school way like the FPS games of the 80's and 90's... as far as being able to host a game yourself with family members at home or for friends who come over.Google's agreement with Packt to offer part of the book for free reading online, convinced us this was the best book out for what we are building. We got it from Packt because when I went to their website, a popup offered me a 20% off code Packt20 and it gave us $5 off the $29.99 eBook.
The $24 price and included a download of the code in individual files was just like finding a cookie in a game you didn't expect. The book has good decomposition, just enough but not to much. I would say a person who only has the most limited knowledge of programming could follow this book.
I actually Googled "Torque 3D How do I display inventory in a window or GUI" and google loaded in at Chapter 3 with the page showing; Dragging and Dropping Between Two Windows with the following paragraph that stated; ...The first window will stand for an RPG Inventory... and I got this relieved feeling I was looking at a page in a book that might just have everything we were looking for.

Associate David Wyand
Gnometech Inc.
Thanks!
@Ron:
I'm sorry to hear about any typos. It is amazing how many people a book ends up going through, and how much it is deconstructed and reconstructed to produce the final layout for printing.
- Dave