Odd values returned from hkpRigidBody::getTransform().

Odd values returned from hkpRigidBody::getTransform().

Hello, again unfortunately. I'm having a slight problem with rigid body tranformation. Whenever I get the transform of a rigid body, its always something along the lines of -4.289494E + 32 or so, for each axis ( maybe differing slightly ). The problem with this is that if I were to go and position the graphical representation of the object at these positions, they wouldn't be correct. So what is the deal with these numbers? Is there some other way to get transforms?

15 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

Have you added the rigid body to the world?
Did you set an intial position when you created the rigid body in the cinfo, using m_position?

Did you call remove reference on the rigid body when you shouldn't? The referce is added when you add to the world but if you remove too many times it can be garbage collected when you're still trying to use it.

Perhaps you have some kind of instability in the forces you applied to the object, and it launched off into infinity?


Yes, the rigid body is in the world. Yes I set the initial position in the Cinfo to { 0, -10, 0 }. I'm applying no forces. The only force that is affect it is gravity. I have not actually called removeReference, but I doubt that'd be the cause.

As an interesting note, the object that is oddly placed is a static rigid body, set using the MOTION_TYPE_FIXED.

Now, I am using managed c++, would that be the reason for this?

It depends on your implementation I suppose. Did you write your own memory manager for havok that uses the managed memory manger? It could have to do with that.

When are you checking the value? Is wrong on the first frame of the simulation? Have you got any other simulation to work?


I've only attempted with managed, but I'm about to just switch to Direct3D 10, as I know that Havok works for C++( I'm using managed to port it to C# ). But no, I didn't write my own memory manager for havok, unless you mean the hkMemory and hkThreadMemory classes that are used for hkBaseSystemInit(...).

Forgot to mention, if I don't set the position whatsoever, it works perfectly. A falling cube falls, and the fixed box lies at 0, 0,0, and not some freakishly large number.

Ahh, perhaps you're placing the object too close to another object? have you tried other transforms? You might not want to try placing it exactly off the ground as there are collision tollerances and stuff. I kind of doubt that would cause your object to explode though.

Woo, got it. I wasn't using hVector4::set, I was just directly setting the vector4. Not so good of an idea on my part :P

Well, that at least makes it so I can position from the Cinfo, but if I try to position the rigid body via hkpRigidBody::setPosition, it still messes up ( except only the X axis is a freakish value, the others are zero ).

are you using simd? Perhaps it's a memory alignment issue. Look in the docs at:
"Common Havok Components | Havok Math Library" Specifically 3.1 Stack Allocations and 16-byte alignment issues.


Ok, yeah, that was it. It wasn't aligned correctly. Thanks a lot man, you've been a great help. Those were the only things giving me trouble. But one thing I'm curious about, how would you be able to generate an axis angle from a Quaternion? As in, fill an hkVector4 with the x, y, and z axis angles?

well generally you might want to avoid it since it can be expensive.

Since a quaternion stores a rotation of angle and axis as (theta,v) (say) as:

[cosine(theta/2), sine(theta/2) * v]

you can get the angle by 2*arccos(w), and the axis by 2*arcsin(w)*(x,y,z)

Actually funny you should mention it. Some of the best documentation for quaternions I found was in the havok docs :)

"Havok Physics | Physics Articles | Rotations, Handedness and all that."

If I misunderstood and you mean to create an hkQuaternion from axis and angle, you can just use the havok helper:

hkVector4 axis(axisX, axisY, axisZ);
hkQuaternion q;
q.setAxisAngle( axis, angle );

I see. Looks like I should've looked harder in the documentation. Sorry for all the hassle. I was just curious about the conversion, I'm still going to use Quaternions for rotation though, seeing as they seem most logical. Thanks for all your help.

No problem. Glad I could help. I got stuck on all the same stuff. I found that conversion info because I'm using directX, which kind puts me in left-hand coordinate system land, and I was using Maya in a right-hand coordinate system. So I was searching to see how this would effect havok, and then came accross that section about conversion.

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!