You are previewing Torque 3D Game Development Cookbook.
O'Reilly logo
Torque 3D Game Development Cookbook

Book Description

Over 80 practical recipes and hidden gems for getting the most out of the Torque 3D game engine

  • Clear step-by-step instruction and practical examples to advance your understanding of Torque 3D and all of its sub-systems

  • Explore essential topics such as graphics, sound, networking and user input

  • Helpful tips and techniques to increase the potential of your Torque 3D games

In Detail

Torque 3D is a popular game engine that supports you in every step along the way to making your game a reality. Even with all of the power and tools that Torque 3D provides, finishing a high quality 3D game requires time and knowledge.

"Torque 3D Game Development Cookbook" is a practical guide that takes you through each of the major steps on the journey to creating your game, while learning a few tricks along the way.

The recipes in this book start off with learning some of the finer points about TorqueScript. The book then moves on to each of Torque 3D’s subsystems and ends with a variety of game play recipes.

The various topics covered include activating level-specific game code and scheduling game events, dragging and dropping items between windows to work with an in-game inventory system, and covering the seams between objects with well placed decals. Some of the advanced topics include writing custom shaders and postFX, using zones to improve rendering performance, and enhancing your game’s ambience through sound.

Once you are done with Torque 3D Game Development Cookbook you’ll be on your way to creating amazing 3D games and gain expert knowledge of Torque 3D.

