Moderators: Sascha Willems, walaber
ClearMemory();
void ndJointHinge::ClearMemory()
{
ndMatrix matrix0;
ndMatrix matrix1;
CalculateGlobalMatrix(matrix0, matrix1);
ndJointBilateralConstraint::ClearMemory();
// save the current joint Omega
const ndVector omega0(m_body0->GetOmega());
const ndVector omega1(m_body1->GetOmega());
// the joint angle can be determined by getting the angle between any two non parallel vectors
m_angle = CalculateAngle(matrix0.m_up, matrix1.m_up, matrix1.m_front);
m_omega = matrix1.m_front.DotProduct(omega0 - omega1).GetScalar();
m_targetAngle = m_angle;
}
you had the model rigged, as a set of rigid bodies
you also had a series of posies.
then you initialize the rig to a pose, and you recreate the joints.
joints.recreated
My suggestion was that your pose was incomplete.
you need the collection of rigid bodies and the collection of joints.
them you pose array contain the array of rigid bodies state: (position, orientation, velocity and angular velocity)
to set a pose, you iterate over the body array setting the rigid body state, and after that you iterate over the joint array calling Clear Memory.
struct BodyState
{
quaterion rotation;
vector position
vector velocity;
vector omega;
}
struct RigPose
{
arrayOfRigidBodies bodies[n]
arrayOfRigidBodyPoses states[n]
arrayOfJointsVonnectin joints[m]
SetPose()
{
forEachBody (index in bodies) do
{
body[index]->SetRotationAndPosition(state[states].rotation, state[states].position);
body[index]->SetVelocity(state[states].velocity);
body[index]->SetVOmega(state[states].omega);
}
forEachJoint (index in joints) do
{
joints[index].ClearmMemory()
}
}
)body[index]->SetRotationAndPosition(state[states].rotation, state[states].position);
joint8->ClearMemory();
SetLimbPose (limbNode, LimbState)
{
// calculate the relative rotation for limbnode.
state = GetBodyState(limbNode) ;
matrixOffset = matrix * LimbState.Inverse();
omega = LimbState.Omega - state.Omega;
veloc = LimbState.Velocity - state.Velocity
SetLimbNewState (LimbState);
// now for each children of this node, calculate the new desire state, and reprect.
forEacgChildrenOf(i in limbNode)
{
// each child inherits the relative change of state.
childState = child[i].State
newState = matrixOffset * childState.Matrix
newState.Veloc = veloc + childState.Omega cross( disttab to paren) + childState.Veloc;
newState.Omega = omega + childState.Veloc
SetLimbPose (child[i], newState)
}
}
blackbird_dream wrote:We are talking about dynamic joints aren't we ? Not kinematic ?
Users browsing this forum: No registered users and 0 guests