O-Town Graphics

Thursday, June 08, 2006

A few random thoughts

I've collected a few articles on fluid dynamics. To much of my amazingment, the math doesn't look horribly difficult. After a point you start to shrug off complex math because it is simply just one of those things that you get used to, so you adapt and hack at it.

The advantages of fluid dynamics is it gives you a much more realistic model for modeling smoke, water, fire, and gases. Essentially these fluids act as set of forces that all affect each other like an interconnected grid. A good model will allow you to simulate smoke stacks, nuclear explosions, even flames of fire.

In other news, Irrlicht uses a left-handed coordinate system and it upsets my balance of life. It angers me, just because I'm so used to a right-handed system. How dare they share a model with Direct3D :) Sure it makes sense from a conceptual standpoint, especially since the perspective transformation of OpenGL will flip the z-coordinate anyway in clip space so it becomes left-handed. I digress though.. it still pains me :)

To review, the basic method to convert from a left-handed system to a right-handed system is you must change the order of triangle vertices when importing models - p0 p1 p2 becomes p0 p2 p1 (which thus flips the normals - this is important, otherwise you have all your objects being backface culled, hehe), and then you must flip the z coordinates. Not too bad. Irrlicht also seems to treat the y axis as a z axis and vise-versa when importing 3D Studio models. But I need to verify their codebase to make sure.

When reading my real-time collision detection book by Christer Ericson I can't help but wonder why no one has mentioned thick planes to me before. It seems not only elegant but in some ways practically mandatory as to ensure numerical stability. Case in point - intersect a nearly parallel line segment against a plane using a parametric equation and solve for t, where t = [ 0, 1 ] indicates an interesction. The problem is as the two are closer to parallel, t approaches +- infinity! That is SO not good :) Thus, you must use thick planes and conditional code to solve for things robustly. So what are thick planes? Instead of solving the equation of a plane N.(P-P0)=0, you solve it like N.(P-P0)<epsilon where epsilon is the a very small value. That small value makes the plane "thick". Of course, this simplicity has many rammifications in algorithms (such as clipping), hence you should refer to the Ericson's book for more details. But do not do clipping without it! (That includes BSP tree's, jackass!)