public void update(float tpf) { if (enabled && spatial != null) { getMotionState().applyTransform(spatial); } }
private native void getWorldLocation(long stateId, Vector3f vec);
private native void getWorldRotationQuat(long stateId, Quaternion vec);
for (PhysicsBoneLink link : boneLinks.values()) { Vector3f p = link.rigidBody.getMotionState().getWorldLocation(); Vector3f position = vars.vect1; Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat(); Quaternion q2 = vars.quat1; Quaternion q3 = vars.quat2;
/** * Test whether physics-space coordinates should match the spatial's local * coordinates. * * @return true if matching local coordinates, false if matching world * coordinates */ public boolean isApplyPhysicsLocal() { return motionState.isApplyPhysicsLocal(); }
/** * Alter whether physics-space coordinates should match the spatial's local * coordinates. * * @param applyPhysicsLocal true→match local coordinates, * false→match world coordinates (default=false) */ public void setApplyPhysicsLocal(boolean applyPhysicsLocal) { motionState.setApplyPhysicsLocal(applyPhysicsLocal); }
@Override protected void postRebuild() { super.postRebuild(); motionState.setVehicle(this); createVehicle(physicsSpace); }
/** * Instantiate a motion state. */ public RigidBodyMotionState() { this.motionStateId = createMotionState(); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created MotionState {0}", Long.toHexString(motionStateId)); }
/** * Finalize this motion state just before it is destroyed. Should be invoked * only by a subclass or by the garbage collector. * * @throws Throwable ignored by the garbage collector */ @Override protected void finalize() throws Throwable { super.finalize(); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing MotionState {0}", Long.toHexString(motionStateId)); finalizeNative(motionStateId); }
/** * Build/rebuild this body after parameters have changed. */ protected void rebuildRigidBody() { boolean removed = false; if (collisionShape instanceof MeshCollisionShape && mass != 0) { throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); } if (objectId != 0) { if (isInWorld(objectId)) { PhysicsSpace.getPhysicsSpace().remove(this); removed = true; } Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Clearing RigidBody {0}", Long.toHexString(objectId)); finalizeNative(objectId); } preRebuild(); objectId = createRigidBody(mass, motionState.getObjectId(), collisionShape.getObjectId()); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created RigidBody {0}", Long.toHexString(objectId)); postRebuild(); if (removed) { PhysicsSpace.getPhysicsSpace().add(this); } }
protected RigidBodyMotionState motionState = new RigidBodyMotionState();
for (PhysicsBoneLink link : boneLinks.values()) { Vector3f p = link.rigidBody.getMotionState().getWorldLocation(); Vector3f position = vars.vect1; Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat(); Quaternion q2 = vars.quat1; Quaternion q3 = vars.quat2;
/** * Test whether physics-space coordinates should match the spatial's local * coordinates. * * @return true if matching local coordinates, false if matching world * coordinates */ public boolean isApplyPhysicsLocal() { return motionState.isApplyPhysicsLocal(); }
/** * Alter whether physics-space coordinates should match the spatial's local * coordinates. * * @param applyPhysicsLocal true→match local coordinates, * false→match world coordinates (default=false) */ public void setApplyPhysicsLocal(boolean applyPhysicsLocal) { motionState.setApplyPhysicsLocal(applyPhysicsLocal); }
@Override protected void postRebuild() { super.postRebuild(); if (tuning == null) { tuning = new VehicleTuning(); } rBody.setActivationState(CollisionObject.DISABLE_DEACTIVATION); motionState.setVehicle(this); if (physicsSpace != null) { createVehicle(physicsSpace); } }
public RigidBodyMotionState() { this.motionStateId = createMotionState(); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created MotionState {0}", Long.toHexString(motionStateId)); }
@Override protected void finalize() throws Throwable { super.finalize(); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing MotionState {0}", Long.toHexString(motionStateId)); finalizeNative(motionStateId); }
/** * Builds/rebuilds the phyiscs body when parameters have changed */ protected void rebuildRigidBody() { boolean removed = false; if (collisionShape instanceof MeshCollisionShape && mass != 0) { throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); } if (objectId != 0) { if (isInWorld(objectId)) { PhysicsSpace.getPhysicsSpace().remove(this); removed = true; } Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Clearing RigidBody {0}", Long.toHexString(objectId)); finalizeNative(objectId); } preRebuild(); objectId = createRigidBody(mass, motionState.getObjectId(), collisionShape.getObjectId()); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created RigidBody {0}", Long.toHexString(objectId)); postRebuild(); if (removed) { PhysicsSpace.getPhysicsSpace().add(this); } }
protected RigidBodyMotionState motionState = new RigidBodyMotionState(); protected float mass = 1.0f; protected boolean kinematic = false;
Vector3f p = link.rigidBody.getMotionState().getWorldLocation(); Quaternion q = link.rigidBody.getMotionState().getWorldRotationQuat();