Good evening,
I just started learning Havok, and I'm attempting to position a capsule right on top of another capsule. With the radii and positions that I provide, I would expect the capsules to be contiguous. However, there is always a small gap between the two. At first, I thought the convex shape radius was the cause. Yet, according to the documentation the sphere and capsules are defined by their convex radii so I don't think that's the problem. Besides, I have no problem setting up two contiguous spheres.
Here is a rough sample code to illustrate what I'm doing:
float radius = 0.5f; float mass = 1; hkVector4 position1(0,1,0); // Position of bottom capsule. hkVector4 vertex1(0,0,-1), vertex2(0,0,1); // Capsule vertices in local space. hkpCapsuleShape *shape = new hkpCapsuleShape(vertex1, vertex2, radius); // Create rigid body information structure. hkpRigidBodyCinfo rigidBodyInfo; rigidBodyInfo.m_motionType = hkpMotion::MOTION_FIXED; // Static element. TO REMOVE rigidBodyInfo.m_shape = shape; rigidBodyInfo.m_position = position1; // Compute the inertia tensor matrix. hkMassProperties massProperties; hkpInertiaTensorComputer::computeShapeVolumeMassProperties(shape, mass, massProperties); rigidBodyInfo.setMassProperties(massProperties); simulator->AddRigidBody(rigidBodyInfo); // Add bottom capsule. hkVector4 position2(0, 1 + 2*radius, 0); // Position of top capsule. rigidBodyInfo.m_position = position2; simulator->AddRigidBody(rigidBodyInfo); // Add top capsule.
My understanding is that the capsule vertices correspond to the center of the half spheres in local space. When the capsule is assigned to a rigid body, the axis between the vertices goes through the rigid body's position (in this particular example that is). Am I wrong? (probably so...) Is there some local to world scaling happening? If not, what is causing the gap?