PhysX SDK is a mature physics engine, which has been under development since 2004. It was developed by Ageia with the purchase of ETH Zurich spin-off NovodeX. Ageia was a fabless semiconductor company and the first company that developed a dedicated co-processor capable of performing physics calculations, which was much faster than the general purpose CPUs available at that time.
The intention of Ageia was to sell PPU (Physics Processing Unit) cards much like the dedicated GPU (Graphics Processing Unit) cards that we buy today. It developed the PhysX software SDK (formerly NovodeX SDK) to harness the processing power of a PPU. The company also licensed out the PhysX SDK as a physics middleware library for game production. Unfortunately, the PPU cards didn't sell very well commercially in the market. On February 4, 2008, Nvidia announced that it would acquire Ageia. On February 13, 2008, the merger was finalized. The PhysX engine is now known as Nvidia PhysX. The potential reason of Ageia acquisition by Nvidia was to implement PhysX on top of their CUDA architecture enabled GPU(s), for hardware-accelerated physics processing. The PhysX GPU acceleration is exclusive to Nvidia GPU(s), which gives Nvidia an edge over its competitors; that is, GPU manufacturers such as ATI/AMD.
PhysX SDK 3.3.0 is the latest release at the time of writing this book. PhysX 3.x features a new modular architecture and a completely rewritten PhysX engine. It provides a significant boost in overall performance as well as efficiency. It is a heavily-modified version written to support multiple platforms but has a single base code. Supported platforms include Windows; Linux; Mac OS X; game consoles such as XBOX 360 and PS3; and even Android-powered handheld devices. PhysX 3.3.0 added support for new platforms such as Xbox One, PS 4, Nintendo Wii U, Apple iOS, PS Vita, and Windows RT. PhysX SDK 3.x has undergone architecture and API improvement, and the code is cleaned at many levels to get rid of obsolete and legacy features and to integrate new physics capabilities.
Nvidia PhysX is a state-of-the-art physics engine, which provides the following features:
Rigid body dynamics: Rigid body dynamics is the most essential aspect of physics simulation, and makes use of physics concepts such as position, velocity, acceleration, forces, momentum, impulse, friction, collision, constraints, and gravity. These properties give us the power to simulate or mimic real-world physics scenarios.
Character controller: Character controller is a special type of physics collider, which is mainly used for third-person or first-person player control, or any other kinematic body that may want to take advantage of the properties associated with the character controller.
Vehicle dynamics: Vehicle dynamics gives you the capability to simulate vehicle physics by using spherical wheel shapes that can simulate sophisticated tire friction models. A joint-based suspension system is used for vehicle suspension.
Particles and fluid simulation: Two of the most exciting features of PhysX are particles and fluid simulation. These features can be used to achieve a vast variety of cinematic effects. Particles can used for creating effects such as fire, spark, and debris, whereas fluid particles, also known as SPH (Smoothed Particle Hydrodynamics), are used to simulate liquid, gases, smoke, or any other SPH-based particle effect.
Cloth simulation: This feature allows you to simulate realistic cloth, which can be used for cloth simulation of the characters in the game or any other cloth-based objects, such as flags and curtains. These cloth objects can also be stretched, torn, or attached to other physical bodies.
Softbody simulation: This feature allows you to simulate volumetric deformable objects.
Notable features in PhysX 3 are as follows:
Automatic and efficient multithreading, and a unified code base for all supported platforms.
Improved task manager and a managed-thread pool that is optimized to harness the processing capability of multi-core processors on all platforms.
A new aggregate concept in which multiple PhysX actors can be combined into one entity having a common collision boundary, which simplifies processing when large numbers of objects are involved.
A new binary in-place serialization by which we can efficiently insert the PhysX actors into a scene with minimal data copying and without extra memory allocation. Creation and destruction of actors is now decoupled from the insertion and removal of scenes, thus allowing flexible asset management strategies.
A highly optimized physics runtime that has better a response time, with lower memory footprints.
A new release of PhysX Visual Debugger (PVD) that allows for better performance profiling and in-depth memory analysis with enhanced visualization of all PhysX content across all major platforms.
A full vehicle model that includes components such as engine, clutch, gears, autobox, differential, wheels, tires, suspension, and chassis.
Downloading PhysX SDK requires you to register as an Nvidia developer, which you can do for free at https://developer.nvidia.com. Once you have successfully created a Nvidia developer account, you need to apply for the APEX/PhysX Registered Developer Program, which you can find by clicking on My Account on the top right of the Nvidia developer web page. The approval request may take one to three business days to process.
After the successful approval of your APEX/PhysX Registered Developer Program request, click on PhysX/Tools Download, select your platform, and then download the PhysX SDK. Please note that for this book, we will download the SDK for PC (Windows) platform. Configuration to include the PhysX SDK's Include
files and Library
files that are covered in this chapter is also for the Windows platform.
The Nvidia PhysX SDK is totally free for the Windows platform, both commercial and noncommercial use. For Linux, OS X, and Android platforms, the Nvidia binary PhysX SDK and tools are free for educational and noncommercial use. For commercial use, the binary SDK is free for developers who work on their respective PhysX applications and make less than $100K in gross revenue. More information on license agreements can be found at https://developer.nvidia.com/content/physx-sdk-eula.
The minimum requirements to support the hardware-accelerated PhysX is an Nvidia GeForce 8 series or later GPU with a minimum of 32 CUDA cores and a minimum of 256 MB of dedicated graphics memory. However, each PhysX application has its own GPU and memory recommendations. In general, 512 MB of graphics memory is recommended unless you have a GPU that is dedicated to PhysX. The Nvidia graphics drivers are made in such a way that they can also take advantage of multiple GPU(s) in a system. These can be configured to use one GPU for rendering graphics and the second GPU only for processing PhysX physics.
We will use Microsoft Visual C++ 2010 Express for compiling the PhysX program. It is freely available at www.microsoft.com. We have to include the PhysX library files and header files in VC++ Directories that can be found at View | Property Pages. Property Pages can also be modified from Property Manager. A Property Manager window enables us to modify project settings that are defined in property sheets. A project property sheet is basically an .xml
file that is used to save project configurations and can also be applied to multiple projects because it is inheritable.
Configuring VC++ 2010 Express requires the following steps:
After downloading the PhysX 3.x SDK for the Windows platform, which comes in a ZIP file, you need to extract it to any preferred location on your PC. For this book, we will extract the PhysX SDK's ZIP file to
C:\dev
. Finally, our PhysX SDK location will look likeC:\dev\PhysX-3.3.0_PC_SDK_Core
.Before including the PhysX library files and header files in Property Manager, we first need to create a new Visual C++ Win32 Console application. To do this, open your MS VC++ compiler from the toolbar and navigate to File | New | Project. Then, a New Project window will pop up. Select Win32 Console Application and also provide Name and Location for the project. Finally, click on the OK button to proceed further as shown in the following screenshot:
Soon after, a Win32 Application Wizard window will pop up. Here, click on the Next button to get the Application Settings screen, where you need to make sure that the Empty project option is checked under Additional options. Finally, click on the Finish button as shown in the following screenshot:
Next, we need to configure our project's VC++ directories so that it can find the PhysX SDK header files and libraries that are required for compiling the PhysX program. We will include the absolute path for PhysX SDK Include Directories and Library Directories. To do this in VC++ 2010 Express, navigate to View | Property Manager. If the Property Manager option is not visible there, navigate to Tools | Settings and select Expert Settings; this will enable the Property Manager option in View. In the Property Manager window, double-click on a configuration-and-platform node, for example, Debug | Win32 or Release | Win32, as shown in the following screenshot:
Double-clicking on a configuration-and-platform node, such as Debug | Win32 or Release | Win32, will open Property pages for the respective node configuration, such as, Debug Property Pages or Release Property Pages. This can also be opened by navigating to View | Property pages.
When configuration-specific Property Pages (namely Debug Property Pages or Release Property Pages) will pop up, select VC++ Directories and add the following entries:
Select Include Directories and then click on <Edit...> to add
C:\dev\PhysX-3.3.0_PC_SDK_Core\Include
.Select Library Directories and then click on <Edit...> to add
C:\dev\PhysX-3.3.0_PC_SDK_Core\Lib\win32
(for a 32-bit platform) orC:\dev\PhysX-3.3.0_PC_SDK_Core\Lib\win64
(for a 64-bit platform).
Finally, click on the OK button to save your changes and close the window.
These PhysX SDK directory settings are saved on a per user basis and not on per project basis. So whenever you create a new VC++ project in VC++ 2010 Express, PhysX directories will automatically be added to your Include Directories
project. We are now finally done with the PhysX configuration in VC++ 2010 Express. In the next chapter, we will create our first PhysX program.
This chapter enlightened us with all of the basic PhysX-related information that is needed to proceed with the rest of this book. We learned how to register as a Nvidia developer and download the PhysX SDK from the Nvidia website. We also learned how to include the PhysX SDK files in Visual C++ 2010 for compiling PhysX programs.