Book Image

Learning Physics Modeling with PhysX

By : Krishna Kumar
Book Image

Learning Physics Modeling with PhysX

By: Krishna Kumar

Overview of this book

<p>In this day and age, physics engines play a very critical role in the success of a sophisticated game. PhysX is a state-of-the-art cross-platform physics engine widely used by top game studios and developers. It contains all the physics-related components you will need and exploits the parallel-processing capability of modern GPUs as well as multi-core CPUs to make a game as physically-realistic as possible. This book will help you to program and simulate games by using PhysX 3.</p> <p>Learning Physics Modeling with PhysX helps you to master physics simulation using the PhysX Physics Engine from scratch. This is useful not only for game developers, but also for developers making virtual walkthroughs or training and other simulation applications. It will cover all the essential features of PhysX 3 with easy-to-understand code snippets and examples to help you learn quickly and efficiently.</p> <p>This book will start off by introducing you to the basic concepts of physic engines and will give you a glimpse of PhysX implementation. We then gradually cover more sophisticated topics with sample source code so that you can see what you have learned in action. We will cover the history and features of the PhysX SDK as well as how to configure it with the C++ compiler. After touching upon essential topics like rigid body dynamics and collision detection, we will gradually move on to more advanced topics like joints, scene queries, character controllers, particles, and cloth simulation. By the end of this book, you will have learned everything you need to know about the PhysX 3 Physics Engine, and you will be able to use it to program your very own physics simulation quickly and efficiently.</p>
Table of Contents (17 chapters)
Learning Physics Modeling with PhysX
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Raycast queries


The raycast query is a way to detect collisions by using rays, just like how we use the laser pointing device during any slide show presentation, which creates a red dot on the first object its ray collides with. Raycast queries have many uses, such as detecting bullet collision point in an FPS game, checking line of sight for the enemy characters, and selecting in-game objects by using a mouse.

In PhysX, raycasting is done by calling the PxScene::raycast() function and it can be used in different modes depending on the arguments you are passing to the function; they are described as follows:

  • raycast() with PxRaycastBuffer buf and PxQueryFlag::eANY_HIT

  • raycast() with PxRaycastBuffer buf and a default constructor

  • raycast() with PxRaycastBuffer buf(PxRaycastBuffer, PxU32)

When using the raycast() function with PxQueryFlag::eANY_HIT, it just returns true on colliding with any PhysX object. It is the least expensive to call, because it doesn't perform any calculation related...