Sorry if this is a really basic question, but I've been trying to figure this out for a bit now, and I thought I could save myself some time by asking y'all. The best info I've found from searching this site came from this issue topic (https://code.google.com/p/bullet/issues/detail?id=413), but it only gives an outline on how to do what I want to.
There are two problems that I'm coming across, although I realize I might be coming at this problem from the wrong way.
1):
I'm trying to get the inertia tensor for a btRigidBody/btCollisionShape in a hinge joint. I'm using hinge_pointer->getRigidBodyA().getCollisionShape() to get at the btCollisionShape, and that compiles fine; but when I try to call calculateLocalInertia() from that btCollisionShape my code doesn't compile. Do I need to call calculateLocalInertia() from a specific shape (i.e. btSpereShape)? If so, how do I do that?
2):
Even if I could get the above working, I don't know what I do once I use calculateLocalInertia(), because from the documentation it looks like it doesn't output anything--it only sets the internal 'inertia' variable.
Code: Select all
65 void btSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
66 {
67 btScalar elem = btScalar(0.4) * mass * getMargin()*getMargin();
68 inertia.setValue(elem,elem,elem);
69
70 }
How would I access this variable? I want to use it to help modulate the force used by the hinge's motor.
To be clear, all I'm trying to do is calculate or access a btCollisionShape's inertia tensor at a given time-step; so if the above attempt makes no sense to you, please disregard that and point me in the direction of the proper way to get at the inertia.
Thank you for your time,
Josh