Tải bản đầy đủ (.pdf) (30 trang)

CREATING GAME ART FOR 3D ENGINES- P1 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (838.08 KB, 30 trang )

C
REATING
G
AME
A
RT
FOR
3D E
NGINES
B
RAD
S
TRONG
C
HARLES
R
IVER
M
EDIA
Boston, Massachusetts
Copyright 2008 Career & Professional Group, a division of Thomson Learning Inc.
Published by Charles River Media, an Imprint of Thomson Learning Inc. All rights reserved.
No part of this publication may be reproduced in any way, stored in a retrieval system of any type, or
transmitted by any means or media, electronic or mechanical, including, but not limited to, photocopy,
recording, or scanning, without prior permission in writing from the publisher.
Publisher and General Manager, Charles River Media: Stacy L. Hiquet
Associate Director of Marketing: Sarah O’Donnell
Manager of Editorial Services: Heather Talbot
Marketing Manager: Jordan Casey
Marketing Assistant: Adena Flitt


Project/Copy Editor: Karen A. Gill
Technical Reviewer: Mike Duggan
CRM Editorial Services Coordinator: Jennifer Blaney
Interior Layout Tech: Judy Littlefield
Cover Designer: Sherry Stinson
Cover Images: Brad Strong
CD-ROM Producer: Brandon Penticuff
Indexer: Joan Green
Proofreader: Sybil Fetter
Charles River Media, Inc.
25 Thomson Place
Boston, MA 02210
617-757-7900
617-757-7969 (fax)
www.charlesriver.com
This book is printed on acid-free paper.
Brad Strong. Creating Game Art for 3D Engines.
ISBN-10: 1-58450-548-6
ISBN-13: 978-1-58450-548-8
Library of Congress Catalog Card Number: 2007933886
3ds Max is a registered trademark of Autodesk, Inc. Photoshop is a registered trademark of Adobe
Systems Incorporated. All other brand names and product names mentioned in this book are trademarks
or service marks of their respective companies. Any omission or misuse (of any kind) of service marks
or trademarks should not be regarded as intent to infringe on the property of others. The publisher
recognizes and respects all marks used by companies, manufacturers, and developers as a means to
distinguish their products.
Printed in Canada
08 09 10 11 12 TC 10 9 8 7 6 5 4 3 2 1
Charles River Media titles are available for site license or bulk purchase by institutions, user groups, cor-
porations, etc. For additional information, please contact the Special Sales Department at 800-347-7707.

Requests for replacement of a defective CD-ROM must be accompanied by the original disc, your mail-
ing address, telephone number, date of purchase, and purchase price. Please state the nature of the
problem, and send the information to Charles River Media, Inc., 25 Thomson Place, Boston, MA 02210.
CRM’s sole obligation to the purchaser is to replace the disc, based on defective materials or faulty
workmanship, but not on the operation or functionality of the product.
eISBN-10: 1-58450-604-0
This book is dedicated to my wife, Åsa,
who was an encouragement and a blessing
from the time this book was just an idea until the final edit.
This page intentionally left blank
C
ONTENTS
A
CKNOWLEDGMENTS
xvii
A
BOUT THE
A
UTHOR
xix
I
NTRODUCTION
xxi
C
HAPTER
1I
NTRODUCTION TO
3
DS
M

AX
1
Examining the 3ds Max Interface 2
Using Drop-Downs and Panels 3
Adjusting Grid and Snap 4
Setting Preferences 4
Creating, Viewing, and Modifying Primitives 4
Using Viewport Controls 5
Modifying Primitives 5
Using Viewing Tools 6
Using Selection Windows 8
Box Modeling a Chair 8
Converting to an Editable Poly 9
Moving the Vertices of the Editable Poly 9
Maximizing the Viewport and Using Arc Rotate 11
Extruding the Legs of the Chair 11
Extruding the Back of the Chair 12
Creating the Arms of the Chair 12
Welding Vertices 14
Manipulating Vertices 14
Working with the Material Editor 15
Applying a Standard Material to an Object 15
Applying a Custom Material to an Object 16
v
Managing Files 18
Saving Your Work 18
Merging and Importing Files 18
Summary 18
C
HAPTER

