You are previewing Learning Game Physics with Bullet Physics and OpenGL.
O'Reilly logo
Learning Game Physics with Bullet Physics and OpenGL

Book Description

Practical 3D physics simulation experience with modern feature-rich graphics and physics APIs

  • Create your own physics simulations and understand the various design concepts of modern games

  • Build a real-time complete game application, implementing 3D graphics and physics entirely from scratch

  • Learn the fundamental and advanced concepts of game programming using step-by-step instructions and examples

In Detail

Physics simulation is an integral part of almost all game development projects as it is essential to the rules and feel of the game (gameplay) regardless of the project’s scale. Bullet is a 3D Collision Detection and Rigid Body Dynamics Library for games, and special effects for film and animations. Bullet is integrated into many 3D modelers including Maya, Houdini, Cinema 4D, LightWave, and Blender. It is free for commercial use and open source under the permissive ZLib License.

A comprehensive guide to start building games with the Bullet Physics library. Learn how modern physics engines work by implementing key features such as collision event systems, user input handling, and simulation of soft bodies. Then learn to control it all with forces, constraints, and robust object management. This book will reveal what’s going on under the hood of two modern and feature-rich graphics and physics APIs; OpenGL and Bullet Physics.

This book begins by teaching you to write your first OpenGL application, and then dives in to exploring the many features of the Bullet library in a straightforward manner. Each new feature expands upon the last, teaching you more about how physics is simulated in a video game, and how Bullet gives you the power to control every aspect of your simulation. You will learn how to render simple and complex shapes, apply some basic lighting, and construct a simple yet robust rendering system. From here, you will pull back the veil to see what’s going on underneath Bullet Physics, and learn to implement key game logic features through this widely-used and extensive physics library. After you finish this book, you’ll be armed with a wealth of knowledge to tackle the more advanced aspects of game graphics and physics going forward.

Table of Contents

  1. Learning Game Physics with Bullet Physics and OpenGL
    1. Table of Contents
    2. Learning Game Physics with Bullet Physics and OpenGL
    3. Credits
    4. About the Author
    5. About the Reviewers
      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 example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Building a Game Application
      1. Application components
      2. Exploring the Bullet and FreeGLUT projects
      3. Exploring Bullet's built-in demo applications
      4. Starting a new project
      5. Building the application layer
        1. Configuring FreeGLUT
          1. glutKeyboardFunc/glutKeyboardUpFunc
          2. glutSpecialFunc/glutSpecialUpFunc
          3. glutMouseFunc
          4. glutMotionFunc/glutPassiveMotionFunc
          5. glutReshapeFunc
          6. glutDisplayFunc
          7. glutIdleFunc
        2. Initializing FreeGLUT
          1. glutInit
          2. glutInitDisplayMode
          3. glutInitWindowPosition/glutInitWindowSize
          4. glutCreateWindow
          5. glutSetOption
        3. Launching FreeGLUT
      6. Summary
    9. 2. Rendering and User Input
      1. Rendering the scene
        1. Introducing double-buffering
        2. Understanding the basics of a camera
          1. glIdentity
          2. glFrustum
          3. gluLookAt
          4. glViewport
      2. Basic rendering and lighting
        1. Creating a simple box
      3. Let there be light!
        1. Normals
        2. Creating ambient, diffuse, and specular lighting
        3. Understanding depth testing
          1. glLightfv
          2. glEnable
        4. glMaterialfv/glMateriali
          1. glShadeModel
          2. glDepthFunc
        5. Coloring your box
        6. Understanding rendering pipelines
      4. User input and camera control
        1. Implementing camera control
        2. Gathering user input
      5. Summary
    10. 3. Physics Initialization
      1. The core bullet objects
        1. The world object
        2. The broad phase
        3. The collision configuration
        4. The collision dispatcher
        5. The constraint solver
      2. Creating the Bullet components
      3. Creating our first physics object
        1. The collision shape
        2. The motion state
        3. The collision object
      4. Building a custom motion state
      5. Creating a box
      6. Rendering from transform data
      7. Stepping the simulation
      8. Summary
    11. 4. Object Management and Debug Rendering
      1. Handling multiple objects
        1. Designing our objects
        2. Rendering our objects
        3. Storing our objects
        4. Creating our objects
      2. Debug rendering
        1. Building the debug drawer
      3. Introducing activation states
      4. The domino effect
      5. Summary
    12. 5. Raycasting and Constraints
      1. The power of raycasting
        1. Picking rays
      2. Destroying objects
      3. Constraints
      4. Understanding constraints
        1. Picking up objects
        2. Building a constraint
      5. Summary
    13. 6. Events, Triggers, and Explosions
      1. Building a collision event system
        1. Explaining the persistent manifolds
        2. Managing the collision event
      2. Building trigger volumes
        1. Disabling contact response
      3. Force, torque, and impulse
        1. Understanding the object motion
        2. Applying forces
      4. Applying impulses
      5. Summary
    14. 7. Collision Shapes
      1. Spheres and cylinders
      2. Convex hulls
        1. Creating convex hulls from mesh data
      3. Compound shapes
      4. Summary
    15. 8. Collision Filtering
      1. Groups and masks
        1. Defining linear and angular freedom
      2. Summary
    16. 9. Soft Body Dynamics
      1. Soft body requirements
        1. Initialization
        2. Creating soft bodies
        3. Rendering soft bodies
      2. Summary
    17. Index