|
@@ -1,4 +1,4 @@
|
|
|
-/**
|
|
|
+/*
|
|
|
* Copyright (c) 2009-2021 jMonkeyEngine
|
|
|
* All rights reserved.
|
|
|
*
|
|
@@ -80,26 +80,26 @@ public class HelloPhysics extends SimpleApplication {
|
|
|
private static final float brickHeight = 0.12f;
|
|
|
|
|
|
static {
|
|
|
- /** Initialize the cannon ball geometry */
|
|
|
+ /* Initialize the cannonball geometry */
|
|
|
sphere = new Sphere(32, 32, 0.4f, true, false);
|
|
|
sphere.setTextureMode(TextureMode.Projected);
|
|
|
- /** Initialize the brick geometry */
|
|
|
+ /* Initialize the brick geometry */
|
|
|
box = new Box(brickLength, brickHeight, brickWidth);
|
|
|
box.scaleTextureCoordinates(new Vector2f(1f, .5f));
|
|
|
- /** Initialize the floor geometry */
|
|
|
+ /* Initialize the floor geometry */
|
|
|
floor = new Box(10f, 0.1f, 5f);
|
|
|
floor.scaleTextureCoordinates(new Vector2f(3, 6));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void simpleInitApp() {
|
|
|
- /** Set up Physics Game */
|
|
|
+ /* Set up Physics Game */
|
|
|
bulletAppState = new BulletAppState();
|
|
|
stateManager.attach(bulletAppState);
|
|
|
- /** Configure cam to look at scene */
|
|
|
+ /* Configure cam to look at scene */
|
|
|
cam.setLocation(new Vector3f(0, 4f, 6f));
|
|
|
cam.lookAt(new Vector3f(2, 2, 0), Vector3f.UNIT_Y);
|
|
|
- /** Initialize the scene, materials, inputs, and physics space */
|
|
|
+ /* Initialize the scene, materials, inputs, and physics space */
|
|
|
initInputs();
|
|
|
initMaterials();
|
|
|
initWall();
|
|
@@ -178,15 +178,15 @@ public class HelloPhysics extends SimpleApplication {
|
|
|
|
|
|
/** This method creates one individual physical brick. */
|
|
|
private void makeBrick(Vector3f loc) {
|
|
|
- /** Create a brick geometry and attach to scene graph. */
|
|
|
+ /* Create a brick geometry and attach it to the scene graph. */
|
|
|
Geometry brick_geo = new Geometry("brick", box);
|
|
|
brick_geo.setMaterial(wall_mat);
|
|
|
rootNode.attachChild(brick_geo);
|
|
|
- /** Position the brick geometry */
|
|
|
+ /* Position the brick geometry. */
|
|
|
brick_geo.setLocalTranslation(loc);
|
|
|
- /** Make brick physical with a mass > 0.0f. */
|
|
|
+ /* Make brick physical with a mass > 0. */
|
|
|
RigidBodyControl brick_phy = new RigidBodyControl(2f);
|
|
|
- /** Add physical brick to physics space. */
|
|
|
+ /* Add physical brick to physics space. */
|
|
|
brick_geo.addControl(brick_phy);
|
|
|
bulletAppState.getPhysicsSpace().add(brick_phy);
|
|
|
}
|
|
@@ -195,18 +195,18 @@ public class HelloPhysics extends SimpleApplication {
|
|
|
* By default, the ball is accelerated and flies
|
|
|
* from the camera position in the camera direction.*/
|
|
|
public void makeCannonBall() {
|
|
|
- /** Create a cannon ball geometry and attach to scene graph. */
|
|
|
+ /* Create a cannonball geometry and attach to scene graph. */
|
|
|
Geometry ball_geo = new Geometry("cannon ball", sphere);
|
|
|
ball_geo.setMaterial(stone_mat);
|
|
|
rootNode.attachChild(ball_geo);
|
|
|
- /** Position the cannon ball */
|
|
|
+ /* Position the cannonball. */
|
|
|
ball_geo.setLocalTranslation(cam.getLocation());
|
|
|
- /** Make the ball physical with a mass > 0.0f */
|
|
|
+ /* Make the ball physical with a mass > 0.0f */
|
|
|
RigidBodyControl ball_phy = new RigidBodyControl(1f);
|
|
|
- /** Add physical ball to physics space. */
|
|
|
+ /* Add physical ball to physics space. */
|
|
|
ball_geo.addControl(ball_phy);
|
|
|
bulletAppState.getPhysicsSpace().add(ball_phy);
|
|
|
- /** Accelerate the physical ball to shoot it. */
|
|
|
+ /* Accelerate the physical ball to shoot it. */
|
|
|
ball_phy.setLinearVelocity(cam.getDirection().mult(25));
|
|
|
}
|
|
|
|