2L
OW
P
OLY
M
ODELING
19
Creating Structurally Sound Models 20
Keeping a Low-Polygon Budget 21
Modeling a Simple Shape 22
Modeling a Health Patch 23
Welding Vertices with Weld Threshold 25
Creating a Pickup with Three Parts 26
Modeling a Power Charger 27
Modeling a Weapon 41
Creating a Template to Model By 42
Modeling with a Plane 43
Adding Symmetry to Mirror and Weld Vertices Simultaneously 47
Scaling Models to Fit the Torque Engine 54
Summary 55
C
HAPTER
3U
NWRAPPING
G
AME
A
RT
57
Unwrapping the Oil Drum 58

Deciding Between Material Color and Object Color 58
Turning Off Smoothing 58
Applying a Cylindrical Map to the Model 59
Applying an Unwrap UVW Modifier 61
Applying a Normal Map 66
Applying a Utility Material 68
Correcting Flaws in the UVs 69
Moving UV Vertices to Improve the Mapping 71
Rendering Out the UV Template 72
Using Texporter: An Alternative for UV Rendering 73
vi Contents
Contents vii
Unwrapping the Weapon 75
Mirroring and Aligning Normal-Mapped UVs 75
Normal Mapping the Cooling Fins 78
Correcting the UVs at the Edges of the Weapon 79
Breaking and Scaling UVs 80
Unwrapping the Ammo Box 82
Unwrapping the Power Charger 84
Applying a Planar Map 85
Moving UV Vertices to Improve the Map 85
Using a Planar Map for More Complex Models 86
Unwrapping the Health Patch 90
Summary 94
C
HAPTER
4T
EXTURING
G
AME

A
RT
95
Texturing Considerations 96
Using the Appropriate Equipment 96
Using Digital Photos for Textures 96
Making the Lighting Consistent 96
Creating Textures from Scratch 97
Creating in Powers of Two 97
Working with Photoshop 97
Texturing the Oil Drum 101
Pushing Pixels with the Liquify Tool 101
Using Offset to Make the Texture Wrap 102
Repairing Seams with the Clone Stamp Tool 102
Reflection Mapping in Photoshop 104
Defining a Reflective Oil Drum Material in 3ds Max 105
Assigning Smoothing Groups to the Oil Drum 107
Texturing the Health Patch 107
Creating Textured Steel 107
Applying a Layer Style to Create Raised Steel Panels 107
Using Layer Masking Instead of Erase 108
Animating a Pulsing Light Using an IFL Material 109
Animating a Transparent Exhaust Material 109
Applying the Materials in 3ds Max 111
Texturing the Weapon 112
Texturing the Power Charger 115
Creating Concrete Using Filters 115
Creating Ancient Metal 117
Modifying Smoothing Groups for the Power Charger 118
Texturing the Ammo Box 119

Summary 122
C
HAPTER
5A
NIMATING
G
AME
A
RT
123
Understanding Animation Basics 124
Creating Keyframes 124
Creating a Loop 125
Adjusting Key Tangencies 126
Animating a Simple Shape 127
Animating the Health Patch 128
Adjusting Pivot Points with Affect Pivot Only 128
Creating Parent-Child Relationships 129
Animating the Weapon 129
Summary 132
C
HAPTER
6E
XPORTING
G
AME
A
RT
133
Exporting Game Art—Overview 134

Export Components 134
Folder Structure 134
Static Shapes Folders 135
Health Patches Folder 135
Weapons Folder 135
Bounds Boxes 135
Markers, or “Dummy Objects” 135
Hierarchy 135
Pickup Rotation 136
Animations 136
viii Contents
Contents ix
Setting Up for 3ds Max and Torque 136
Installing the DTS Exporter 136
Setting Up Torque for First Person Shooter 137
Deleting CS.DSO Files So That CS Files Will Be Read 137
Entering the Torque Editor 137
Saving and Renaming Missions 138
Checking the Torque Console Window 138
Previewing Game Art in Torque Show Tool Pro 139
Setting Up and Exporting the Simple Shape 140
Accessing the DTS Export Utilities 140
Setting Up the Hierarchy of a Simple Oil Drum 140
Exporting the Simple Shape 141
Inserting the Simple Shape into the Game 141
Applying Levels of Detail 143
Causing Collisions 145
Setting Up and Exporting the Health Patch 145
Colliding with Health Objects 146
Embedding Sequence Objects 146

