Door revolute joint

nargil

08-08-2009 17:18:37

A movie: http://www.youtube.com/watch?v=Ms7x4PTCkHQ

Is this a solver problem, just because i use setPosition in the editor, and everything will be fine if I use the character->move() or throw rigid bodies at it ?
Or maybe isn't 1 revolute joint enough ?

the code from the editor, and in the comments the values typed in in the editor
NxRevoluteJointDesc revDesc;
revDesc.setToDefault();
revDesc.actor[0] = actor0; // the door
revDesc.actor[1] = actor1; // null
revDesc.spring.spring = this->GetPropertyByName("sprSpr")->GetValue().GetDouble(); // 100
revDesc.spring.damper = this->GetPropertyByName("sprDamp")->GetValue().GetDouble(); // 10
revDesc.spring.targetValue = this->GetPropertyByName("sprTarget")->GetValue().GetDouble(); // 0
revDesc.limit.low.setToDefault();
revDesc.limit.high.setToDefault();
revDesc.limit.low.value = this->GetPropertyByName("minAngle")->GetValue().GetDouble() * Ogre::Math::PI /180; // -90 * PI / 180
revDesc.limit.high.value = this->GetPropertyByName("maxAngle")->GetValue().GetDouble() * Ogre::Math::PI /180; // 90 * PI / 180
revDesc.flags|=NX_RJF_SPRING_ENABLED;
revDesc.flags|=NX_RJF_LIMIT_ENABLED;
revDesc.setGlobalAxis(NxOgre::NxConvert<NxVec3,Ogre::Vector3>(globalAxis)); // (0,1,0)
revDesc.setGlobalAnchor(NxOgre::NxConvert<NxVec3,Ogre::Vector3>(globalAnchor)); // placed at the left side of the door
NxRevoluteJoint *revJoint=(NxRevoluteJoint *)WxEngine::getSingletonPtr()->getScene()->getNxScene()->createJoint(revDesc);


I also noticed that if I place the door in the air, and create a revolute joint in the same way as above the door tends to fall a little bit (the greater the mass - the more). I'd want it to be always straight up. No matter the mass.

nargil

08-08-2009 17:35:27

I'm looking at the projections in the manual, and there is something I don't get:


NxReal NxRevoluteJointDesc::projectionAngle

The angle beyond which the joint is projected.

This similar to projectionDistance, except this is an angle (in radians) to which angular drift is projected.

Unit: Radians Range: (0.2,PI)
Default: 0.0872 (about 5 degrees in radians)

Is the default value smaller than the minimal ?! Or is the range (0.02,PI) ?

betajaen

08-08-2009 18:05:11

I don't know about the projection distance (it's been a while since I've done doors with PhysX).

But for your other errors; how about setting disabling linear movement completely using NX_BF flags and limit angular movement to the Y axis only. That way it should only express it's anger at you in the rotational Y axis only - which is what you want.

nargil

08-08-2009 19:43:55

Thanks for the reply, but it doesn't fix the mass issue. Even though I can't rotate the actor on the x/z axis, attached to a joint and given a big mass it rotates itself (and probably the joint too). The only differences are that now with mass 100 it behaves like mass 10 without NX_BF_FROZEN_ROT_X | NX_BF_FROZEN_ROT_Z.

Locking the position is not an option, because i want it to work with doors that are not alligned. I might lock NX_BF_FROZEN_POS_Y, but it actually makes no difference for the joint with an (0,1,0) axis.

Quite a solution seems to be setting:

desc.actor[0]->setCMassGlobalPosition(anchor);

where anchor i the joint anchor position

betajaen

08-08-2009 19:47:09

What about increasing the linear (and possibly angular) damping to simulate the increase in mass?

nargil

08-08-2009 19:50:08

What about increasing the linear (and possibly angular) damping to simulate the increase in mass?
of what ?

I have edited the previous post

Quite a solution seems to be setting:

desc.actor[0]->setCMassGlobalPosition(anchor);

where anchor i the joint anchor position

The only problem is: This is a little bit outside the door shape. I'm not sure how it will affect the physics.

nargil

08-08-2009 19:57:37

So the conclusion is:
- setting projection distance to 0.1 meter, and enable the projection mode (fixes most of the errors shown in the movie)
- setting the cmass at the joint anchor point allows to increase the mass of the door

There is still some jittering if the kinematic character rotates the door more than the limit allows. Let's hope this won't be an issue in real time simulation with ->move instead od ->setposition

betajaen

08-08-2009 20:08:44

I agree with your assessment, your tunnelling though the door which is causing unexpected collisions causing it to move in unpredictable directions. Moving the character into the door will add a force in the direction of the door's joint and make a nice door opening motion.

I would try increasing the linear/angular damping of the door, and perhaps enable some of the anti-movement flags for those doors aligned against a particular axis - Just to make it extra stable.