Table of Contents

  1. Torque 3D Game Development Cookbook
    1. Table of Contents
    2. Torque 3D Game Development Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the color images of this book
        2. Downloading the example code
        3. Errata
        4. Piracy
        5. Questions
    8. 1. TorqueScript: The Only Script You Need to Know
      1. Introduction
      2. Accessing delimited fields within a string
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Skipping spaces (only tab and new line delimiters)
          2. Skipping spaces and tabs (only new line delimiters)
        5. See also
      3. Iterating on words in a string list
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Retrieving components of a variable using accessors
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Iterating on objects in a SimSet or SimGroup collection
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Getting a random object from a SimSet or SimGroup collection
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Finding an object in a SimSet or SimGroup collection using its internal name
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Including children SimSet and SimGroup collections in the search
          2. Using the special -> operator
          3. Using the special --> operator
        5. See also
      8. Executing a method on a SimSet or SimGroup collection
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Creating a new SimObject instance
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Creating a new SimObject instance with a globally unique name
          2. Creating a new SimObject instance with defined properties
          3. Creating a new SimObject instance based on another SimObject instance
        4. See also
      10. Creating a new internal name only SimObject instance
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      11. Creating a new Datablock object
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Creating a new Datablock object based on another Datablock object
          2. Limited total number of Datablocks
          3. The datablock keyword should only be used on the server
          4. Datablock properties should be considered static
        4. See also
      12. Creating a new singleton
        1. How to do it...
        2. How it works...
        3. See also
      13. Extending a SimObject instance using the class property
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Working with a class namespace after object creation
          2. Extending even further with the superClass property
          3. Understanding the namespace hierarchy
          4. Limitations of the class property
        5. See also
      14. Using a variable to access methods or properties of a SimObject instance
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      15. Using call() to call a variable method on a SimObject instance with arguments
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      16. Using call() to call a variable function with arguments
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      17. Using script arrays as dictionaries
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      18. Using ArrayObject and custom script sorting callbacks
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      19. Scheduling SimObject methods
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      20. Scheduling functions
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      21. Activating and deactivating a package
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    9. 2. Working with Your Editors
      1. Introduction
      2. Setting up fogging of the level
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Fog and the ScatterSky class
      3. How to cover seams and texture changes using decals placed in the World Editor
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Working with decal instances
          2. TSStatic shapes and decalType property
      4. Copying the transform of an object to another in the World Editor window
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Copying only position (or rotation, or scale) of an object
          2. Nudging the selected object
          3. Rotating an object using degrees
          4. Manipulating more than one object
      5. How to change the material of an object in the World Editor
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Modifying materials that do not start with base_
          2. Skinning multiple materials at once
      6. Setting up a glow mask using the Material Editor window
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Effect of alpha threshold on glow
          2. Using more than one material
      7. Using a convex shape as a zone
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Quickly zoning a level
          2. Game engine performance considerations
        5. See also
      8. Setting zone-specific ambient lighting
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      9. Grouping adjacent zones together
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    10. 3. Graphical User Interface
      1. Introduction
      2. Creating a password text edit box
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Using pushDialog() and popDialog() and setting up the UI file to work with them
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Executing the .gui file of the dialog box
          2. Standard dialog box callbacks
          3. Making a non-modal dialog box
          4. Difference between pushDialog() and setContent()
          5. Using a different root control for the dialog box
      4. Displaying metrics (such as FPS) from the console
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. A list of all standard metrics
          2. Creating game-specific metrics
      5. Displaying a list of all game objects
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Displaying a level at the main menu
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Making the main menu level more interesting
          2. Performance considerations
      7. Dragging and dropping between two windows
        1. Getting ready
        2. How to do it…
        3. How it works...
        4. There's more...
          1. Dialog boxes and the drag-and-drop operation
          2. How to use the inventory and paper doll windows in a game
          3. How to pass along game play information with the dragged controls
    11. 4. Camera and Mouse Controls
      1. Introduction
      2. Locking and hiding the mouse while the right mouse button is down
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Clicking on an object in the scene (client-side)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Collision mesh required
          2. Client-side-only limitations
          3. Single-player games
          4. Type masks
        5. See also

      4. Clicking on an object in the scene (server-side)
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Collision mesh required
        5. See also
      5. Picking up an item in the scene while the mouse is locked and hidden
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Changing the camera's view and control mode
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Giving the camera smooth movement
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Camera speed boost and brakes using triggers
          2. Smooth camera rotation
      8. Having the camera follow a path
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Maximum size of node list
          2. Manually stopping and changing direction
          3. Node callback
    12. 5. Your Graphics Evolved
      1. Introduction
      2. Using the built-in video recording
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Playing back Theora videos on Windows
          2. Record to individual PNG frames
      3. Changing the material of a ShapeBase object using script
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. The setSkinName() method needs to be called on the server
          2. Multiplayer considerations
          3. Player class considerations
        5. See also
      4. Building a custom material
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using named render targets as sampler data sources
          2. Single pass only
          3. Passing defines to the shader compiler using ShaderData
          4. Working with a custom GFXStateBlockData class
        5. See also
      5. Building a custom material using advanced lighting
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Building a postFX
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Dynamically changing a postFX's texture
          2. Defining shader macros
          3. Chaining multiple postFX together
        5. See also
    13. 6. Make That Sound Happen
      1. Introduction
      2. Playing a quick 2D or 3D sound on all clients
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Limitations of ServerPlay2D
          2. Limitations of ServerPlay3D
          3. Local client sound playing equivalent
        5. See also
      3. Using SFXEmitter to create networked sound effects
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Dynamically creating the sound source
          2. Using a mono sound source
          3. Sounds not fading with distance
        5. See also
      4. Playing a sound on a ShapeBase object
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Playing music while a level is loading
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. How to have a background sound for a level
        1. Getting ready
        2. How to do it...
        3. How it works...
      7. How to have music change according to the mood
        1. Getting ready
        2. How to do it…
        3. How it works...
        4. There's more...
          1. SFXState activations are reference counted
          2. Having more than one active SFXState instance
      8. Triggering an event during sound playback
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Only on client
          2. Markers on an SFXEmitter class
          3. Problem with looped sounds
        5. See also
    14. 7. Game Objects
      1. Introduction
      2. Playing an animation sequence on a TSStatic class
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      3. Playing an animation sequence on a ShapeBase class
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Pausing an animation sequence playback
          2. Jumping to a location in timeline of an animation sequence
          3. Changing playback direction and speed of a sequence
        5. See also
      4. How to make it rain using a Precipitation object
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Sprite sheet for drops and splashes
          2. Using a shader for drops and splashes
          3. Precipitation at a fixed location
          4. Modifying precipitation over time
          5. Global control of Precipitation drop density
        5. See also
      5. Using the Lightning object to automatically create a thunderstorm
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Striking a player or vehicle
          2. Manual lightning strikes
        5. See also
      6. Using the TimeOfDay object to generate events
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Setting up the ScatterSky class for night
          2. Manually modifying the time of day
        5. See also
    15. 8. Multiplayer Servers
      1. Introduction
      2. How to start a dedicated server
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. The -game parameter
          2. The -level parameter
          3. Shutting down a dedicated server
        5. See also
      3. What ports are needed to be open or forwarded for a multiplayer server
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Changing the port used by the game server
          2. Master server considerations
          3. Playing over a LAN
      4. Passing arbitrary parameters from the client to the server
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. How to become an admin on a server
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Different types of administrators
          2. Administrator password is server wide
      6. Kicking and banning people from the server
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Kicking or banning a player by name
          2. Remotely kicking or banning a player
        5. See also
      7. Stopping a server from restarting when the last player leaves
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Accessing the server connection from the client
        1. How to do it...
        2. See also
      9. How to access all client connections from the server
        1. How to do it...
        2. How it works...
        3. See also
      10. Broadcasting a message to all clients and having it displayed in the center of the screen
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Manually clearing the center print message
          2. Individual client version of center print
    16. 9. Importance of Networking
      1. Introduction
      2. Sending a network event from the client to the server
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Packed network strings
          2. Packed empty strings
          3. Packed network integers
          4. Handling floating point numbers
        5. See also
      3. Sending a network event from the server to the client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Connecting as a TCP client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Sending data to a server
          2. Connecting and disconnecting
          3. Success callbacks
          4. Failure callbacks
        5. See also
      5. Setting up a TCP server
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Handling more than one connection
          2. Dropping a connection
        5. See also
      6. Connecting as an HTTP client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Separating the HTTP header and body
          2. Processing an XML response
        5. See also
      7. Using an RSS feed for game news, message of the day, or other client messages
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. How to activate, deactivate, and use Telnet for console access
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Disabling remote console access once it has been enabled
          2. Telnet is not secure
    17. 10. Miscellaneous Gameplay Features
      1. Introduction
      2. How to have a sprinting player use up energy
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Balance energy drain versus recharge rate
          2. Modifying other sprint limitations
          3. Disabling sprint
      3. Enabling and disabling air control
        1. How to do it...
        2. How it works...
      4. How to jump jet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Jump jet animation sequence
          2. Disabling jump jetting
          3. More control over the jump jet
        5. See also
      5. Adjusting the fire spread of a weapon
        1. How to do it...
        2. How it works...
      6. Changing the number of shots fired from a weapon
        1. How to do it...
        2. How it works...
        3. See also
      7. Making a weapon use energy rather than ammo
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Finding objects in range
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Obtaining the distance to a found object
          2. Obtaining the distance to the closest point to a found object
          3. Searching for all objects of a particular type
          4. A very quick search test
          5. Performing a ray cast search of the scene graph
        4. See also
      9. Using the message producer/consumer system
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Removing a listener from all event messages
          2. Peeking into an EventManager instance
    18. Index