Inserting the Health Patch into the Mission 148
Scripting Health Patch Animation 148
Analyzing the Characteristics of a Health Patch 149
Setting Up and Exporting Ammo 150
Setting Up and Exporting Weapons 151
Weapons Components 152
The Projectile 152
A Simple Weapon Hierarchy 152
Preparing and Exporting Weapon Animations 152
Scripting for Weapons and Ammo 153
Producing Simple Shape Animations 159
Creating the Simple Shape Datablock 159
Editing Game.cs to Call Your Script 161
Troubleshooting 162
The Shape Does Not Appear in the Game 162
The Texture Does Not Show Up in the Game 162
Weapon View in First Person Mode Is Incorrectly Offset 162
Summary 163
C
HAPTER
7C
HARACTER
M
ODELING
165
Modeling a Character—Overview 166
Planning for Unwrapping the Model 166
Acknowledging Character Polygon Limitations 166
Setting Up Templates in Photoshop 166
Posing the Character 166

Sketching a Front and Right-Side View of the Character 167
Scanning and Creating Two Matching Images in Photoshop 168
Turning Down the Brightness and Saving the Images 168
Setting Up the Template Planes in 3ds Max 169
Setting Up Units 169
Creating Template Planes 169
Orienting the Template Planes 169
Snapping the Template Planes to the Origin 170
Applying the Templates to the Planes 170
Freezing the Templates 171
Modeling the Astronaut Character Mesh 171
Starting with a Box 171
Making the Modeling Process Easier by Adjusting Properties 171
Adding Symmetry to Speed the Modeling Process 172
Extruding the Arms and Legs 172
Moving and Adding Vertices as Necessary 172
Adding Edges with Row, Loop, and Connect 174
Adding Volume and Shape to the Mesh 175
Using Edge Loops 175
Planning for Movement 176
Modeling the Hands 177
Merging and Scaling the Hand to Fit the Body 178
Modeling the Head and Face 180
Finishing Off the Head with a Geosphere 181
Converting to Editable Mesh and Turning Edges 182
Adding Accessory Meshes 183
Creating a Helmet with Detached Polygons 184
Adding a Shell Modifier 184
Modeling a Robot with Multiple Meshes 186
Summary 187

x Contents
Contents xi
C
HAPTER
8C
HARACTER
U
NWRAPPING
189
Unwrapping a Character—Overview 190
Unwrapping Before You Rig the Model 190
Understanding the Impact of Stray Vertices 190
Removing Stray Vertices 190
Unwrapping the Hands with a Planar Map and Adding Them to the Body 191
Unwrapping the Body with a Normal Map 194
Breaking and Overlapping UVs 195
Breaking and Reorganizing UVs 195
Adjusting the UVs on the Body 196
Unwrapping the Character’s Face 197
Adjusting the UVs on the Face 197
Unwrapping with the Pelt Map 198
Creating a Character UV Template 200
Unwrapping the Helmet 201
Unwrapping a Component Mesh 201
Unwrapping with Multiple Material IDs 202
Creating a Multi/Sub-Object Material 202
Assigning Mesh IDs to Polygons 202
Accessing the Selection Sets in the Edit UVWs Dialog Box 203
Saving, Loading, and Combining UVs 204
Baking the Texture into the Mesh 205

Summary 205
C
HAPTER
9C
HARACTER
T
EXTURING
207
Texturing the Astronaut 208
Setting Up in Photoshop 208
Using the Same Smoothing Group 208
Creating the Astronaut’s Spacesuit Texture 208
Using a Layer Style to Create Raised Pixels 209
Using a Layer Mask to Draw the Ribs 211
Texturing the Astronaut’s Helmet 211
Texturing the Astronaut’s Face 211
Texturing the Robot 213
Creating a Base Metal Texture 213
Creating Panels 214
Creating Rivets 214
Creating Scratched and Peeling Paint 215
Modeling Textures in 3ds Max 217
Troubleshooting 219
Misaligned Unwrap 219
Distorted Textures 219
Summary 219
C
HAPTER
10 C
HARACTER

