physx - density vs velocity

Started by
3 comments, last by jezham 15 years, 10 months ago
I am using physx and have a little guy walking around the world (no character controller, just made my own using a bounding box for now and I add impulse to it to walk around) anyhow, i cant seem to grasp the relationship between the density of the object and the forces needed to make it move. Since the bounding box is relative to the size of the animation file i load, using the same forces on a 4 x 4 x 4 box wont move it the same amount as using that same force on a 2 x 2 x 2 box, but it isnt double either..... is it normal to use something like Getmass() and calculate a velocity based on that or am I missing something else?

	virtual void AddForce(vector3df forceDir, float forceStrength)
	{
		if (m_NxActor)
		{
			NxVec3 fd(forceDir.X,forceDir.Y,forceDir.Z);
			NxReal fs(forceStrength);
			NxVec3 forceVec = fs * fd;
			m_NxActor->addForce(forceVec,NX_SMOOTH_IMPULSE,true);
		}
	}
and when i use the code to move an object, I have to hard code all of the forcestrength until it 'looks right'. for example,

						int Id = CreateObjectByType("CSObject_Ball");
						CSObject* o = GetFactory()->GetObjectPointer(Id);
						if (o)
						{
							// get and normalize the direction
							vector3df irrDir = (m_Camera->getTarget() - m_Camera->getPosition()).normalize(); 
							o->SetScale(vector3df(10,10,10));
							o->SetPosition(m_Camera->getPosition());
							o->AddForce(irrDir,5000000);
						}
as I scale the object, the density of it causes the mass of it to increase. so a 'ball' of scale(1,1,1) will move massively faster than a ball of size(10,10,10). has anyone seen any documentation around the net that can help me figure out a formula so that I can move the ball the same speed regardless of the scale of it? my example : if i want my character to walk 2 meters per second, what force do I add based upon the total mass of the character?
Advertisement
solved i think...

I found this nice website that might be useful to others.

http://library.thinkquest.org/C0114565/content.php?id=341

											// a = m/f;											// m_MoveSpeed = m_NxActor->getMass() / f											// m_MoveSpeed * f = m_NxActor->getMass()											// f = m_NxActor->getMass() / m_MoveSpeed											float f = m_NxActor->getMass() / m_MoveSpeed;												AddForwardForce(f);


Quote:
using the same forces on a 4 x 4 x 4 box wont move it the same amount as using that same force on a 2 x 2 x 2 box, but it isnt double either.....


I may be off track here but a 4*4*4 box is 8 times the size (volume wise) of a 2*2*2 box rather than being double the size.
agreed, but I still havent found what I am looking for.

if an object has density then it gets a calculated mass based upon it's shape and size inside physx. What I am looking for is a calculation that will move the idle object. After the item is moving, I can then use a straight forward calculation as above to keep it moving.
Why not set the mass manually using bodyDesc.mass, then you can double both mass and force to get the same result.

Also, "keep it moving"? You are only fighting friction and linear damping.

This topic is closed to new replies.

Advertisement