added inertia manipulating methods

fix-456
Kai Boernert 8 years ago committed by Rémy Bouquet
parent ec6c32ecdc
commit 96b355e38c
  1. 35
      jme3-bullet-native/src/native/cpp/com_jme3_bullet_objects_PhysicsRigidBody.cpp
  2. 8
      jme3-bullet-native/src/native/cpp/com_jme3_bullet_objects_PhysicsRigidBody.h
  3. 16
      jme3-bullet/src/main/java/com/jme3/bullet/objects/PhysicsRigidBody.java

@ -151,6 +151,41 @@ extern "C" {
// } // }
} }
/*
* Class: com_jme3_bullet_objects_PhysicsRigidBody
* Method: setInverseInertiaLocal
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setInverseInertiaLocal
(JNIEnv *env, jobject object, jlong bodyId, jobject value) {
btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId);
if (body == NULL) {
jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
btVector3 vec = btVector3();
jmeBulletUtil::convert(env, value, &vec);
body->setInvInertiaDiagLocal(vec);
}
/*
* Class: com_jme3_bullet_objects_PhysicsRigidBody
* Method: getInverseInertiaLocal
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getInverseInertiaLocal
(JNIEnv *env, jobject object, jlong bodyId, jobject value) {
btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId);
if (body == NULL) {
jclass newExc = env->FindClass("java/lang/NullPointerException");
env->ThrowNew(newExc, "The native object does not exist.");
return;
}
jmeBulletUtil::convert(env, &body->getInvInertiaDiagLocal(), value);
}
/* /*
* Class: com_jme3_bullet_objects_PhysicsRigidBody * Class: com_jme3_bullet_objects_PhysicsRigidBody
* Method: getPhysicsLocation * Method: getPhysicsLocation

@ -89,6 +89,14 @@ JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setPhysicsR
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsLocation JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsLocation
(JNIEnv *, jobject, jlong, jobject); (JNIEnv *, jobject, jlong, jobject);
/*
* Class: com_jme3_bullet_objects_PhysicsRigidBody
* Method: getInverseInertiaLocal
* Signature: (JLcom/jme3/math/Vector3f;)V
*/
JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getInverseInertiaLocal
(JNIEnv *, jobject, jlong, jobject);
/* /*
* Class: com_jme3_bullet_objects_PhysicsRigidBody * Class: com_jme3_bullet_objects_PhysicsRigidBody
* Method: getPhysicsRotation * Method: getPhysicsRotation

@ -185,6 +185,21 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
getPhysicsRotation(objectId, rot); getPhysicsRotation(objectId, rot);
return rot; return rot;
} }
public void setInverseInertiaLocal(Vector3f gravity) {
setInverseInertiaLocal(objectId, gravity);
}
private native void setInverseInertiaLocal(long objectId, Vector3f gravity);
public Vector3f getInverseInertiaLocal(Vector3f trans) {
if (trans == null) {
trans = new Vector3f();
}
getInverseInertiaLocal(objectId, trans);
return trans;
}
private native void getInverseInertiaLocal(long objectId, Vector3f vector);
private native void getPhysicsRotation(long objectId, Quaternion rot); private native void getPhysicsRotation(long objectId, Quaternion rot);
@ -352,7 +367,6 @@ public class PhysicsRigidBody extends PhysicsCollisionObject {
public void setGravity(Vector3f gravity) { public void setGravity(Vector3f gravity) {
setGravity(objectId, gravity); setGravity(objectId, gravity);
} }
private native void setGravity(long objectId, Vector3f gravity); private native void setGravity(long objectId, Vector3f gravity);
public float getFriction() { public float getFriction() {

Loading…
Cancel
Save