However, I am getting some odd behavior with the Kinematic joint. When an object is picked up, a kinematic joint is created, and the target position and rotation is continually set. When the object is dropped, the kinematic joint is deleted.
In my demo, walk into the room on the right. Press E to pick up the crate sitting in the back of the pickup truck and move around to carry the crate. Drop the crate by pressing E again.
After the crate is dropped, it cannot be picked up again. It can still be pushed and shot to move it, but a new kinematic joint will have no effect on it.
Other times, such as in this video, it will freeze up on either the SetTargetPosition or SetTargetRotation commands.
Download
https://www.leadwerks.com/files/KinematicJoint.zip
Code
- Code: Select all
void NewtonDynamicsJoint::SetTargetPosition(const Vec3& pos, const float blend)
{
if (type == KINEMATIC)
{
dVector posf;
posf.m_x = pos.x * blend + entity[0]->body->nextmat.t.x * (1.0f- blend);
posf.m_y = pos.y * blend + entity[0]->body->nextmat.t.y * (1.0f - blend);
posf.m_z = pos.z * blend + entity[0]->body->nextmat.t.z * (1.0f - blend);
posf.m_w = 1.0f;
((dCustomKinematicController*)newtonuserjoint)->SetTargetPosit(posf);
}
}
void NewtonDynamicsJoint::SetTargetRotation(const Quat& rotation, const float blend)
{
if (type == KINEMATIC)
{
dQuaternion rotf;
Quat q = entity[0]->body->nextquat.Slerp(rotation, blend);
q = q.Normalize();
rotf.m_q0 = q.w;
rotf.m_q1 = -q.x;
rotf.m_q2 = -q.y;
rotf.m_q3 = -q.z;
((dCustomKinematicController*)newtonuserjoint)->SetTargetRotation(rotf);
}
}
Video