Help with sphere...

Mani2010
Posts: 7
Joined: Sat Feb 06, 2010 12:10 pm

Help with sphere...

Post by Mani2010 »

Hi, new to Bullet (great work btw), i have two questions.
1) playing around with the basic demo project, i changed the box that you can shoot out to a sphere. Looking at the sphere up close, i found it isn't a perfect sphere. It has edges.
I am worried i will get strange movement as a result.
i only added one line...see below

Code: Select all

void	DemoApplication::setShootBoxShape ()
{
	if (!m_shootBoxShape)
	{
//		m_shootBoxShape = new btBoxShape(btVector3(.5f,.5f,.5f));
		m_shootBoxShape = new btSphereShape(btScalar(.5f));
	}
}

2) How to add bend to an object, i think its called centripical force, like a curve ball in baseball?
Mani2010
Posts: 7
Joined: Sat Feb 06, 2010 12:10 pm

Re: Help with sphere...

Post by Mani2010 »

On my second question, i have worked out you use body->setAngularVelocity(); to apply spin but i my sphere just shoots out in a straight line whilst also spinning, does not curved/bend its path. Any help?
B_old
Posts: 79
Joined: Tue Sep 26, 2006 1:10 pm

Re: Help with sphere...

Post by B_old »

Regarding your first question: The sphere you are seeing is just a graphical representation of the collision shape. The simulation works with a perfect sphere.
Mani2010
Posts: 7
Joined: Sat Feb 06, 2010 12:10 pm

Re: Help with sphere...

Post by Mani2010 »

thanks
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Help with sphere...

Post by Flix »

2) How to add bend to an object, i think its called centripical force, like a curve ball in baseball?
I thought it was called Bernoulli force...

Anyway, as far as I remember, that force is caused by the friction between the body surface and a fluid (air), and of course it can't be applied by Bullet itself (unless you add an impulse yourself every timestep).

I've never tried to do something like that, so I have no clue on how to caculate such an impulse.

For your interest, there are other more common physic effects that are not simulated by Bullet as it is, such as air friction (that makes objects of different shape and mass fall to the ground at different times, if I'm not mistaken), and the other force (I'm not remembering the name actually) that makes helium ballons fly. Both of these forces together with gravity (the only one simulated by Bullet) make physic bodies fall correctly.

Regards.
B_old
Posts: 79
Joined: Tue Sep 26, 2006 1:10 pm

Re: Help with sphere...

Post by B_old »

Flix wrote: For your interest, there are other more common physic effects that are not simulated by Bullet as it is, such as air friction (that makes objects of different shape and mass fall to the ground at different times, if I'm not mistaken), and the other force (I'm not remembering the name actually) that makes helium ballons fly. Both of these forces together with gravity (the only one simulated by Bullet) make physic bodies fall correctly.
That is interesting, thanks for the info!
WittyUserName
Posts: 4
Joined: Sun Feb 07, 2010 3:24 pm

Re: Help with sphere...

Post by WittyUserName »

Flix wrote:
2) How to add bend to an object, i think its called centripical force, like a curve ball in baseball?
I thought it was called Bernoulli force...

Anyway, as far as I remember, that force is caused by the friction between the body surface and a fluid (air), and of course it can't be applied by Bullet itself (unless you add an impulse yourself every timestep).

I've never tried to do something like that, so I have no clue on how to caculate such an impulse.
You could probably get something close by getting the ball's angular momentum vector (w) and taking the cross product with the ball's linear velocity (v); so every time step you could apply an impulse F = C*w.cross(v), where C is some constant you choose by trial and error to make it look kinda realistic.
Mani2010
Posts: 7
Joined: Sat Feb 06, 2010 12:10 pm

Re: Help with sphere...

Post by Mani2010 »

Thanks all for your replies, they have been very helpful.

WittyUserName: your suggestion makes sense, gonna give it a try.