- where should I implement the aerodynamic model?
- In a custom btMotionState handler?
- Once before calling stepSimulation(), calling applyForce()?
- derive btRigidBody and override something?
- edit: digging through the API suggests the appropriate thing is to implement a btActionInterface... i'm looking at btRaycastVehicle as an example, is this correct?
- what reference frame is the input to btRigidBody::applyForce()?
- global?
- local?
- what reference frame is the output of btRigidBody::getLinearVelocity()?
- edit: found this one: it's global... so is there an easy way to get local? I'm guessing I get the transform and apply it?
aerodynamics: where to applyForce(), which reference frame
-
- Posts: 3
- Joined: Wed Dec 15, 2010 3:37 pm
aerodynamics: where to applyForce(), which reference frame
I'm simulating an aircraft and I have some questions that I cant find answers to on the forums. Currently the aircraft is a btRigidBody and I'm hoping I can just call applyForce() somewhere.
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: aerodynamics: where to applyForce(), which reference fra
Not sure I can give correct answers on everything (hope somebody else answers as well
)
1) I would use a (pre or post) tick callback or the btActionInterface if it's enough. Do some testing...
2) global as far as I remember
3) global. To get the local frame for a quantity like this (basically you need just to rotate it: the position of the body is not relevant), you can try (use the body transform basis as btMatrix3x3):
Commented out there should be equivalent ways of doing the same operation. You can see that in Bullet the inverse of a 3x3 matrix equals the transpose (no scaling allowed) and that the order of the vector * matrix operation is important.
Hope they work (I'm not testing these methods for a while, I'm not 100% sure they work).

1) I would use a (pre or post) tick callback or the btActionInterface if it's enough. Do some testing...
2) global as far as I remember
3) global. To get the local frame for a quantity like this (basically you need just to rotate it: the position of the body is not relevant), you can try (use the body transform basis as btMatrix3x3):
Code: Select all
SIMD_FORCE_INLINE static btVector3 GlobalToLocal(const btMatrix3x3& in,const btVector3& v) {
//return in.transpose() * v;
//return in.inverse() * v;
return v*in; //Equivalent to: in.transpose() * v (which is faster? It should be exactly the same)
}
SIMD_FORCE_INLINE static btVector3 LocalToGlobal(const btMatrix3x3& in,const btVector3& v) {
//return in.getColumn(0)*v.x() + in.getColumn(1)*v.y() + in.getColumn(2)*v.z();
return in*v; // Equivalent (which is faster? It should be exactly the same)
}
Hope they work (I'm not testing these methods for a while, I'm not 100% sure they work).
-
- Posts: 3
- Joined: Wed Dec 15, 2010 3:37 pm
Re: aerodynamics: where to applyForce(), which reference fra
Ok. So the transform basis is a rotation matrix mapping a vector in the local coordinate frame to an equivalent vector in the global/world coordinate frame. I would have guessed it was the other way around, so thanks for that.
I'm currently doing testing trying to make this work with a btActionInterface but it seems that using applyForce() in the update method doesn't do anything... This is weird though because the btRaycastVehicle does apply forces in this method. I'm not sure what is going on. If there's an intended interface, I'd like to use it, rather than testing all possible options.I would use a (pre or post) tick callback or the btActionInterface if it's enough. Do some testing...
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: aerodynamics: where to applyForce(), which reference fra
You may try to use impulses instead of forces (impulses start and end in a single time step). They should work.cheshirekow wrote:it seems that using applyForce() in the update method doesn't do anything...
BTW: The transform basis is just the orientation of the body...
-
- Posts: 3
- Joined: Wed Dec 15, 2010 3:37 pm
Re: aerodynamics: where to applyForce(), which reference fra
Thanks for the suggestion, using impulses in the action interface object seems to be working as I'd hoped.