R
IGGING
221
Rigging—Overview 222
Deciding Between Bones and Biped 222
Setting Up the Mesh as a 3D Template 222
Making a Biped 223
Modifying the Parameters of a Biped After You’ve Created It 223
Understanding the Biped 223
Understanding the Biped Center of Mass (COM) 224
Rotating the Biped 224
Moving the Biped 225
Minimizing Vertex Collapse 225
Minimizing Collapsed Vertices by Modeling 226
Minimizing Collapsed Vertices by Prerotating Biped Bones 226
Minimizing Collapsed Vertices by Using Helper Bones 226
Minimizing Deformations by Using the Joint Angle Deformer 230
Fitting the Biped to the Character Mesh 230
Scaling the Pelvis and Clavicles of the Biped 231
Scaling and Rotating the Legs and Arms of the Biped 231
Aligning the Biped to the Character Mesh from the Side View 231
Saving the Figure File 231
Examining the Skinning Process 232
Applying a Skeleton via Skin or Physique 232
Ensuring You’re Ready for Skinning 232
Applying the Skin Modifier to the Character Mesh 233
Deciding Which Bones to Add to the Skin Modifier 233
Adjusting the Envelope 233
xii Contents
Contents xiii

Assigning Weights to Vertices with Absolute Effect 237
Assigning Weights to Vertices with the Weight Tool 238
Moving and Rotating Bones to Check Vertex Assignments 241
Understanding Forward Kinematics and Inverse Kinematics 241
Avoiding the Chewing Gum Effect 241
Changing the Skeleton While Skinning 242
Looking for Vertex Collapse 243
Keyframing the Biped to Check Mesh Deformation 243
Creating Optional Controller Objects 244
Rigging a Robot 244
Using the Default Player Biped with a Custom Mesh 245
Taking Advantage of Using the Kork Player Biped with Your Character Mesh 246
Dealing with the Disadvantages of Using the Kork Player Biped with Your Mesh 246
Stripping Down the Player.max File 246
Applying the Skin Modifier to Your Mesh but Using the Kork Player Biped Bones 246
Minimizing Vertex Collapse with the Kork Player Biped 247
Combining Bones with Biped 248
Summary 249
C
HAPTER
11 C
HARACTER
A
NIMATION
251
Implementing Character Animation Concepts 252
Applying Counterpose 252
Avoiding Twins or Twinning 252
Using Arcs for Natural Movement 252
Applying Secondary Motion 252

Exaggerating Movement 253
Planning the Animation Cycles 253
Distinguishing Animation Methods 253
Choosing Between Full Body, Lower Body, and Blend Animation 253
Exporting All Animations Together or Separately 254
Choosing Between Biped and Bones Animation 254
Animating with Biped 255
Dealing with Nonintuitive Dependencies in the Biped Skeletal System 255
Creating and Importing BIP Files 255
Creating the Root Pose 256
Animating the Root Cycle 257
Animating a Run Cycle 258
Keyframing the Biped to Run 258
Constraining the Cam Marker 263
Viewing and Adjusting Trajectories 264
Improving the Run Cycle 264
Animating a Back (Backwards Run) Cycle 265
Animating a Side (Strafe) Cycle 265
Animating Jump, Fall, and Land Cycles 266
Animating the Death Fall 266
Summary 266
C
HAPTER
12 C
HARACTER
E
XPORTING
269
Exporting Character Shape (DTS) Files 270
Required Markers for Character Export 270

