Hello,
Can you tell me how to simulate a conveyor, please?
Like that: http://www.youtube.com/watch?v=yKGyzcaOuA4&NR=1
Thank you.
How to simulate a conveyor?
-
- Posts: 7
- Joined: Sun Dec 05, 2010 4:59 pm
Re: How to simulate a conveyor?
up, please!
Even a simplified model... I just need that some boxes travel a conveyor.
Even a simplified model... I just need that some boxes travel a conveyor.
Re: How to simulate a conveyor?
Search for motors in Bullet.
- Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
- Contact:
Re: How to simulate a conveyor?
You can use special friction mode, with a target velocity and direction to simulate a conveyor.
See attached BasicDemo.cpp
Thanks,
Erwin
This was earlier discussed here: also http://www.bulletphysics.org/Bullet/php ... f=9&t=3555
Code: Select all
gContactAddedCallback = CustomMaterialCombinerCallback;
///this flag will use the friction information from the contact point, if contactPoint.m_lateralFrictionInitialized==true
m_dynamicsWorld->getSolverInfo().m_solverMode |= SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;
///enable the callback for the ground object
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
{
cp.m_lateralFrictionInitialized = true;
///choose a target velocity in the friction dir1 direction, for a conveyor belt effect
cp.m_lateralFrictionDir1.setValue(0.5,0.5,0.5);
cp.m_lateralFrictionDir1.normalize();
///optionally downscale the friction direction 2 for lower (anisotropic) friction (rather than a unit vector)
btScalar downscale = 1.f;
cp.m_lateralFrictionDir2 = downscale*cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB);
cp.m_contactMotion1 = 1.f;
//cp.m_contactCFM2 = 0.1;
//cp.m_combinedFriction = 10;
//cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1);
return true;
}
Erwin
This was earlier discussed here: also http://www.bulletphysics.org/Bullet/php ... f=9&t=3555
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
- Contact:
Re: How to simulate a conveyor?
If you set the velocity of a static object, you'll get the friction you want even though it remains stationary.
Re: How to simulate a conveyor?
Well, it works .sparkprime wrote:If you set the velocity of a static object, you'll get the friction you want even though it remains stationary.
This easy trick seems to work for static bodies only. Probably the solution Erwin posted is more generic, although more complex.
Thanks for the tip.
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
- Contact:
Re: How to simulate a conveyor?
I think if you use Erwin's suggestion on a dynamic conveyor belt object you might need to include the conveyor belt object's linearVelocity at the contact point in the calculation but not sure.
Re: How to simulate a conveyor?
hi,
has someone used the custom friction callback for a dynamic body yet? i would like to implement a box that can be moved over the ground by using custom friction for that box...but if i use the callback posted above like it is the box remains in the start position (even in the air) and nothing happens...
Best regards
Gickl
EDIT: I made a dumb mistake...i applied the collision flags of a different (static) body to the dynamic body when setting the CF_CUSTOM_MATERIAL_CALLBACK flag, so now the callback works
has someone used the custom friction callback for a dynamic body yet? i would like to implement a box that can be moved over the ground by using custom friction for that box...but if i use the callback posted above like it is the box remains in the start position (even in the air) and nothing happens...
Best regards
Gickl
EDIT: I made a dumb mistake...i applied the collision flags of a different (static) body to the dynamic body when setting the CF_CUSTOM_MATERIAL_CALLBACK flag, so now the callback works