CryENGINE 3 Game Development
Beginner's Guide
Discover how to use the CryENGINE 3 free SDK, the
next-generaon, real-me game development tool
Sean Tracy
Paul Reindell
BIRMINGHAM - MUMBAI
CryENGINE 3 Game Development Beginner's Guide
Copyright © 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system,
or transmied in any form or by any means, without the prior wrien permission of the
publisher, except in the case of brief quotaons embedded in crical arcles or reviews.
Every eort has been made in the preparaon of this book to ensure the accuracy of the
informaon presented. However, the informaon contained in this book is sold without
warranty, either express or implied. Neither the authors, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be
caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark informaon about all of the
companies and products menoned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this informaon.
First published: September 2012
Producon Reference: 1140912
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-200-7
www.packtpub.com
Cover Image by Hazel Denise Karunungan ()
Credits
Valenna D'silva
Adi Gajjar
Producon Coordinators
Nitesh Thakur
Manu Joseph
Cover Work
Nitesh Thakur
About the Authors
Sean Tracy is Crytek's Senior Field Applicaon Engineer for the award-winning
CryENGINE. He is responsible for adapng the engine and its features to individual
licensees, as well as developing full technical and "vercal slice" demos for prospecve
and exisng clients. Describing himself as a "generalizing specialist", he also gives support
directly to CryENGINE licensees while designing and maintaining their workows, pipelines,
and development techniques.
Sean was recruited by Crytek in 2008 aer working as an electronics technician for the
Canadian military. He was recruited due to his role in founding and leading development
on the award-winning total conversion project—MechWarrior: Living Legends. Since then,
he has been featured in numerous gaming magazines and has been invited to speak at many
game-related trade shows, conferences, and seminars. He is an avid gamer with extensive
modding experience on tles, including Never Winter Nights, Baleeld, Doom, and Quake.
This is Sean's second book.
I would rst like to thank my beauful wife, Kristy, for her love and support
throughout the process of wring this book and for her ongoing support
allowing me to do what I truly enjoy for a living. I also want to thank her
for giving us a gorgeous baby girl who is the light of my life. I would also
like to thank my colleagues for taking the me to review the book with
me, as it's a pleasure to work with people with the same love for real-me
technology as I have. Finally, I'd like to thank Crytek and Packt for their
support in allowing me to write this book and for making one of the best
game engines on the market.
parcipang in sessions relang to game producon, design, and markeng.
Michelle is the author of Corona SDK Mobile Game Development: Beginner's Guide,
which was published by Packt Publishing. She has also wrien an arcle called How
to Create a Mini-Game in Corona SDK for Game Coder Magazine. You can also view
her personal website at .
Dr Christos Gatzidis is a Senior Lecturer in Creave Technology at Bournemouth
University, UK at the School of Design, Engineering, and Compung. He has a PhD
from City University London, UK and an MSc in Computer Animaon from Teesside
University, UK; he has also previously published work in a number of academically
edited books, conferences, and journals. He is also the framework leader for the
Creave Technology collecon of degrees at Bournemouth University (which includes
the BSc in Games Technology and the MSc in Computer Games Technology courses).
Christos teaches a variety of units on these courses and uses game engines (such as
Epic's Unreal Development Kit) across all years of the undergraduate course, to cover
topics ranging from basic-level design fundamentals to more advanced scripng.
I would like to thank the authors of this book and also the great people
at Packt for producing this excellent guide in one of the most engaging
game development tools around today.
Sascha Hoba is an Engine Programmer for Crytek's award-winning CryENGINE. He is
responsible for implemenng new features, improving exisng ones, and keeping the
engine up-to-date with improvements made across all Crytek teams to increase the
overall quality of the engine. He also gives direct support to CryENGINE licensees
around the world, guiding them on how to use CryENGINE from a programmer's
perspecve and trying to nd possible soluons for special requests made by licensees.
Sascha was recruited by Crytek back in 2010 aer studying IT—Informaon
Technology—at university. He was recruited due to his experience in working with all the
revisions of CryENGINE since CryENGINE 1, back in 2004. He gained his experience as an
acve member of the FarCry and Crysis modding communies, where he always tried to
push the engine to its limits and solve individual problems on how to implement certain
features with the available CryENGINE SDK.
to your book.
Did you know that Packt oers eBook versions of every book published, with PDF and ePub
les available? You can upgrade to the eBook version at
www.PacktPub.com and as a print
book customer, you are entled to a discount on the eBook copy. Get in touch with us at
for more details.
At
www.PacktPub.com, you can also read a collecon of free technical arcles, sign up
for a range of free newsleers and receive exclusive discounts and oers on Packt books
and eBooks.
Do you need instant soluons to your IT quesons? PacktLib is Packts online digital book
library. Here, you can access, read and search across Packt's enre library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view nine enrely free books. Simply use your login credenals for
immediate access.
Table of Contents
Preface 1
Chapter 1: Introducing the CryENGINE 3 Free SDK 7
What is the CryENGINE? 8
Applying your vision 8
Far Cry by Crytek – rst-person shooter 9
Aion by NCso – massively online role-playing game 10
Crysis by Crytek – rst-person shooter 11
Scaling your level with Meters Per Unit 39
Calculang the real-world size of the terrain 40
Using or not using terrain 40
Time for acon - creang your own heightmap 41
Using alternave ways for creang terrain 47
Generang procedural terrain 47
Imporng a pre-made heightmap 48
Creang terrain textures 49
Time for acon - creang some basic terrain texture layers 50
Adding altude and slope 56
Adjusng the le resoluon 56
Creang vegetaon 57
Time for acon - creang some ora for your level 58
Time for acon - seng up me of day and its basic parameters 62
Adding Atmosphere 69
Summary 69
Chapter 3: Playable Levels in No Time 71
Building levels with enes and objects 71
Starng a level 72
Creang a spawn point 72
Time for acon - creang a spawn point 72
Landmarks to guide the player 74
Using roads in levels 74
Time for acon - creang a road object 74
Ulizing layers to organize level objects 79
Time for acon - creang and managing layers 79
Adding objects using the asset browser 81
Time for acon - adding brushes to the level 82
White boxing 84
White boxing using Construcve Solid Geometry (CSG) 84
Starng CryENGINE 3 with Visual Studio 122
Time for acon - starng CryENGINE with the debugger aached 122
Breakpoints, watches, and co 125
Time for acon - seng up your rst breakpoint 126
Create a new Lua enty and call C++ code to interact with it 129
Time for acon - creang a new enty 129
Time for acon - placing your enty into your level 132
How to interact with enes via Lua script 134
Time for acon - making the teleporter usable 134
Time for some real code 136
Time for acon - wring a new scriptbind funcon in C++ 136
Call the new C++ funcon from your Lua script 140
Time for acon - changing the teleporter enty to execute the C++ code 141
CryENGINE specic data types 143
Summary 145
Table of Contents
[ iv ]
Chapter 6: User Interface and HUD Creaon with Flash 147
Adobe Flash as a very powerful UI design tool 148
Time for acon – creang a new Flash asset with Adobe Flash 148
Bringing your Flash asset into CryENGINE 3 158
Time for acon – bringing your Flash asset into CryENGINE 3 158
Time for acon – making funcons, variables, and movieclips accessible in
CryENGINE 3 159
Dierent alignment modes for UI elements 162
Dynamic alignment 163
Fixed and fullscreen alignment 164
Using the UI Emulator to display and test your asset 164
Time for acon – starng Sandbox and tesng your UIElement 164
Creang a new UI Acon for the new HUD 167
Creang destrucble objects 205
Time for acon - making your object destrucble 205
Specifying physics and render dynamics with user dened properes 210
Breaking two-dimensional assets 210
Designing breakables with constraints 211
Using character assets 213
Following the character creaon pipeline 213
Creang your own characters 213
Time for acon - creang your own skinned character 214
Creang a character LOD (Level of Detail) 221
Bone aachments 222
Creang animaons for your character 223
Time for acon - creang animaon for a skinned character 223
.chrparams wildcard mapping 227
Creang animaon for rigid body assets 228
Time for acon - creang animaon using rigid body data 229
Summary 232
Chapter 8: Creang Real-me Cutscenes and Cinemac Events 233
Discovering the Track View editor 234
Creang a new Track View sequence 234
Time for acon – creang a new sequence 235
Adding tracks to the director node 238
Adjusng Sequence Properes 238
Animang a camera in Track View 238
Time for acon – animang a camera 239
FOV 243
Playback speed 243
Curve Editor 243
Triggering a sequence using Flow Graph 243
Time for acon – triggering a sequence 244
Geng your rst sound into the CryENGINE 266
Time for acon - creang an ambient sound event 266
Leveraging advanced parameters of ambient sounds 273
Time for acon - nesng ambient sounds and using other parameters
for sound events 273
Randomizing sounds 276
Time for acon - creang random sounds 277
Reverb volumes 279
Time for acon - create your own reverb preset 280
Adding sounds to parcle eects 283
Time for acon - add a sound to a parcle eect 283
Using the three dierent sound control overme funcons 285
Sound events and weapons 286
Time for acon - add sound to a weapon 286
Weapon sound workow ps 289
Summary 290
Chapter 10: Preparing to Share Your Content 291
Proling performance in Sandbox 292
Proling with display info 292
Time for acon – enabling and reading display info 292
Understanding draw calls 294
Visualizing triangle count 295
Table of Contents
[ vii ]
Seng budgets 295
Saving a level's stascs 295
Time for acon – Save Level Stascs 296
Viewing textures and render targets in the Textures tab 300
Viewing physical triangle count and physics memory footprints 300
Reading the Detailed Dependencies tab 300
hobbyist developers alike have turned to middleware game engines, such as the CryENGINE,
to save them me, money, and frustraon, while manifesng their ideas into releasable games.
The CryENGINE is a comfortable t for most developers, because it allows users to create
their content quickly, iterate on that content, and to nalize it without leaving the comfort
of the CryENGINE's Sandbox Editor. I oen refer to the CryENGINE as a force mulplier,
since its tools make it possible for smaller teams to accomplish what used to take an
enre development studio, full of people. This book is an introducon to the CryENGINE
technology, and is comprised of achievable, small-scale examples, which can be applied
in almost any game genre. This book is not designed to cover exhausvely every feature
and funcon in the CryENGINE, but rather is designed to give you the knowledge and tools
needed to get you of to a smooth and painless start when making your own games with the
CryENGINE 3.
What this book covers
Chapter 1, Introducing the CryENGINE 3 Free SDK, covers the beginning to developing
your own games of any scale by learning to harness the power of the award-winning
CryENGINE® 3 game engine. In this chapter, you will learn to navigate and interface
within the CryENGINE® 3 Sandbox, the tool used to create AAA games, such as Crysis
1 and 2, as well as the soon to be released Crysis 3.
Preface
[ 2 ]
Chapter 2, Breaking Ground with Sandbox, covers building your game worlds in real me
with CryENGINE® 3 Sandbox, as we share insights into some of the tools and features
useable right out of the box. In this chapter, you will learn how to create your own worlds
by following straighorward examples that use some of the important fundamental features
available to developers of the CryENGINE®. This includes tools and techniques related to
sculpng, molding the terrain, and placing vegetaon.
Chapter 3, Playable Levels in No Time, covers more advanced level design tools, which
are discussed in the chapter, as well as simple modeling techniques using the integrated
CryENGINE solids system.
Chapter 4, I'm a Scripter, Not a Coder, covers learning the method of visual scripng used
which include Photoshop and 3D Studio Max. Though not a fundamental requirement,
having some basic knowledge of real-me graphics soware and, consequently, the
terminology used, will make the goal of these tutorials more clear. The freely available
version of the CryENGINE® 3 has been used for all the examples in this book, and Chapter
1, Introducing the CryENGINE 3 Free SDK will guide the reader to download and install the
CryENGINE® 3 Free SDK.
Conventions
In this book, you will nd several headings appearing frequently.
To give clear instrucons of how to complete a procedure or task, we use:
Time for action – heading
1. Acon 1
2. Acon 2
3. Acon 3
Instrucons oen need some extra explanaon so that they make sense, so they are
followed with:
What just happened?
This heading explains the working of tasks or instrucons that you have just completed.
You will also nd some other learning aids in the book, including:
Preface
[ 4 ]
Pop quiz – heading
These are short mulple choice quesons intended to help you test your own understanding
Have a go hero – heading
These set praccal challenges and give you ideas for experimenng with what you have
learned.
You will also nd a number of styles of text that disnguish between dierent kinds of
informaon. Here are some examples of these styles, and an explanaon of their meaning.
Code words in text are shown as follows: " If you now navigate to the level directory using
Windows Explorer, you will noce a new folder called
Layers. Inside that folder, you will
e-mailed directly to you.
Downloading the color images of this book
We also provide you a PDF le that has color images of the screenshots/diagrams used
in this book. The color images will help you beer understand the changes in the output.
You can download this le from
/>downloads/2007_graphics.pdf
.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you nd a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you would report this to us. By doing so, you can save
other readers from frustraon and help us improve subsequent versions of this book.
If you nd any errata, please report them by vising />support
, selecng your book, clicking on the errata submission form link, and entering
the details of your errata. Once your errata are veried, your submission will be accepted
and the errata will be uploaded to our website, or added to any list of exisng errata, under
the Errata secon of that tle.
Preface
[ 6 ]
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt,
we take the protecon of our copyright and licenses very seriously. If you come across any
illegal copies of our works, in any form, on the Internet, please provide us with the locaon
address or website name immediately so that we can pursue a remedy.
Please contact us at
with a link to the suspected pirated material.
We appreciate your help in protecng our authors, and our ability to bring you
valuable content.
Questions
You can contact us at if you are having a problem with any