Doors in doorways and Havok - Overshoot

Doors in doorways and Havok - Overshoot

I have a doorway with a side bar 0.1 x 0.1 meters and about 2 meters tall, and a door inside it.The door is about 0.2 meters smaller than the doorway and next to the side bar, so there is plenty of clearence.I'm using hkpLimitedHingeConstraintData for the hinge creation.I've looked at it in the Havok debug viewer and the door is not interpenetrating any where.There are angle constraints from 0 to 2 radians, so 0 is closed and 2 is way open.It all works about correctly, but for one thing:When you close the door it overshoots the 0 radian position and if closed hard, does not return back to the 0 position, so the door is slightly  (maybe .2 meters) opn the wrong way out.How do you do a hard stop for a door, like real doors do?R. KeeneSandswept Studios.

publicaciones de 4 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Imagen de havok_joe

Hi Richard:
You can add a Position Motor on your door to make it as a power door. Here is a very good demo for it.Physics > UseCase > Doors

Running this demo, you can see one of doors has almost the same problem as yours, another one with the position motor on it will automatically run back to there original position.

It's very easy to set in 3DMax or Maya by using Havok Content Tools. To create it in run time, it will be some extra code required. Briefly, you should create a hkpPositionConstraintMotor, set correct parameter for it, and call hkpLimitedHingeConstraintData::setMotor() to set it into your hinge.

Good luck

Joe Developer Support Engineer Havok www.havok.com

Ok, the solution is the wrapper class hkpMalleableConstraintData
setStrength is how ridgid the angle limits are.
// Create constraint m_hingeConstraint = new hkpLimitedHingeConstraintData(); m_hingeConstraint->setInBodySpace(pivotFrame, pivotDoor, axis, axis, zeroDegreeAxis, zeroDegreeAxis); m_hingeConstraint->setMaxAngularLimit(0.0f); m_hingeConstraint->setMinAngularLimit(-2.0f); m_hingeConstraint->setSolvingMethod(hkpConstraintAtom::METHOD_STABILIZED); m_hingeConstraint->setMaxFrictionTorque(20.0f); m_hingeConstraint->setAngularLimitsTauFactor(2.0f); m_hingeWrapper = new hkpMalleableConstraintData(m_hingeConstraint); m_hingeWrapper->setStrength(1.0f); m_ownerBlock->m_havokWorld->createAndAddConstraintInstance( m_companionDoorway->m_havokBody, m_havokBody, m_hingeWrapper )->removeReference();

For door latching we detect when the door is active and it's angle from getEstimatedAngle is near zero.Then set a flag that the door is latched, and set the movement type to STATIC.void SPDoor::latchDoor(){  activate();  m_worldPosition = m_initialPosition;  m_rotation = m_initialFacing;  syncPositionAndRotationToHavok();  m_havokBody->setMotionType(hkpMotion::MotionType::MOTION_FIXED);  m_isLatched = true;}void SPDoor::unlatchDoor(){  activate();  m_havokBody->setMotionType(hkpMotion::MotionType::MOTION_BOX_INERTIA);  m_isLatched = false;}(The activate is our game code, not havok's activate.)

Inicie sesión para dejar un comentario.