Java Code Examples for com.jme3.bullet.control.RigidBodyControl#setRestitution()
The following examples show how to use
com.jme3.bullet.control.RigidBodyControl#setRestitution() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestIssue1283.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Add a thin wall to the scene and physics space. */ private void addWall() { float thickness = 0.1f; Box wallMesh = new Box(10f, 10f, thickness); Geometry geometry = new Geometry("wall", wallMesh); rootNode.attachChild(geometry); geometry.setMaterial(wallMaterial); float mass = 0f; // static rigid body RigidBodyControl physicsControl = new RigidBodyControl(mass); geometry.addControl(physicsControl); physicsControl.setRestitution(0.8f); physicsSpace.add(physicsControl); }
Example 2
Source File: TestIssue1283.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Add a projectile to the scene and physics space. Its initial position and * velocity are determined by the camera the and mouse pointer. */ private void launchProjectile() { Vector2f screenXY = inputManager.getCursorPosition(); float nearZ = 0f; Vector3f nearLocation = cam.getWorldCoordinates(screenXY, nearZ); float farZ = 1f; Vector3f farLocation = cam.getWorldCoordinates(screenXY, farZ); Vector3f direction = farLocation.subtract(nearLocation); direction.normalizeLocal(); Geometry geometry = new Geometry("projectile", projectileMesh); rootNode.attachChild(geometry); geometry.setLocalTranslation(nearLocation); geometry.setMaterial(projectileMaterial); float mass = 1f; RigidBodyControl physicsControl = new RigidBodyControl(mass); geometry.addControl(physicsControl); physicsControl.setCcdMotionThreshold(0.01f); physicsControl.setCcdSweptSphereRadius(projectileRadius); physicsControl.setCollisionGroup( PhysicsCollisionObject.COLLISION_GROUP_02); physicsControl.setCollideWithGroups( PhysicsCollisionObject.COLLISION_GROUP_02); physicsControl.setRestitution(0.8f); float projectileSpeed = 250f; // physics-space units per second Vector3f initialVelocity = direction.mult(projectileSpeed); physicsControl.setLinearVelocity(initialVelocity); physicsSpace.add(physicsControl); }