SixDofJoint: add getAngles() and test recent buildscript changes

fix-openal-soft-deadlink
Stephen Gold 5 years ago
parent 0f3bc6cdcf
commit 392a3c5cff
  1. 24
      jme3-bullet-native/src/native/cpp/com_jme3_bullet_joints_SixDofJoint.cpp
  2. 18
      jme3-bullet/src/main/java/com/jme3/bullet/joints/SixDofJoint.java

@ -165,6 +165,30 @@ extern "C" {
btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA); btGeneric6DofConstraint* joint = new btGeneric6DofConstraint(*bodyA, *bodyB, transA, transB, useLinearReferenceFrameA);
return reinterpret_cast<jlong>(joint); return reinterpret_cast<jlong>(joint);
} }
/*
* Class: com_jme3_bullet_joints_SixDofJoint
* Method: getAngles
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_joints_SixDofJoint_getAngles
(JNIEnv *env, jobject object, jlong jointId, jobject storeVector) {
btGeneric6DofConstraint *pJoint
= reinterpret_cast<btGeneric6DofConstraint *> (jointId);
if (pJoint == NULL) {
jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
pJoint->calculateTransforms();
btScalar x = pJoint->getAngle(0);
btScalar y = pJoint->getAngle(1);
btScalar z = pJoint->getAngle(2);
const btVector3& angles = btVector3(x, y, z);
jmeBulletUtil::convert(env, &angles, storeVector);
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -166,6 +166,24 @@ public class SixDofJoint extends PhysicsJoint {
translationalMotor = new TranslationalLimitMotor(getTranslationalLimitMotor(objectId)); translationalMotor = new TranslationalLimitMotor(getTranslationalLimitMotor(objectId));
} }
native private void getAngles(long jointId, Vector3f storeVector);
/**
* Copy the joint's rotation angles.
*
* @param storeResult storage for the result (modified if not null)
* @return the rotation angle for each local axis (in radians, either
* storeResult or a new vector, not null)
*/
public Vector3f getAngles(Vector3f storeResult) {
Vector3f result = (storeResult == null) ? new Vector3f() : storeResult;
long constraintId = getObjectId();
getAngles(constraintId, result);
return result;
}
private native long getRotationalLimitMotor(long objectId, int index); private native long getRotationalLimitMotor(long objectId, int index);
private native long getTranslationalLimitMotor(long objectId); private native long getTranslationalLimitMotor(long objectId);

Loading…
Cancel
Save