Checklist for Exporting a Simple Character 270
Position of the Character’s Markers 271
The Character Hierarchy 271
Bounding Box 272
Levels of Detail 273
MountPoints 275
Additional Meshes and Collisions 275
Config File 276
Export of the DTS Shape 277
Exporting Character Animation (DSQ) Files 278
Sequence Object Setup 279
Footprints and Foot Sounds 280
Export of the DSQ Animation 280
Using the Torque Show Tool Pro 281
Scripting Characters 282
The Player.cs Animation Script 282
The Player.cs Datablock Script 284
Scripting for Different Character Meshes in the Game 284
xiv Contents
Contents xv
Troubleshooting 287
Assertion Failed on Skin Object 287
Improperly Assigned Vertices 287
Character Is Invisible in the Game 287
Character Is Not Animating 288
Cannot Collapse bip01 L Finger00 Because It Is a Bone 288
Helper Bones and Proxy Objects Are Distorted in the Animation Files 288
Weapon Is Invisible or Intermittently Visible in First Person Mode 288
Weapon Is Pointed the Wrong Way or Is Otherwise Misaligned 289
Footprints Are Not Visible in the Game 289

Character Stutters Forward and Backward During Run 289
Character Does Not Fall Down in Death Cycle 289
Assertion Error During Vertex Merge 290
Character Does Not Complete Animation 290
Summary 290
A
PPENDIX
AO
NTHE
C
OMPANION
CD-ROM 293
I
NDEX
295
This page intentionally left blank
ACKNOWLEDGMENTS
I
wish to thank the editing team at Charles River Media (Emi Smith,
Karen Gill, Jennifer Blaney, and Jenifer Niles) for their help in getting
this book publish-ready. Thanks, too, to my technical editor, Mike
Duggan. Also deserving recognition are the guys who make the Torque
Game Engine available, GarageGames, who directly or indirectly made
this book and the accompanying CD possible. In particular, I want to
thank Joe Maruschak at GarageGames for the great articles and forum
answers that have helped me and many others get a handle on this en-
gine. I also want to thank Autodesk for a great product (3ds Max) and for
the experience I gathered while there; thank you David Koel for making
me a better AE. Cuneyt Ozdas deserves recognition for writing Texporter,
the handy UV renderer. Thanks also to Matt Summers for writing the

Dark Industries exporter, and to Sam Bacsa for writing Codeweaver,
which helped me to work through some of the scripting challenges. Fi-
nally, thanks to Steve Smith at the Art Institute of Colorado for freely
sharing his knowledge while I taught there.
xvii
This page intentionally left blank
ABOUT THE AUTHOR
B
rad Strong, a former Autodesk application engineer, has more
than 18 years of experience using and teaching digital design soft-
ware in the Rocky Mountain region. He holds a master’s in
computer information systems from Denver University/University Col-
lege, where his thesis and capstone project was on game-based learning;
a master’s in management from the University of Phoenix, where his
thesis was on effective CAD utilization; and a bachelor’s in art from the
University of Colorado at Denver.
Brad has developed and taught a range of courses on programming,
art, and game development at art and technical colleges in the Colorado
area. Most recently, he taught 3D modeling, materials and lighting, 3D
animation, and online game development for the Art Institute of Col-
orado. Since 2002, he has been developing 3D learning games. He is the
president of 3dCognition, a game-based learning development studio,
based in Karlskoga, Sweden. The 3dCognition Web site can be found at
.
When he’s not working, Brad enjoys theology, philosophy, bass guitar,
and composing fusion-lounge-gospel music with his wife.
xix
This page intentionally left blank
INTRODUCTION
T

his book focuses on how to create game art properly for a game en-
gine, as well as how to export that art to the engine and make script
changes so that the art becomes a viable part of the game.
Although many of the processes and techniques will apply to specific
modeling, texturing, animation, and game software solutions, this book
will use 3ds Max release 8 to generate models and animations, and the
Torque Game Engine for the game-side examples. These two solutions are
at the forefront of their class; 3ds Max has more than 200,000 registered
users and is used by more top-selling game developers for modeling and
animation than any other solution. The Torque Game Engine enjoys a
solid reputation as the most powerful and affordable solution for the small
game development studio, in addition to being a viable choice for students
and hobbyists.
Much of this book comes from my own tribulations as an instructor
for modeling, texturing, animation, and game development courses. A
good instructor learns over a period of semesters and years how to get the
information across as efficiently as possible to minimize everyone’s (his
own included!) frustration.
An equal part of this book stems from my own frustrations as a game
developer for the past five years. It was from my own notes on what was
working and what wasn’t, combined with my own interpretation of the
resources at the Torque Web site (), that
many of these pages were birthed.
Because this book covers so many aspects of game art (modeling, un-
wrapping, texturing, rigging, animation, exporting, scripting), it will be
impossible to drill too deeply into any one area. However, the goal of this
book is to provide step-by-step exercises and video tutorials that a serious
student can use to create and successfully import game art, from simple
shapes to full-blown characters. There should be more than enough here
for the accomplished or aspiring artist/animator to gain an understanding

