float targetPercent = ((int)(time / 1000) % (int)(cyclePeriod)) / cyclePeriod;
float targetAngle = 0.5f * (1.0f + (float)Math.sin(BulletGlobals.SIMD_2_PI * targetPercent));
float targetLimitAngle = hingeC.getLowerLimit() + targetAngle * (hingeC.getUpperLimit() - hingeC.getLowerLimit());
float angleError = targetLimitAngle - curAngle;
float desiredAngularVel = 1000000.f * angleError/ms;
hingeC.enableAngularMotor(true, desiredAngularVel, muscleStrength);
}
}
if (dynamicsWorld != null) {
dynamicsWorld.stepSimulation(ms / 1000000.f);