How to simulate a conveyor?

Post Reply
PeterMacGonagan
Posts: 7
Joined: Sun Dec 05, 2010 4:59 pm

How to simulate a conveyor?

Post by PeterMacGonagan »

Hello,

Can you tell me how to simulate a conveyor, please?
Like that: http://www.youtube.com/watch?v=yKGyzcaOuA4&NR=1

Thank you.
PeterMacGonagan
Posts: 7
Joined: Sun Dec 05, 2010 4:59 pm

Re: How to simulate a conveyor?

Post by PeterMacGonagan »

up, please!
Even a simplified model... I just need that some boxes travel a conveyor.
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: How to simulate a conveyor?

Post by bone »

Search for motors in Bullet.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: How to simulate a conveyor?

Post by Erwin Coumans »

You can use special friction mode, with a target velocity and direction to simulate a conveyor.

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;
}
See attached BasicDemo.cpp
BasicDemo.zip
(3.1 KiB) Downloaded 839 times
Thanks,
Erwin

This was earlier discussed here: also http://www.bulletphysics.org/Bullet/php ... f=9&t=3555
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: How to simulate a conveyor?

Post by sparkprime »

If you set the velocity of a static object, you'll get the friction you want even though it remains stationary.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: How to simulate a conveyor?

Post by Flix »

sparkprime wrote:If you set the velocity of a static object, you'll get the friction you want even though it remains stationary.
Well, it works :D .
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.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York
Contact:

Re: How to simulate a conveyor?

Post by sparkprime »

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.
Gickl
Posts: 33
Joined: Tue Jun 05, 2012 8:43 am

Re: How to simulate a conveyor?

Post by Gickl »

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
Post Reply