Professional Documents
Culture Documents
Laporan Praktikum Desain Aplikasi Multimedia Dan Grafis Modul 13 "Hello Physics "
Laporan Praktikum Desain Aplikasi Multimedia Dan Grafis Modul 13 "Hello Physics "
Laporan Praktikum Desain Aplikasi Multimedia Dan Grafis Modul 13 "Hello Physics "
H. HAMID
201110370311274
4B
SOURCE CODE
package jme3test.helloworld;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.TextureKey;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.font.BitmapText;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.material.Material;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.scene.shape.Sphere;
import com.jme3.scene.shape.Sphere.TextureMode;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
/**
* Example 12 - how to give objects physical properties so they bounce and fall.
* @author base code by double1984, updated by zathras
*/
public class HelloPhysics extends SimpleApplication {
/** Prepare geometries and physical nodes for bricks and cannon balls. */
private RigidBodyControl brick_phy;
private static final Box box;
private RigidBodyControl ball_phy;
static {
/** Initialize the cannon ball geometry */
sphere = new Sphere(32, 32, 0.4f, true, false);
sphere.setTextureMode(TextureMode.Projected);
/** Initialize the brick geometry */
box = new Box(Vector3f.ZERO, brickLength, brickHeight, brickWidth);
box.scaleTextureCoordinates(new Vector2f(1f, .5f));
/** Initialize the floor geometry */
floor = new Box(Vector3f.ZERO, 10f, 0.1f, 5f);
floor.scaleTextureCoordinates(new Vector2f(3, 6));
}
@Override
/**
* Every time the shoot action is triggered, a new cannon ball is produced.
* The ball is set up to fly from the camera position in the camera direction.
*/
private ActionListener actionListener = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("shoot") && !keyPressed) {
makeCannonBall();
}
}
};
bulletAppState.getPhysicsSpace().add(floor_phy);
}
brick_geo.setMaterial(wall_mat);
rootNode.attachChild(brick_geo);
/** Position the brick geometry */
brick_geo.setLocalTranslation(loc);
/** Make brick physical with a mass > 0.0f. */
brick_phy = new RigidBodyControl(2f);
/** Add physical brick to physics space. */
brick_geo.addControl(brick_phy);
bulletAppState.getPhysicsSpace().add(brick_phy);
}
/** A plus sign used as crosshairs to help the player with aiming.*/
protected void initCrossHairs() {
setDisplayStatView(false);
//guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
BitmapText ch = new BitmapText(guiFont, false);
ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
ch.setText("+");
// fake crosshairs :)
ch.setLocalTranslation( // center
settings.getWidth() / 2,
settings.getHeight() / 2, 0);
guiNode.attachChild(ch);
}
}
PRINT SCREEN OUTPUT
PADA PROGRAM DI ATAS BOX AKAN MEMPUNYAI MASING GERAKAN DENGAN AKSI
MASING-MASING TOMBOL,YAITU:
A. TOMBOL D
B. TOMBOL A
C. TOMBOL W
D. TOMBOL S
// 2x2 texture animation fire.setEndColor( new ColorRGBA(1f, 0f, 0f, 1f)); // red
fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
DARI METHOD DI ATAS TERDAPAT MASING-MASING FUNGSI:
A. MEMBUAT BENTUK TEKSTUR DAN SEBAGAI TITIK ASAL TEKSTUR
B. BENTUK GEOMETRY TEKSTUR
C. SEBAGAI PEMBUAT TEKSTUR
D. MEMBUAT WARNA DAN TEKSTUR
E. MEMUNCULKAN TEKSTUR DIKOTAK DIALOG
KESIMPULAN