of how to create game art and how to make it come alive in a 3D engine.
xxi
Multimedia is a powerful medium because it engages so many of our
senses. 3D games are the highest and most compelling form of multime-
dia, because they add competition, instant feedback, immersion, and ad-
venture. We are motivated, challenged, and empowered to do things we
could not do otherwise. The future of game development is promising,
and I believe that the future for game-based learning and interactive sim-
ulations is particularly bright. Math, for example, is a dry subject, but if
solving a few equations will help me fly to a far star, I might be interested.
If you have questions or comments on this book, feel free to e-mail
them to As feedback is generated from this book,
any noteworthy corrections or additions will be available at http://www.
3dCognition.com.
I hope that this book is instrumental in making your game ideas real.
xxii Creating Game Art for 3D Engines
CHAPTER
1
INTRODUCTION TO 3DS MAX
1
In This Chapter
• Examining the 3ds Max Interface
• Creating, Viewing, and Modifying Primitives
• Box Modeling a Chair
• Working with the Material Editor
• Managing Files
2 Creating Game Art for 3D Engines
T
his chapter introduces some of the foundational features of 3ds Max for the
benefit of those who have limited or no experience. Please keep in mind that

for complete coverage of 3ds Max, you should work through a book that is
focused solely on that product. Even then, the vast majority of 3ds Max users do not
use or understand the entire functionality of the product. Because the goal of this
book is to generate game assets and make them functional in the game, we will only
discuss those foundational aspects of 3ds Max that directly pertain to our goal.
We will overview the 3ds Max interface, primitives, viewing tools and options,
transforms, properties, Editable Polys, and basic materials. Each version of 3ds Max
adds a vast amount of functionality; however, on the whole, the look and feel of 3ds
Max has not changed for several releases. This tutorial and the files on the CD-ROM
are being made with Release 8. The features used are primarily found in Release 7
and earlier; Release 8 features will be noted when used. If you are using a version of
3ds Max as early as 4 or 5, you should still be able to follow and apply the majority
of what will be discussed in this book.
E
XAMINING THE
3
DS
M
AX
I
NTERFACE
The features of 3ds Max continue to improve with each release, but the general
interface has stayed consistent. We will begin with a brief overview of the interface,
and then we’ll jump right into creating some 3D primitives. The intent here is to stay
laser-focused on those foundational tools and techniques that will help us to build
pickups, weapons, and characters in the following chapters. This walk-through will
be done project-style, so we will discuss the different tools as we come to them in
each project. Our first project will be to model a simple chair.
In Figure 1.1, at the top of the screen, you have drop-down menus with a Stan-
dard toolbar immediately below. If your screen resolution is 1024 × 768, the entire

toolbar will not fit on the screen; therefore, you will need to drag it to the right and
left as you work so that you can see the entire set of tools. To the right are the pan-
els. There are panels for Create, Modify, Hierarchy, Motion, Display, and Utilities.
This is typically one of the most heavily used areas of the interface. In this image, the
Create panel is focused on the Geometry tools. This is where you find primitives,
such as boxes, cylinders, and spheres.
At the bottom of the workspace is the animation area, where you can set and
modify keyframes.
At the lower right are the viewing tools. These tools will change based on whether
you are in a perspective view, an orthographic view (such as front, right, back, or top),
or if you are looking through a camera.
The area in the middle is the workspace. By default, you have four viewports. You
can activate any viewport by right-clicking in it. At any time, you can toggle between
four viewports or one viewport by clicking the Maximize Viewport toggle, which
resides in the lower right-hand corner of the screen. If you click the Maximize View-
port toggle while a particular viewport is active, that viewport becomes maximized.
Clicking the toggle again returns you to a four-viewport interface. Click this button a

×