c++ - Bullet Physics - Orienting a rigid body -
i'm trying orient cylinder in bullet. right now, cylinder thing in simulation. have found answers here, , believe close, still no rotation. here function creating cylinder, maybe jump out @ someone.
what doing incorrectly?
void createcylinder(int index, double x, double y, double z, double radius, double length, int yaw, int pitch, int roll) { btscalar mass = 1; btvector3 position(x,y,z); btvector3 cylinertia(0,0,0); //create collision shape btcollisionshape* cylcoll = new btcylindershape(btvector3(radius,length,1)); //default motion state btdefaultmotionstate* ms = new btdefaultmotionstate(bttransform(btquaternion(0,0,0,1), btvector3(0,10,0))); //calculate inertia cylcoll->calculatelocalinertia(mass, cylinertia); //construction info btrigidbody::btrigidbodyconstructioninfo cylci( mass, ms, cylcoll, //collision shape cylinertia //inertia ); btrigidbody *cylinder = new btrigidbody(cylci); //orient cylinder bttransform tr; tr.setidentity(); btquaternion quat; quat.seteuler(yaw,pitch,roll); //or quat.seteulerzyx depending on ordering want tr.setrotation(quat); //apply transform cylinder rigid body cylinder->setcenterofmasstransform(tr); body[index] = cylinder; m_dynamicsworld->addrigidbody(body[index]); }
you must modify body's worldtransform
, not centerofmasstransform
. can in defaultmotionstate on body itself.