c++ - Box doesn't roll in Bullet Physics -
as can see in image, box doesn't roll slides on slope.
here how create box in code,
config = new btdefaultcollisionconfiguration(); dispatcher = new btcollisiondispatcher(config); broadphase = new btdbvtbroadphase(); solver = new btsequentialimpulseconstraintsolver(); bworld = new btdiscretedynamicsworld(dispatcher, broadphase, solver, config); bworld->setgravity(btvector3(0, -9.8f, 0)); // ... bttransform t; t.setidentity(); t.setorigin(btvector3(position.x, position.y, position.z)); btboxshape* box = new btboxshape(btvector3(size.x, size.y, size.z)); btvector3 inertia(0, 0, 0); float mass = 10.f; box->calculatelocalinertia(mass, inertia); btmotionstate* mstate = new btdefaultmotionstate(t); btrigidbody::btrigidbodyconstructioninfo cinfo(mass, mstate, box); //cinfo.m_restitution = 0.4f; //cinfo.m_friction = 0.5f; btrigidbody* body = new btrigidbody(cinfo); //body->setlinearfactor(btvector3(1,1,0)); //body->setangularfactor(btvector3(0,0,1)); m_impl->bworld->addrigidbody(body);
i tried friction , other parameters result same. let me know i'm doing wrong here.
you need pass inertia
vector btrigidbodyconstructioninfo
. check 4th parameter on btrigidbodyconstructioninfo
constructor (the 1 default value).
Comments
Post a Comment