I finally had a success by integrating bullet in my modification.
Here's a video : http://www.youtube.com/watch?v=sc0Gnpipt4I
As you can see, it's very slow, if I increase the gravity, the objects shake around all the time and it's unstable.
Is there another way to make a faster simulation ?
In the end of the video, the cubes are flashing, there is another problem in the angles, here's the output each frame :
Code: Select all
89.976227 94.429276 -121.999039
89.976807 102.566681 -113.861641
-1.#IND00 -86.173752 57.397865
89.975487 -121.755554 21.816078
89.984230 -75.655006 67.916634
-1.#IND00 -87.542641 56.028996
89.966919 93.990807 -122.437546
-1.#IND00 104.383301 -112.045090
89.950333 -11.514298 132.057098
89.975677 -106.485023 37.086777
-1.#IND00 -70.515511 73.056213
89.978676 92.123039 -124.305275
89.981857 69.030800 -147.396729
-1.#IND00 66.479553 -149.948380
-1.#IND00 68.244347 -148.183578
89.989868 75.375633 -141.052307
-1.#IND00 -82.589790 60.982040
89.977440 -6.836949 136.734985
-1.#IND00 74.711380 -141.716675
89.980804 -121.056732 22.515261
89.972801 -58.335423 85.236595
89.976555 -80.269928 63.301830
89.982849 92.357216 -124.070923
-1.#IND00 74.407661 -142.020462
-1.#IND00 76.497597 -139.930511
Code: Select all
btVector3 ang;
btQuaternion qang;
tra.getBasis().getRotation(qang);
QuaternionToEulerXYZ(qang,ang);
newang[2] = ang.getX();
newang[0] = ang.getY();
newang[1] = ang.getZ();
newang[2] *= GRAD_PI;
newang[0] *= GRAD_PI;
newang[1] *= GRAD_PI;
VectorCopy(newang,get->s.angles);
VectorCopy(newang,get->r.currentAngles);
VectorCopy(newang,get->s.apos.trBase);
Code: Select all
void QuaternionToEulerXYZ(const btQuaternion &quat,btVector3 &euler)
{
btScalar w=quat.getW(); btScalar x=quat.getX(); btScalar y=quat.getY(); btScalar z=quat.getZ();
double sqw = w*w; double sqx = x*x; double sqy = y*y; double sqz = z*z;
euler.setZ((atan2(2.0 * (x*y + z*w),(sqx - sqy - sqz + sqw))));
euler.setX((atan2(2.0 * (y*z + x*w),(-sqx - sqy + sqz + sqw))));
euler.setY((asin(-2.0 * (x*z - y*w))));
}
Thanks,
Eltran.