control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution());
control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution());
ballGeometry.getControl(RigidBodyControl.class).setRestitution(1); rootNode.attachChild(ballGeometry); space.add(ballGeometry);
player.setRestitution(PLAYER_REST);
@Override public void makeSpheres(Material mat) { for (int i = 0; i < 5; i++) { RigidBodyControl rbc = new RigidBodyControl(.001f); Sphere s = findOrMakeMeshShapeFacade(null).makeSphereMesh(16, 16, 0.5f); Geometry ballGeometry = findOrMakeSceneGeometryFacade(null).makeGeom( GeomFactory.GEOM_SOCCER_BALL, s, mat, rbc); //RigidBodyControl automatically uses Sphere collision shapes when attached to single geometry with sphere mesh ballGeometry.getControl(RigidBodyControl.class).setRestitution(1); ballGeometry.setLocalTranslation(i, 2, -3); myParentNode.attachChild(ballGeometry); myPhysSpc.add(ballGeometry); } } @Override public void makeImmovableSphere(Material mat) {
Ball(String ballUri, Vector3f position, ColorRGBA color, float size) { uri = ballUri; initialPosition = position; radius = size; Sphere ball = new Sphere(20, 20, size); material = myStandardMaterial.clone(); material.setBoolean("UseMaterialColors", true); material.setColor("Diffuse", color); material.setColor("Ambient", color); material.setColor("Specular", color); material.setFloat("Shininess", 25f); control = new RigidBodyControl(sphereShape(size), (float) (pow(size, 3) * MASS_COEFFICIENT)); control.setRestitution(0.5f); geometry = myFactory.makeGeom(uri, ball, material, control); reset(); myRenderContext.enqueueCallable(new Callable<Void>() { // Do this on main render thread @Override public Void call() throws Exception { //geometry.addControl(control); myPhysics.add(control); myBallsNode.attachChild(geometry); control.setPhysicsLocation(initialPosition); // Probably unnecessary - setting this here, in reset() above, and using resetAllBalls in buildModelFromTurtle because they don't want to go to the initial position! Probably some sort of jME concurrency thing... return null; } }); }
@Override public Control cloneForSpatial(Spatial spatial) { RigidBodyControl control = new RigidBodyControl(collisionShape, mass); control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); control.setKinematic(isKinematic()); control.setKinematicSpatial(isKinematicSpatial()); control.setLinearSleepingThreshold(getLinearSleepingThreshold()); control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution()); if (mass > 0) { control.setAngularVelocity(getAngularVelocity()); control.setLinearVelocity(getLinearVelocity()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); return control; }
public Control cloneForSpatial(Spatial spatial) { RigidBodyControl control = new RigidBodyControl(collisionShape, mass); control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); control.setKinematic(isKinematic()); control.setKinematicSpatial(isKinematicSpatial()); control.setLinearSleepingThreshold(getLinearSleepingThreshold()); control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution()); if (mass > 0) { control.setAngularVelocity(getAngularVelocity()); control.setLinearVelocity(getLinearVelocity()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.setSpatial(spatial); return control; }
control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution());
@Override public Object jmeClone() { RigidBodyControl control = new RigidBodyControl(collisionShape, mass); control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); control.setKinematic(isKinematic()); control.setKinematicSpatial(isKinematicSpatial()); control.setLinearSleepingThreshold(getLinearSleepingThreshold()); control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution()); if (mass > 0) { control.setAngularVelocity(getAngularVelocity()); control.setLinearVelocity(getLinearVelocity()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.spatial = this.spatial; control.setEnabled(isEnabled()); return control; }
control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution());