Jump to content
  • Advertisement
Sign in to follow this  
7thAvatar

physx - density vs velocity

This topic is 3649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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);


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!