Physics Programming

Here's my detail explanation how I went through my physics collision and how I integrated NVIDIA PhysX in Revoker Engine

Tools : C++,GLSL ,OpenGL, NVIDIA PhysX

Physics Programming

Physics Collisions

I’ve created simple collision test cases using resources from a book to understand both basic and advanced physics concepts.

Techincal View

Initially created a custom Physics engine with manual physics calculation of handling collision systems and gravity.

Bounding Volume Hierarchy (BVH) Collision

Bounding Volume Hierarchy (BVH) Collision

Techincal View

To handle collisions efficiently, I partition the AABB until it reaches a specified depth value, creating smaller portions of the AABB. This process generates a hierarchical tree with a root, and I recursively partition the AABB until the desired depth is reached.


I created a BVHNode class which handles for recursive split.

In the video, I've recorded the code snippet of how I check collision between them.

For collision, I would check an AABB intersects with the BvhNode and return the result.

Softbody Physics

Softboy physics is something which allows for realistic simulations of materials like cloth, jelly, and rubber. For my soft body physics implementation, I used the Verlet integration method, referencing Sebastian's Unity video for guidance. Here’s how I approached it:

Simulation Process:


Updating Points: I updated the points by calculating the difference between their current and previous positions to determine the direction and update the velocity of each point.


Updating Sticks: I then updated the sticks by calculating the difference from their rest length, adjusting the positions of connected points to maintain the constraints.

This approach allows for realistic simulation of soft body dynamics, capturing the elastic and flexible behavior of deformable objects.


Mesh Vertices as Points : I started by taking the mesh vertices and storing them in a struct called Point, which contains their current and previous positions.


Connecting Vertices with Sticks: I then created another struct called Stick, used to represent the connections between points. Each vertex is connected to its neighboring vertices, forming multiple stick connections similar to a spiderweb.



PhysX Integration

After diving deep into my physics engine learning, I decided to integrate NVIDIA PhysX. Given that many of my components were inspired by Unity references that I recreated, I leveraged this experience to incorporate PhysX into my engine effectively.

Overview


Integrated the required Libs and DLL files.

  1. Created a PhysX engine Update loop which handles the renders and the simulation.


  2. Colliders Components:

  3. Physics material similar to Unity's

  1. Rigid body which handles the physical simulation


  1. Collision events:

  1. Ray Cast:

  • Other Game Engine

    .

  • Other Game Engine

    .

Softboy physics is something which allows for realistic simulations of materials like cloth, jelly, and rubber.

Softbody Physics

For my soft body physics implementation, I used the Verlet integration method, referencing Sebastian's Unity video for guidance. Here’s how I approached it:

Technical overview

First, I loaded the model using Assimp and stored the animation data, which includes animation clips, bone Node with transformations, and keyframes with time from Assimp. I created a struct called BoneNode that stores the data of bone name, index (aka bone ID), transformation matrix, and child nodes. While loading the model, I would generate Bone hierarchy and set each mesh's vertex with the respective bone ID and the weight by which the vertex is influenced by that bone.

Physics Programming

Here's my detail explanation how I went through my physics collision and how I integrated NVIDIA PhysX in Revoker Engine

Tools Used

C++,GLSL ,OpenGL, NVIDIA PhysX

I'm always open to share about my projects and experiences!

Feel free to connect with me—send a message on LinkedIn or drop an email. I’d be happy to chat!

ibrahim155.developer@gmail.com

+12269989187

Create a free website with Framer, the website builder loved by startups, designers and agencies.