private native float getMargin(long objectId);
/** * De-serialize this shape, for example when loading from a J3O file. * * @param im importer (not null) * @throws IOException from importer */ public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule capsule = im.getCapsule(this); radius = capsule.readFloat("radius", 0.5f); createShape(); }
public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule capsule = ex.getCapsule(this); capsule.writeSavableArrayList(children, "children", new ArrayList<ChildCollisionShape>()); }
protected void preRebuild() { collisionShape.calculateLocalInertia(mass, localInertia); if (constructionInfo == null) { constructionInfo = new RigidBodyConstructionInfo(mass, motionState, collisionShape.getCShape(), localInertia); } else { constructionInfo.mass = mass; constructionInfo.collisionShape = collisionShape.getCShape(); constructionInfo.motionState = motionState; } }
/** * Instantiate an enabled control to visualize the specified character. * * @param debugAppState which app state (not null, alias created) * @param body the character to visualize (not null, alias created) */ public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_PINK); }
private void addChildShapeDirect(CollisionShape shape, Vector3f location, Matrix3f rotation) { if(shape instanceof CompoundCollisionShape){ throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!"); } // Transform transA = new Transform(Converter.convert(rotation)); // Converter.convert(location, transA.origin); // Converter.convert(rotation, transA.basis); addChildShape(objectId, shape.getObjectId(), location, rotation); // ((CompoundShape) objectId).addChildShape(transA, shape.getObjectId()); }
public static Mesh getDebugMesh(CollisionShape shape) { Mesh mesh = new Mesh(); DebugMeshCallback callback = new DebugMeshCallback(); /* * Populate the mesh based on an unscaled shape; * the shape's scale will be applied later, to the geometry. */ Vector3f savedScale = shape.getScale().clone(); shape.setScale(Vector3f.UNIT_XYZ); getVertices(shape.getObjectId(), callback); shape.setScale(savedScale); mesh.setBuffer(Type.Position, 3, callback.getVertices()); mesh.getFloatBuffer(Type.Position).clear(); return mesh; }
/** * Finalize this shape 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 Mesh {0}", Long.toHexString(meshId)); finalizeNative(meshId); }
/** * Finalize this shape 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 CollisionShape {0}", Long.toHexString(objectId)); finalizeNative(objectId); }
/** * Alter the scaling factors of this shape. CAUTION: Not all shapes can be * scaled. * <p> * Note that if the shape is shared (between collision objects and/or * compound shapes) changes can have unintended consequences. * * @param scale the desired scaling factor for each local axis (not null, no * negative component, unaffected, default=1,1,1) */ public void setScale(Vector3f scale) { this.scale.set(scale); setLocalScaling(objectId, scale); } /**
private native void setMargin(long objectId, float margin);
/** * Sets the mass of this PhysicsRigidBody, objects with mass=0 are static. * @param mass */ public void setMass(float mass) { this.mass = mass; if(collisionShape instanceof MeshCollisionShape && mass != 0){ throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); } if (collisionShape != null) { collisionShape.calculateLocalInertia(mass, localInertia); } if (rBody != null) { rBody.setMassProps(mass, localInertia); if (mass == 0.0f) { rBody.setCollisionFlags(rBody.getCollisionFlags() | CollisionFlags.STATIC_OBJECT); } else { rBody.setCollisionFlags(rBody.getCollisionFlags() & ~CollisionFlags.STATIC_OBJECT); } } }
/** * Instantiate an enabled control to visualize the specified character. * * @param debugAppState which app state (not null, alias created) * @param body the character to visualize (not null, alias created) */ public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) { super(debugAppState); this.body = body; myShape = body.getCollisionShape(); oldScale.set(myShape.getScale()); this.geom = DebugShapeFactory.getDebugShape(myShape); this.geom.setName(body.toString()); geom.setMaterial(debugAppState.DEBUG_PINK); }
/** * Remove a child from this shape. * * @param shape the child shape to remove (not null) */ public void removeChildShape(CollisionShape shape) { removeChildShape(objectId, shape.getObjectId()); // ((CompoundShape) objectId).removeChildShape(shape.getObjectId()); for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext();) { ChildCollisionShape childCollisionShape = it.next(); if (childCollisionShape.shape == shape) { it.remove(); } } }
public void setCollisionShape(CollisionShape collisionShape) { super.setCollisionShape(collisionShape); if(collisionShape instanceof MeshCollisionShape && mass!=0){ throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); } if (rBody == null) { rebuildRigidBody(); } else { collisionShape.calculateLocalInertia(mass, localInertia); constructionInfo.collisionShape = collisionShape.getCShape(); rBody.setCollisionShape(collisionShape.getCShape()); } }
/** * Finalize this shape 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 public void finalize() throws Throwable { super.finalize(); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing Mesh {0}", Long.toHexString(this.meshId)); if (this.meshId > 0) { this.finalizeNative(this.meshId, this.nativeBVHBuffer); } }
@Override protected void finalize() throws Throwable { super.finalize(); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Finalizing CollisionShape {0}", Long.toHexString(objectId)); finalizeNative(objectId); }
public void setScale(Vector3f scale) { this.scale.set(scale); setLocalScaling(objectId, scale); }
private native void setMargin(long objectId, float margin);
/** * Sets the mass of this PhysicsRigidBody, objects with mass=0 are static. * @param mass */ public void setMass(float mass) { this.mass = mass; if(collisionShape instanceof MeshCollisionShape && mass != 0){ throw new IllegalStateException("Dynamic rigidbody can not have mesh collision shape!"); } if (collisionShape != null) { collisionShape.calculateLocalInertia(mass, localInertia); } if (rBody != null) { rBody.setMassProps(mass, localInertia); if (mass == 0.0f) { rBody.setCollisionFlags(rBody.getCollisionFlags() | CollisionFlags.STATIC_OBJECT); } else { rBody.setCollisionFlags(rBody.getCollisionFlags() & ~CollisionFlags.STATIC_OBJECT); } } }