Translate Objekt while Engine is Running

Translate Objekt while Engine is Running

Hello everyone,

I am new to havok, so I have a question, which you might have solved already, but I cant find any answers.

There is an rigidbody with Constraints. And I got a new Position for it, which should be reached by a physical translation. And there is the Problem. I have found various Method to do this job:

setTransform() - no phyiscal translation.

applyForce() - not exact translation

applyLinearImpulse() - not exact, but one can calculate the translation (ill come to that later)

applyHardKeyFrame() - i dont get it ^^

Well i have an EXACT translation, so Forces dont fit the problem, i think.

At the Moment I am using the applyLinearImpulse and set the LinearVelocity to 0 when the Position is reached. This results in a slow translation, because the constrainted object, pulls it further.

The HardKeyFrame seems to do what i want, but it doesnt work. I think i dont get it.
I thought, this function applies the velocity to reach the given point within the given timestep (the inv of the timestep)

So i tried to set the velocity to 0 after the timestep. the result wasnt even close.

I saw this behaviour in the visual debugger(Holding SPACE and dragging an Object), i would rly appreciate it, if you can say me how this works. Or gimme a ressource


2 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

It sounds like hkpKeyFrameUtility::applyHardKeyFrame() is the function you want. This is the best way to move something if you know it's desired position and orientation next frame.

The approach you describe is correct - applyHardKeyFrame() one frame, and then zero the velocity the next. If the body does not collide with anything or have gravity or other constraints or actions applied to it, and the timeStep you use is correct and constant, then it should be in the new position next frame. Then you can use setLinearVelocity (and setAngularVelocity() if you're changing it's orientation) to zero in order to stop it.

There are many demos that use hkpKeyFrameUtility::applyHardKeyFrame(), for a simple example check out: Demo\Demos\Physics\Api\Dynamics\RigidBodies\Keyframing\KeyframingDemo.

If you're still having trouble getting it to work let me know.

PS: the VDB and demos use hkpMouseSpringAction which does a simple spring calculation based on the mouse position to drag things around. You can search the demos for an example of how it's used.

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi