Bullet physics物理引擎學習筆記
Bullet 物理引擎的參考文件比較少,主要是通過學習Bullet自帶的例子來學習。以下是我在學習中遇到的一些困惑和自己的理解:
1. collisionshape和rigidbody的區別:
碰撞形狀顧名思義只需要指定碰撞體的形狀,常用的碰撞體形狀有:btBoxShape等。
剛體要指定的資訊比較多,包括質量,運動狀態,碰撞體形狀,慣性。多個剛體可能共用相同的碰撞形狀。
2. 在dynamicworld中設定剛體的位置
先將物體位置通過setIdentity()初始化為0,然後通過setOrigin(btVector3 pos)來設定物體質心的位置。特別需要注意的,btBoxShape( const btVector3& boxHalfExtents),這個函式形參是半個box的大小。
3. 通過匯入obj等三維模型在bullet中建立剛體時bullet會計算自動該剛體的質心,非常強大!
4.The world transform of a rigid body is in Bullet always equal to its center of mass, and its basis also defines its local frame for inertia.
World transform of the center of mass for rigid bodies, transformed vertices for soft bodies
ATTRIBUTE_ALIGNED16(type) variablename creates a 16-byte aligned variable
5.Bullet uses a small collision margin for collision shapes, to improve performance and reliability of the collision detection. It is best not to modify the default collision margin, and if you do use a positive value: zero margin might introduce problems.
6.3D orientations and rotations can be represented using either btQuaternion or btMatrix3x3.
btTransform is a combination of a position and an orientation. It can be used to transform points and vectors from one coordinate space into the other. No scaling or shearing is allowed.
7.Right-handed coordinate system in bullet
8.