Monday, April 28, 2014

Learn PhysX Modeling with PhysX: A Review

Recently, Packt publishing has released a new book on Game Physics called Learning Physics Modeling with PhysX Examining the accompanying code tells me that the author has shamelessly copied some of my tutorial code into this book. While I am not asking anything from neither the author nor the publisher but at least an acknowledgement or a reference to the original tutorials/source code should have been given in the book as the main source of this text or at least a mention some where in the book's source codes.

Here is my review for this book. The book starts with a gentle introduction to PhysX v 3.3.0 in Chapter 1. Chapter 2 is a copy of my simple box tutorial with the only difference being that the author does not render anything on screen; he simply outputs the box position to console. Chapter 3,4,5,6,7,8,9,10 are ripped from the PhysX guide. All of the code snippets as well as the figures are taken from the PhysX guide. There are no concrete use cases given in any of these chapters. I would suggest the reader to follow the official PhysX guide rather than reading through these chapters as the former is more elaborate. Apart from the simple box tutorial, the author has given his own examples for instance one on particles, character controller, joint, queries are based of PhysX guide.

All in all, I would ask the readers not to buy this book. Save your money as the information contained in this book is available for free both online and in the free PhysX guide. The books sample codes are good. You can read them alongside the PhysX guide which should be enough to understand whats going inside.
 
.

Friday, April 18, 2014

C++ port of the TraerPhysics library

I have ported the famous Processing Physics library called TraerPhysics to C++. I have put it on github for others to use. Refer to the readme.md file for details.

Thanks,
Mobeen

Tuesday, April 1, 2014

Havok Physics Engine Tutorial Series: Cloth

Before I start this tutorial, a short disclaimer. This is not the best way to model a cloth. Havok Physics SDK has a separate Havok Cloth package which is optimized for cloth simulation. I would recommend you to go and give it a try. The tutorial is showing one possible way to create cloth using distance constraint.
 
In this tutorial, I will show you how to create a simple cloth using the simple distance constraint which is wrapped into the hkpStiffSpringConstraint object in the Havok Physics SDK. This tutorial will be building on top of to the Simple Distance Constraint Tutorial , Picking Tutorial and Chain Tutorials that we did earlier. OK so lets get started.

Creating a cloth using simple distance constraint
A cloth can be modeled simply by using a set of masses linked with mass less springs. The springs can be approximated using hkpStiffSpringConstraint in Havok physics sdk. There are three types of springs: structural, shear and bending springs. Details of the cloth model are beyond the scope of this tutorial. Interested readers may drop in a comment and I will happily point you to relevant resources on cloth modeling. The first thing we need is a set of masses which we create using the following code snippet.


This is similar in spirit to the Multiple Bouncing Boxes Tutorial. The only difference is in the position of the boxes so that they lie in the XZ plane at a given Y value.

Setting up structural springs between the masses
OK once we lay down our masses, we can create a bunch of springs between them using the following code snippet. We basically iterate between each pair of rigid bodies and create a stiff spring constraint between them. First we iterate horizontally and then vertically.


I store the indices into a vector so that I would render the cloth springs easily in the OnRender function.

Rendering of Cloth
For this simple cloth model, I render the masses as boxes as was shown in the Multiple Boxes tutorial.


For springs, I iterate through the vector (indices), and create a line between each pair of indices as shown in the code below.


Output
That's all, after compiling and building the given code, you will see a piece of cloth. The mass at each end of the top row are fixed to ensure that the cloth does not fall down. The rest of the boxes can be picked.

You can get the full source code from my github repo https://github.com/mmmovania/HavokPhysicsTutorials

Controls:
Left click to rotate, left click and drag on a mass to pick and reposition
Middle click to zoom
Right click to pan

What's next:
In the next tutorial, I will show you how to create a basic vehicle.

Thanks,
Mobeen

Popular Posts

Copyright (C) 2011 - Movania Muhammad Mobeen. Awesome Inc. theme. Powered by Blogger.