Sign in to follow this  
leandro81

Weird problem with PhysX

Recommended Posts

leandro81    192
Hi, I am using PhysX to simulate simple rigid bodies and i am getting this weird problem: There is a plane and several objects placed on top of it; when i apply a force on one of them, the force direction gradually moves toward one of the axis: X or Z (depending on which one is closer to the original force direction), please look: Free Image Hosting at www.ImageShack.us I am using C# and PhysX:
Vector3 lookDirection = new Vector3();
lookDirection = currentCamera.LookAt.Position - currentCamera.Position;
lookDirection.Y = 0.0f; // removes the Y part, as i want to apply a horizontal force;
lookDirection.Normalize();
lookDirection = lookDirection * strength;
physicsManager.addForce(obj, lookDirection, currentCamera.LookAt.Position);

And inside physicsManager:
public void addForce(Object3D obj, Vector3 force, Vector3 pos)
{
    if (bodies.ContainsKey(obj))
    {
        NxActor actor = bodies[obj];                
        actor.addForceAtPos(force, pos, NxForceMode.NX_FORCE);                
    }
}

I don't know what could be causing this, or what i am doing wrong. Well, thanks in advance for any tips! :) Cheers, Leandro

Share this post


Link to post
Share on other sites
jezham    204
Unless this is happening in a hardware scene then you need to force cone friction, for the advanced friction model.

when creating actors, use this flag:
NX_AF_FORCE_CONE_FRICTION

or for the whole scene:
NX_SF_FORCE_CONE_FRICTION (in your sceneDesc.flags)

Share this post


Link to post
Share on other sites
leandro81    192
WOW! Thanks, this really seems to be the solution!

But now I have another problem, I am using this wrapper and it's linked against version 2.4.4 of PhysX library and this flag appeared only on version 2.6.1 :(

Does anyone know another .NET wrapper for a recent version of PhysX?

Thanks in advance,
Leandro

Share this post


Link to post
Share on other sites
jezham    204
Yeah the newer friction model has a real nice feel to it :)

Can't help with wrappers, perhaps start making your own as a side project, e.g. draw everything with the debug code to start, etc? It takes years though, I'm doing everything (within reason) custom and it feels like I'm doing a whole team's effort!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this