logo资料库

Learning Game Physics with Bullet Physics and OpenGL.pdf

第1页 / 共126页
第2页 / 共126页
第3页 / 共126页
第4页 / 共126页
第5页 / 共126页
第6页 / 共126页
第7页 / 共126页
第8页 / 共126页
资料共126页,剩余部分请下载后查看
Cover
Copyright
Credits
About the Author
About the Reviewers
www.PacktPub.com
Table of Contents
Preface
Chapter 1: Building a Game Application
Application components
Exploring the Bullet and FreeGLUT projects
Exploring Bullet's built-in demo applications
Starting a new project
Building the application layer
Configuring FreeGLUT
glutKeyboardFunc/glutKeyboardUpFunc
glutSpecialFunc/glutSpecialUpFunc
glutMouseFunc
glutMotionFunc/glutPassiveMotionFunc
glutReshapeFunc
glutDisplayFunc
glutIdleFunc
Initializing FreeGLUT
glutInit
glutInitDisplayMode
glutInitWindowPosition/glutInitWindowSize
glutCreateWindow
glutSetOption
Launching FreeGLUT
Summary
Chapter 2 : Rendering and User Input
Rendering the scene
Introducing double-buffering
Understanding the basics of camera
glIdentity
glFrustum
gluLookAt
glViewport
Basic rendering and lighting
Creating a simple box
Let there be light!
Normals
Creating ambient, diffuse, and specular lighting
Understanding depth testing
glLightfv
glEnable
glMaterialfv/glMateriali
glShadeModel
glDepthFunc
Coloring your box
Understanding rendering pipelines
User input and camera control
Implementing camera control
Gathering user input
Summary
Chapter 3 : Physics Initialization
The core bullet objects
The world object
The broad phase
The collision configuration
The collision dispatcher
The constraint solver
Creating the Bullet components
Creating our first physics object
The collision shape
The motion state
The collision object
Building a custom motion state
Creating a box
Rendering from transform data
Stepping the simulation
Summary
Chapter 4 : Object Management and Debug Rendering
Handling multiple objects
Designing our objects
Rendering our objects
Storing our objects
Creating our objects
Debug rendering
Building the debug drawer
Introducing activation states
The domino effect
Summary
Chapter 5 : Raycasting and Constraints
The power of raycasting
Picking rays
Destroying objects
Constraints
Understanding constraints
Picking up the objects
Building a constraint
Summary
Chapter 6 : Events, Triggers, and Explosions
Building a collision event system
Explaining the persistent manifolds
Managing the collision event
Building trigger volumes
Disabling contact response
Force, torque, and impulse
Understanding the object motion
Applying forces
Applying impulses
Summary
Chapter 7 : Collision Shapes
Spheres and cylinders
Convex hulls
Creating convex hulls from mesh data
Compound shapes
Summary
Chapter 8 : Collision Filtering
Groups and masks
Defining linear and angular freedom
Summary
Chapter 9 : Soft Body Dynamics
Soft body requirements
Initialization
Creating soft bodies
Rendering soft bodies
Summary
Index
www.allitebooks.com
Learning Game Physics with Bullet Physics and OpenGL Practical 3D physics simulation experience with modern feature-rich graphics and physics APIs Chris Dickinson BIRMINGHAM - MUMBAI
Learning Game Physics with Bullet Physics and OpenGL Copyright © 2013 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, 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 information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: October 2013 Production Reference: 1181013 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78328-187-9 www.packtpub.com Cover Image by Abhishek Pandey (abhishek.pandey1210@gmail.com) www.allitebooks.com
Credits Author Chris Dickinson Proofreader Lesley Harrison Reviewers Marco Altomonte Ian Voyce Acquisition Editor Vinay Argekar Commissioning Editor Poonam Jain Technical Editor Shali Sasidharan Project Coordinator Amigya Khurana Indexer Monica Ajmera Mehta Graphics Ronak Dhruv Yuvraj Mannari Abhinash Sahu Production Coordinator Nitesh Thakur Cover Work Nitesh Thakur www.allitebooks.com
About the Author Chris Dickinson grew up in England with a strong passion for science, mathematics, and, in particular, video games. He received his Master's degree in Physics with Electronics from the University of Leeds in 2005, and then left for California to work in scientific research in the heart of Silicon Valley. Finding that career path unsuitable, he began working in software testing and automation. For years, he attempted to unravel the magic behind video games and 3D worlds through modding and level design, and was mostly self taught in software development and design. But, realizing that he needed proper tutelage and a stronger grasp of the fundamentals, if he ever wanted to build these complex applications himself, he decided to undertake a Bachelor's in Game and Simulation Programming while simultaneously working full time. He earned his second degree in early 2013 and continues his career in software development/test automation while simultaneously developing independent game projects in his spare time. I would like to thank my wonderful wife and best friend, Jamie, for always being supportive, and eager to help; not to mention, for putting up with me and my never-ending list of projects and erratic work schedule. I'd also like to extend a warm thanks to the good folks at Blizzard Entertainment for bringing us together through a shared addiction to World of Warcraft. Also, my friends, for their constant pestering and high expectations of me to get things done, and, of course, my family for unleashing me on the world and giving me all of the possibilities I was able to explore. To have learned, lived, and loved so much in such a short space of time is only thanks to the opportunities and motivation given to me by all of you. www.allitebooks.com
About the Reviewers Marco Altomonte is working for Milestone S.r.l. on the graphics engine used in multiplatform video games, such as MotoGP, World Rally Championship, and SBK. He developed the XNA game, RC Racing 360, published on Microsoft Live Marketplace for Xbox 360. He worked for ALTAIR Robotics Lab in Robotics and Physics Simulation department. He developed a GPGPU (General-purpose computing on graphics processing units) soft body simulator with haptic feedback for a surgeon training software. He authored Simulation of deformable environment with haptic feedback on GPU, published in Proceedings 3959-3964, IROS 2008: International Conference on Intelligent Robots and Systems. Ian Voyce is a developer with a broad range of experience gained over many years in the software industry. He has worked for a variety of clients from advertising agencies to investment banks, as well as made several independent releases to the Apple AppStore. He has a background in creative computing and user experience with in-depth technical knowledge and a professional specialism in quantitative development. He tries to find the time to combine his favorite pursuits of blogging (at www.voyce.com), creating and playing games, and spending quality of time with his two daughters. www.allitebooks.com
www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire 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 entirely free books. Simply use your login credentials for immediate access. www.allitebooks.com
Table of Contents 1 7 7 8 9 10 11 11 13 13 13 13 14 14 14 14 15 15 15 15 15 16 17 19 19 20 22 23 23 24 24 Preface Chapter 1: Building a Game Application Application components Exploring the Bullet and FreeGLUT projects Exploring Bullet's built-in demo applications Starting a new project Building the application layer Configuring FreeGLUT glutKeyboardFunc/glutKeyboardUpFunc glutSpecialFunc/glutSpecialUpFunc glutMouseFunc glutMotionFunc/glutPassiveMotionFunc glutReshapeFunc glutDisplayFunc glutIdleFunc Initializing FreeGLUT glutInit glutInitDisplayMode glutInitWindowPosition/glutInitWindowSize glutCreateWindow glutSetOption Launching FreeGLUT Summary Chapter 2: Rendering and User Input Rendering the scene Introducing double-buffering Understanding the basics of a camera glIdentity glFrustum gluLookAt glViewport www.allitebooks.com
分享到:
收藏