In Newton 1.53 I made motorized hinges with limits using the built in hinge and callbacks using this method
- Code: Select all
n_joint = NewtonConstraintCreateHinge(nworld, joint.pos, joint.axis), joint.follower, joint.base);
NewtonHingeSetUserCallback(n_joint, hingejoint_callback);
void hingejoint_callback(NewtonJoint* hinge, NewtonHingeSliderUpdateDesc* desc)
{
...
if(angle > angleUB && desired_omega>=0)
desc.m_accel = NewtonHingeCalculateStopAlpha(hinge, desc, angleUB); //above upper limit
else
{
if(angle < angleLB && desired_omega<=0)
desc.m_accel = NewtonHingeCalculateStopAlpha(hinge, desc, angleLB); //below lower limit
else
desc.m_accel = accelK * (desired_omega - actual_omega) / desc.m_timestep; //between limits -> motorized
}
}
I want to update this to Newton 2, and use the joint library's CreateCustomHinge function. I managed to make a hinge with limits but I don't know how to motorize it. How do I apply callbacks to the CustomHinge. Do I use CustomSetSubmitContraintCallback?
and then use these functions in the callback? (or do these only work with the legacy joints):
NewtonUserJointAddAngularRow (nujoint, 0, pin);
NewtonUserJointSetRowAcceleration (nujoint, accel);
P.S. I'm using Newton 2.11 with GameStudio using the wrapper made by Vasilenko Vitaliy (VeT)