1 /* 2 * Copyright (c) 2009-2010 jMonkeyEngine 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 /** 34 * Author: Normen Hansen 35 */ 36 #include "com_jme3_bullet_objects_PhysicsRigidBody.h" 37 #include "jmeBulletUtil.h" 38 #include "jmeMotionState.h" 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* 45 * Class: com_jme3_bullet_objects_PhysicsRigidBody 46 * Method: createRigidBody 47 * Signature: (FJJ)J 48 */ 49 JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_createRigidBody 50 (JNIEnv *env, jobject object, jfloat mass, jlong motionstatId, jlong shapeId) { 51 jmeClasses::initJavaClasses(env); 52 btMotionState* motionState = reinterpret_cast<btMotionState*>(motionstatId); 53 btCollisionShape* shape = reinterpret_cast<btCollisionShape*>(shapeId); 54 btVector3 localInertia = btVector3(); 55 shape->calculateLocalInertia(mass, localInertia); 56 btRigidBody* body = new btRigidBody(mass, motionState, shape, localInertia); 57 body->setUserPointer(NULL); 58 return reinterpret_cast<jlong>(body); 59 } 60 61 /* 62 * Class: com_jme3_bullet_objects_PhysicsRigidBody 63 * Method: isInWorld 64 * Signature: (J)Z 65 */ 66 JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_isInWorld 67 (JNIEnv *env, jobject object, jlong bodyId) { 68 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 69 if (body == NULL) { 70 jclass newExc = env->FindClass("java/lang/NullPointerException"); 71 env->ThrowNew(newExc, "The native object does not exist."); 72 return false; 73 } 74 return body->isInWorld(); 75 } 76 77 /* 78 * Class: com_jme3_bullet_objects_PhysicsRigidBody 79 * Method: setPhysicsLocation 80 * Signature: (JLcom/jme3/math/Vector3f;)V 81 */ 82 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setPhysicsLocation 83 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 84 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 85 if (body == NULL) { 86 jclass newExc = env->FindClass("java/lang/NullPointerException"); 87 env->ThrowNew(newExc, "The native object does not exist."); 88 return; 89 } 90 // if (body->isStaticOrKinematicObject() || !body->isInWorld()) 91 ((jmeMotionState*) body->getMotionState())->setKinematicLocation(env, value); 92 body->setCenterOfMassTransform(((jmeMotionState*) body->getMotionState())->worldTransform); 93 // else{ 94 // btMatrix3x3* mtx = &btMatrix3x3(); 95 // btTransform* trans = &btTransform(*mtx); 96 // trans->setBasis(body->getCenterOfMassTransform().getBasis()); 97 // jmeBulletUtil::convert(env, value, &trans->getOrigin()); 98 // body->setCenterOfMassTransform(*trans); 99 // } 100 } 101 102 /* 103 * Class: com_jme3_bullet_objects_PhysicsRigidBody 104 * Method: setPhysicsRotation 105 * Signature: (JLcom/jme3/math/Matrix3f;)V 106 */ 107 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setPhysicsRotation__JLcom_jme3_math_Matrix3f_2 108 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 109 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 110 if (body == NULL) { 111 jclass newExc = env->FindClass("java/lang/NullPointerException"); 112 env->ThrowNew(newExc, "The native object does not exist."); 113 return; 114 } 115 // if (body->isStaticOrKinematicObject() || !body->isInWorld()) 116 ((jmeMotionState*) body->getMotionState())->setKinematicRotation(env, value); 117 body->setCenterOfMassTransform(((jmeMotionState*) body->getMotionState())->worldTransform); 118 // else{ 119 // btMatrix3x3* mtx = &btMatrix3x3(); 120 // btTransform* trans = &btTransform(*mtx); 121 // trans->setOrigin(body->getCenterOfMassTransform().getOrigin()); 122 // jmeBulletUtil::convert(env, value, &trans->getBasis()); 123 // body->setCenterOfMassTransform(*trans); 124 // } 125 } 126 127 /* 128 * Class: com_jme3_bullet_objects_PhysicsRigidBody 129 * Method: setPhysicsRotation 130 * Signature: (JLcom/jme3/math/Quaternion;)V 131 */ 132 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setPhysicsRotation__JLcom_jme3_math_Quaternion_2 133 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 134 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 135 if (body == NULL) { 136 jclass newExc = env->FindClass("java/lang/NullPointerException"); 137 env->ThrowNew(newExc, "The native object does not exist."); 138 return; 139 } 140 // if (body->isStaticOrKinematicObject() || !body->isInWorld()) 141 ((jmeMotionState*) body->getMotionState())->setKinematicRotationQuat(env, value); 142 body->setCenterOfMassTransform(((jmeMotionState*) body->getMotionState())->worldTransform); 143 // else{ 144 // btMatrix3x3* mtx = &btMatrix3x3(); 145 // btTransform* trans = &btTransform(*mtx); 146 // trans->setOrigin(body->getCenterOfMassTransform().getOrigin()); 147 // jmeBulletUtil::convertQuat(env, value, &trans->getBasis()); 148 // body->setCenterOfMassTransform(*trans); 149 // } 150 } 151 152 /* 153 * Class: com_jme3_bullet_objects_PhysicsRigidBody 154 * Method: getPhysicsLocation 155 * Signature: (JLcom/jme3/math/Vector3f;)V 156 */ 157 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsLocation 158 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 159 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 160 if (body == NULL) { 161 jclass newExc = env->FindClass("java/lang/NullPointerException"); 162 env->ThrowNew(newExc, "The native object does not exist."); 163 return; 164 } 165 jmeBulletUtil::convert(env, &body->getWorldTransform().getOrigin(), value); 166 } 167 168 /* 169 * Class: com_jme3_bullet_objects_PhysicsRigidBody 170 * Method: getPhysicsRotation 171 * Signature: (JLcom/jme3/math/Quaternion;)V 172 */ 173 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsRotation 174 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 175 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 176 if (body == NULL) { 177 jclass newExc = env->FindClass("java/lang/NullPointerException"); 178 env->ThrowNew(newExc, "The native object does not exist."); 179 return; 180 } 181 jmeBulletUtil::convertQuat(env, &body->getWorldTransform().getBasis(), value); 182 } 183 184 /* 185 * Class: com_jme3_bullet_objects_PhysicsRigidBody 186 * Method: getPhysicsRotationMatrix 187 * Signature: (JLcom/jme3/math/Matrix3f;)V 188 */ 189 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getPhysicsRotationMatrix 190 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 191 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 192 if (body == NULL) { 193 jclass newExc = env->FindClass("java/lang/NullPointerException"); 194 env->ThrowNew(newExc, "The native object does not exist."); 195 return; 196 } 197 jmeBulletUtil::convert(env, &body->getWorldTransform().getBasis(), value); 198 } 199 200 /* 201 * Class: com_jme3_bullet_objects_PhysicsRigidBody 202 * Method: setKinematic 203 * Signature: (JZ)V 204 */ 205 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setKinematic 206 (JNIEnv *env, jobject object, jlong bodyId, jboolean value) { 207 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 208 if (body == NULL) { 209 jclass newExc = env->FindClass("java/lang/NullPointerException"); 210 env->ThrowNew(newExc, "The native object does not exist."); 211 return; 212 } 213 if (value) { 214 body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); 215 body->setActivationState(DISABLE_DEACTIVATION); 216 } else { 217 body->setCollisionFlags(body->getCollisionFlags() & ~btCollisionObject::CF_KINEMATIC_OBJECT); 218 body->setActivationState(ACTIVE_TAG); 219 } 220 } 221 222 /* 223 * Class: com_jme3_bullet_objects_PhysicsRigidBody 224 * Method: setCcdSweptSphereRadius 225 * Signature: (JF)V 226 */ 227 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setCcdSweptSphereRadius 228 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 229 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 230 if (body == NULL) { 231 jclass newExc = env->FindClass("java/lang/NullPointerException"); 232 env->ThrowNew(newExc, "The native object does not exist."); 233 return; 234 } 235 body->setCcdSweptSphereRadius(value); 236 } 237 238 /* 239 * Class: com_jme3_bullet_objects_PhysicsRigidBody 240 * Method: setCcdMotionThreshold 241 * Signature: (JF)V 242 */ 243 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setCcdMotionThreshold 244 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 245 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 246 if (body == NULL) { 247 jclass newExc = env->FindClass("java/lang/NullPointerException"); 248 env->ThrowNew(newExc, "The native object does not exist."); 249 return; 250 } 251 body->setCcdMotionThreshold(value); 252 } 253 254 /* 255 * Class: com_jme3_bullet_objects_PhysicsRigidBody 256 * Method: getCcdSweptSphereRadius 257 * Signature: (J)F 258 */ 259 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getCcdSweptSphereRadius 260 (JNIEnv *env, jobject object, jlong bodyId) { 261 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 262 if (body == NULL) { 263 jclass newExc = env->FindClass("java/lang/NullPointerException"); 264 env->ThrowNew(newExc, "The native object does not exist."); 265 return 0; 266 } 267 return body->getCcdSweptSphereRadius(); 268 } 269 270 /* 271 * Class: com_jme3_bullet_objects_PhysicsRigidBody 272 * Method: getCcdMotionThreshold 273 * Signature: (J)F 274 */ 275 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getCcdMotionThreshold 276 (JNIEnv *env, jobject object, jlong bodyId) { 277 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 278 if (body == NULL) { 279 jclass newExc = env->FindClass("java/lang/NullPointerException"); 280 env->ThrowNew(newExc, "The native object does not exist."); 281 return 0; 282 } 283 return body->getCcdMotionThreshold(); 284 } 285 286 /* 287 * Class: com_jme3_bullet_objects_PhysicsRigidBody 288 * Method: getCcdSquareMotionThreshold 289 * Signature: (J)F 290 */ 291 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getCcdSquareMotionThreshold 292 (JNIEnv *env, jobject object, jlong bodyId) { 293 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 294 if (body == NULL) { 295 jclass newExc = env->FindClass("java/lang/NullPointerException"); 296 env->ThrowNew(newExc, "The native object does not exist."); 297 return 0; 298 } 299 return body->getCcdSquareMotionThreshold(); 300 } 301 302 /* 303 * Class: com_jme3_bullet_objects_PhysicsRigidBody 304 * Method: setStatic 305 * Signature: (JZ)V 306 */ 307 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setStatic 308 (JNIEnv *env, jobject object, jlong bodyId, jboolean value) { 309 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 310 if (body == NULL) { 311 jclass newExc = env->FindClass("java/lang/NullPointerException"); 312 env->ThrowNew(newExc, "The native object does not exist."); 313 return; 314 } 315 if (value) { 316 body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_STATIC_OBJECT); 317 } else { 318 body->setCollisionFlags(body->getCollisionFlags() & ~btCollisionObject::CF_STATIC_OBJECT); 319 } 320 } 321 322 /* 323 * Class: com_jme3_bullet_objects_PhysicsRigidBody 324 * Method: updateMassProps 325 * Signature: (JJF)J 326 */ 327 JNIEXPORT jlong JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_updateMassProps 328 (JNIEnv *env, jobject object, jlong bodyId, jlong shapeId, jfloat mass) { 329 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 330 if (body == NULL) { 331 jclass newExc = env->FindClass("java/lang/NullPointerException"); 332 env->ThrowNew(newExc, "The native object does not exist."); 333 return 0; 334 } 335 btCollisionShape* shape = reinterpret_cast<btCollisionShape*>(shapeId); 336 btVector3 localInertia = btVector3(); 337 shape->calculateLocalInertia(mass, localInertia); 338 body->setMassProps(mass, localInertia); 339 return reinterpret_cast<jlong>(body); 340 } 341 342 /* 343 * Class: com_jme3_bullet_objects_PhysicsRigidBody 344 * Method: getGravity 345 * Signature: (JLcom/jme3/math/Vector3f;)V 346 */ 347 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getGravity 348 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 349 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 350 if (body == NULL) { 351 jclass newExc = env->FindClass("java/lang/NullPointerException"); 352 env->ThrowNew(newExc, "The native object does not exist."); 353 return; 354 } 355 jmeBulletUtil::convert(env, &body->getGravity(), value); 356 } 357 358 /* 359 * Class: com_jme3_bullet_objects_PhysicsRigidBody 360 * Method: setGravity 361 * Signature: (JLcom/jme3/math/Vector3f;)V 362 */ 363 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setGravity 364 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 365 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 366 if (body == NULL) { 367 jclass newExc = env->FindClass("java/lang/NullPointerException"); 368 env->ThrowNew(newExc, "The native object does not exist."); 369 return; 370 } 371 btVector3 vec = btVector3(); 372 jmeBulletUtil::convert(env, value, &vec); 373 body->setGravity(vec); 374 } 375 376 /* 377 * Class: com_jme3_bullet_objects_PhysicsRigidBody 378 * Method: getFriction 379 * Signature: (J)F 380 */ 381 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getFriction 382 (JNIEnv *env, jobject object, jlong bodyId) { 383 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 384 if (body == NULL) { 385 jclass newExc = env->FindClass("java/lang/NullPointerException"); 386 env->ThrowNew(newExc, "The native object does not exist."); 387 return 0; 388 } 389 return body->getFriction(); 390 } 391 392 /* 393 * Class: com_jme3_bullet_objects_PhysicsRigidBody 394 * Method: setFriction 395 * Signature: (JF)V 396 */ 397 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setFriction 398 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 399 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 400 if (body == NULL) { 401 jclass newExc = env->FindClass("java/lang/NullPointerException"); 402 env->ThrowNew(newExc, "The native object does not exist."); 403 return; 404 } 405 body->setFriction(value); 406 } 407 408 /* 409 * Class: com_jme3_bullet_objects_PhysicsRigidBody 410 * Method: setDamping 411 * Signature: (JFF)V 412 */ 413 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setDamping 414 (JNIEnv *env, jobject object, jlong bodyId, jfloat value1, jfloat value2) { 415 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 416 if (body == NULL) { 417 jclass newExc = env->FindClass("java/lang/NullPointerException"); 418 env->ThrowNew(newExc, "The native object does not exist."); 419 return; 420 } 421 body->setDamping(value1, value2); 422 } 423 424 /* 425 * Class: com_jme3_bullet_objects_PhysicsRigidBody 426 * Method: setAngularDamping 427 * Signature: (JF)V 428 */ 429 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularDamping 430 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 431 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 432 if (body == NULL) { 433 jclass newExc = env->FindClass("java/lang/NullPointerException"); 434 env->ThrowNew(newExc, "The native object does not exist."); 435 return; 436 } 437 body->setDamping(body->getAngularDamping(), value); 438 } 439 440 /* 441 * Class: com_jme3_bullet_objects_PhysicsRigidBody 442 * Method: getLinearDamping 443 * Signature: (J)F 444 */ 445 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getLinearDamping 446 (JNIEnv *env, jobject object, jlong bodyId) { 447 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 448 if (body == NULL) { 449 jclass newExc = env->FindClass("java/lang/NullPointerException"); 450 env->ThrowNew(newExc, "The native object does not exist."); 451 return 0; 452 } 453 return body->getLinearDamping(); 454 } 455 456 /* 457 * Class: com_jme3_bullet_objects_PhysicsRigidBody 458 * Method: getAngularDamping 459 * Signature: (J)F 460 */ 461 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularDamping 462 (JNIEnv *env, jobject object, jlong bodyId) { 463 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 464 if (body == NULL) { 465 jclass newExc = env->FindClass("java/lang/NullPointerException"); 466 env->ThrowNew(newExc, "The native object does not exist."); 467 return 0; 468 } 469 return body->getAngularDamping(); 470 } 471 472 /* 473 * Class: com_jme3_bullet_objects_PhysicsRigidBody 474 * Method: getRestitution 475 * Signature: (J)F 476 */ 477 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getRestitution 478 (JNIEnv *env, jobject object, jlong bodyId) { 479 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 480 if (body == NULL) { 481 jclass newExc = env->FindClass("java/lang/NullPointerException"); 482 env->ThrowNew(newExc, "The native object does not exist."); 483 return 0; 484 } 485 return body->getRestitution(); 486 } 487 488 /* 489 * Class: com_jme3_bullet_objects_PhysicsRigidBody 490 * Method: setRestitution 491 * Signature: (JF)V 492 */ 493 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setRestitution 494 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 495 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 496 if (body == NULL) { 497 jclass newExc = env->FindClass("java/lang/NullPointerException"); 498 env->ThrowNew(newExc, "The native object does not exist."); 499 return; 500 } 501 body->setRestitution(value); 502 } 503 504 /* 505 * Class: com_jme3_bullet_objects_PhysicsRigidBody 506 * Method: getAngularVelocity 507 * Signature: (JLcom/jme3/math/Vector3f;)V 508 */ 509 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularVelocity 510 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 511 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 512 if (body == NULL) { 513 jclass newExc = env->FindClass("java/lang/NullPointerException"); 514 env->ThrowNew(newExc, "The native object does not exist."); 515 return; 516 } 517 jmeBulletUtil::convert(env, &body->getAngularVelocity(), value); 518 } 519 520 /* 521 * Class: com_jme3_bullet_objects_PhysicsRigidBody 522 * Method: setAngularVelocity 523 * Signature: (JLcom/jme3/math/Vector3f;)V 524 */ 525 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularVelocity 526 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 527 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 528 if (body == NULL) { 529 jclass newExc = env->FindClass("java/lang/NullPointerException"); 530 env->ThrowNew(newExc, "The native object does not exist."); 531 return; 532 } 533 btVector3 vec = btVector3(); 534 jmeBulletUtil::convert(env, value, &vec); 535 body->setAngularVelocity(vec); 536 } 537 538 /* 539 * Class: com_jme3_bullet_objects_PhysicsRigidBody 540 * Method: getLinearVelocity 541 * Signature: (JLcom/jme3/math/Vector3f;)V 542 */ 543 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getLinearVelocity 544 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 545 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 546 if (body == NULL) { 547 jclass newExc = env->FindClass("java/lang/NullPointerException"); 548 env->ThrowNew(newExc, "The native object does not exist."); 549 return; 550 } 551 jmeBulletUtil::convert(env, &body->getLinearVelocity(), value); 552 } 553 554 /* 555 * Class: com_jme3_bullet_objects_PhysicsRigidBody 556 * Method: setLinearVelocity 557 * Signature: (JLcom/jme3/math/Vector3f;)V 558 */ 559 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setLinearVelocity 560 (JNIEnv *env, jobject object, jlong bodyId, jobject value) { 561 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 562 if (body == NULL) { 563 jclass newExc = env->FindClass("java/lang/NullPointerException"); 564 env->ThrowNew(newExc, "The native object does not exist."); 565 return; 566 } 567 btVector3 vec = btVector3(); 568 jmeBulletUtil::convert(env, value, &vec); 569 body->setLinearVelocity(vec); 570 } 571 572 /* 573 * Class: com_jme3_bullet_objects_PhysicsRigidBody 574 * Method: applyForce 575 * Signature: (JLcom/jme3/math/Vector3f;Lcom/jme3/math/Vector3f;)V 576 */ 577 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyForce 578 (JNIEnv *env, jobject object, jlong bodyId, jobject force, jobject location) { 579 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 580 if (body == NULL) { 581 jclass newExc = env->FindClass("java/lang/NullPointerException"); 582 env->ThrowNew(newExc, "The native object does not exist."); 583 return; 584 } 585 btVector3 vec1 = btVector3(); 586 btVector3 vec2 = btVector3(); 587 jmeBulletUtil::convert(env, force, &vec1); 588 jmeBulletUtil::convert(env, location, &vec2); 589 body->applyForce(vec1, vec2); 590 } 591 592 /* 593 * Class: com_jme3_bullet_objects_PhysicsRigidBody 594 * Method: applyCentralForce 595 * Signature: (JLcom/jme3/math/Vector3f;)V 596 */ 597 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyCentralForce 598 (JNIEnv *env, jobject object, jlong bodyId, jobject force) { 599 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 600 if (body == NULL) { 601 jclass newExc = env->FindClass("java/lang/NullPointerException"); 602 env->ThrowNew(newExc, "The native object does not exist."); 603 return; 604 } 605 btVector3 vec1 = btVector3(); 606 jmeBulletUtil::convert(env, force, &vec1); 607 body->applyCentralForce(vec1); 608 } 609 610 /* 611 * Class: com_jme3_bullet_objects_PhysicsRigidBody 612 * Method: applyTorque 613 * Signature: (JLcom/jme3/math/Vector3f;)V 614 */ 615 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyTorque 616 (JNIEnv *env, jobject object, jlong bodyId, jobject force) { 617 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 618 if (body == NULL) { 619 jclass newExc = env->FindClass("java/lang/NullPointerException"); 620 env->ThrowNew(newExc, "The native object does not exist."); 621 return; 622 } 623 btVector3 vec1 = btVector3(); 624 jmeBulletUtil::convert(env, force, &vec1); 625 body->applyTorque(vec1); 626 } 627 628 /* 629 * Class: com_jme3_bullet_objects_PhysicsRigidBody 630 * Method: applyImpulse 631 * Signature: (JLcom/jme3/math/Vector3f;Lcom/jme3/math/Vector3f;)V 632 */ 633 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyImpulse 634 (JNIEnv *env, jobject object, jlong bodyId, jobject force, jobject location) { 635 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 636 if (body == NULL) { 637 jclass newExc = env->FindClass("java/lang/NullPointerException"); 638 env->ThrowNew(newExc, "The native object does not exist."); 639 return; 640 } 641 btVector3 vec1 = btVector3(); 642 btVector3 vec2 = btVector3(); 643 jmeBulletUtil::convert(env, force, &vec1); 644 jmeBulletUtil::convert(env, location, &vec2); 645 body->applyImpulse(vec1, vec2); 646 } 647 648 /* 649 * Class: com_jme3_bullet_objects_PhysicsRigidBody 650 * Method: applyTorqueImpulse 651 * Signature: (JLcom/jme3/math/Vector3f;)V 652 */ 653 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_applyTorqueImpulse 654 (JNIEnv *env, jobject object, jlong bodyId, jobject force) { 655 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 656 if (body == NULL) { 657 jclass newExc = env->FindClass("java/lang/NullPointerException"); 658 env->ThrowNew(newExc, "The native object does not exist."); 659 return; 660 } 661 btVector3 vec1 = btVector3(); 662 jmeBulletUtil::convert(env, force, &vec1); 663 body->applyTorqueImpulse(vec1); 664 } 665 666 /* 667 * Class: com_jme3_bullet_objects_PhysicsRigidBody 668 * Method: clearForces 669 * Signature: (J)V 670 */ 671 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_clearForces 672 (JNIEnv *env, jobject object, jlong bodyId) { 673 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 674 if (body == NULL) { 675 jclass newExc = env->FindClass("java/lang/NullPointerException"); 676 env->ThrowNew(newExc, "The native object does not exist."); 677 return; 678 } 679 body->clearForces(); 680 } 681 682 /* 683 * Class: com_jme3_bullet_objects_PhysicsRigidBody 684 * Method: setCollisionShape 685 * Signature: (JJ)V 686 */ 687 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setCollisionShape 688 (JNIEnv *env, jobject object, jlong bodyId, jlong shapeId) { 689 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 690 if (body == NULL) { 691 jclass newExc = env->FindClass("java/lang/NullPointerException"); 692 env->ThrowNew(newExc, "The native object does not exist."); 693 return; 694 } 695 btCollisionShape* shape = reinterpret_cast<btCollisionShape*>(shapeId); 696 body->setCollisionShape(shape); 697 } 698 699 /* 700 * Class: com_jme3_bullet_objects_PhysicsRigidBody 701 * Method: activate 702 * Signature: (J)V 703 */ 704 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_activate 705 (JNIEnv *env, jobject object, jlong bodyId) { 706 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 707 if (body == NULL) { 708 jclass newExc = env->FindClass("java/lang/NullPointerException"); 709 env->ThrowNew(newExc, "The native object does not exist."); 710 return; 711 } 712 body->activate(false); 713 } 714 715 /* 716 * Class: com_jme3_bullet_objects_PhysicsRigidBody 717 * Method: isActive 718 * Signature: (J)Z 719 */ 720 JNIEXPORT jboolean JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_isActive 721 (JNIEnv *env, jobject object, jlong bodyId) { 722 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 723 if (body == NULL) { 724 jclass newExc = env->FindClass("java/lang/NullPointerException"); 725 env->ThrowNew(newExc, "The native object does not exist."); 726 return false; 727 } 728 return body->isActive(); 729 } 730 731 /* 732 * Class: com_jme3_bullet_objects_PhysicsRigidBody 733 * Method: setSleepingThresholds 734 * Signature: (JFF)V 735 */ 736 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setSleepingThresholds 737 (JNIEnv *env, jobject object, jlong bodyId, jfloat linear, jfloat angular) { 738 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 739 if (body == NULL) { 740 jclass newExc = env->FindClass("java/lang/NullPointerException"); 741 env->ThrowNew(newExc, "The native object does not exist."); 742 return; 743 } 744 body->setSleepingThresholds(linear, angular); 745 } 746 747 /* 748 * Class: com_jme3_bullet_objects_PhysicsRigidBody 749 * Method: setLinearSleepingThreshold 750 * Signature: (JF)V 751 */ 752 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setLinearSleepingThreshold 753 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 754 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 755 if (body == NULL) { 756 jclass newExc = env->FindClass("java/lang/NullPointerException"); 757 env->ThrowNew(newExc, "The native object does not exist."); 758 return; 759 } 760 body->setSleepingThresholds(value, body->getLinearSleepingThreshold()); 761 } 762 763 /* 764 * Class: com_jme3_bullet_objects_PhysicsRigidBody 765 * Method: setAngularSleepingThreshold 766 * Signature: (JF)V 767 */ 768 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularSleepingThreshold 769 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 770 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 771 if (body == NULL) { 772 jclass newExc = env->FindClass("java/lang/NullPointerException"); 773 env->ThrowNew(newExc, "The native object does not exist."); 774 return; 775 } 776 body->setSleepingThresholds(body->getAngularSleepingThreshold(), value); 777 } 778 779 /* 780 * Class: com_jme3_bullet_objects_PhysicsRigidBody 781 * Method: getLinearSleepingThreshold 782 * Signature: (J)F 783 */ 784 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getLinearSleepingThreshold 785 (JNIEnv *env, jobject object, jlong bodyId) { 786 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 787 if (body == NULL) { 788 jclass newExc = env->FindClass("java/lang/NullPointerException"); 789 env->ThrowNew(newExc, "The native object does not exist."); 790 return 0; 791 } 792 return body->getLinearSleepingThreshold(); 793 } 794 795 /* 796 * Class: com_jme3_bullet_objects_PhysicsRigidBody 797 * Method: getAngularSleepingThreshold 798 * Signature: (J)F 799 */ 800 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularSleepingThreshold 801 (JNIEnv *env, jobject object, jlong bodyId) { 802 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 803 if (body == NULL) { 804 jclass newExc = env->FindClass("java/lang/NullPointerException"); 805 env->ThrowNew(newExc, "The native object does not exist."); 806 return 0; 807 } 808 return body->getAngularSleepingThreshold(); 809 } 810 811 /* 812 * Class: com_jme3_bullet_objects_PhysicsRigidBody 813 * Method: getAngularFactor 814 * Signature: (J)F 815 */ 816 JNIEXPORT jfloat JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_getAngularFactor 817 (JNIEnv *env, jobject object, jlong bodyId) { 818 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 819 if (body == NULL) { 820 jclass newExc = env->FindClass("java/lang/NullPointerException"); 821 env->ThrowNew(newExc, "The native object does not exist."); 822 return 0; 823 } 824 return body->getAngularFactor().getX(); 825 } 826 827 /* 828 * Class: com_jme3_bullet_objects_PhysicsRigidBody 829 * Method: setAngularFactor 830 * Signature: (JF)V 831 */ 832 JNIEXPORT void JNICALL Java_com_jme3_bullet_objects_PhysicsRigidBody_setAngularFactor 833 (JNIEnv *env, jobject object, jlong bodyId, jfloat value) { 834 btRigidBody* body = reinterpret_cast<btRigidBody*>(bodyId); 835 if (body == NULL) { 836 jclass newExc = env->FindClass("java/lang/NullPointerException"); 837 env->ThrowNew(newExc, "The native object does not exist."); 838 return; 839 } 840 btVector3 vec1 = btVector3(); 841 vec1.setX(value); 842 vec1.setY(value); 843 vec1.setZ(value); 844 body->setAngularFactor(vec1); 845 } 846 847 #ifdef __cplusplus 848 } 849 #endif 850