159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta/*
259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * To change this template, choose Tools | Templates
359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * and open the template in the editor.
459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */
559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
659b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapackage jme3test.bullet;
759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta/*
959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Copyright (c) 2009-2010 jMonkeyEngine
1059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * All rights reserved.
1159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *
1259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * Redistribution and use in source and binary forms, with or without
1359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * modification, are permitted provided that the following conditions are
1459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * met:
1559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *
1659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * * Redistributions of source code must retain the above copyright
1759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *   notice, this list of conditions and the following disclaimer.
1859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *
1959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * * Redistributions in binary form must reproduce the above copyright
2059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *   notice, this list of conditions and the following disclaimer in the
2159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *   documentation and/or other materials provided with the distribution.
2259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *
2359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
2459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *   may be used to endorse or promote products derived from this software
2559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *   without specific prior written permission.
2659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *
2759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
3059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
3159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
3259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
3359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
3459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
3559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */
3959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
4059b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.app.SimpleApplication;
4159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.asset.TextureKey;
4259b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.bullet.BulletAppState;
4359b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.bullet.PhysicsSpace;
4459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.bullet.collision.shapes.SphereCollisionShape;
4559b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.bullet.control.RigidBodyControl;
4659b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.font.BitmapText;
4759b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.input.MouseInput;
4859b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.input.controls.ActionListener;
4959b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.input.controls.MouseButtonTrigger;
5059b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.material.Material;
5159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.math.Vector2f;
5259b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.math.Vector3f;
5359b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.renderer.queue.RenderQueue.ShadowMode;
5459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.Geometry;
5559b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.shape.Box;
5659b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.shape.Sphere;
5759b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.shape.Sphere.TextureMode;
5859b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.shadow.PssmShadowRenderer;
5959b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.shadow.PssmShadowRenderer.CompareMode;
6059b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.shadow.PssmShadowRenderer.FilterMode;
6159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture;
6259b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture.WrapMode;
6359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
6459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta/**
6559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *
6659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @author double1984 (tower mod by atom)
6759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */
6859b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapublic class TestBrickTower extends SimpleApplication {
6959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
7059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    int bricksPerLayer = 8;
7159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    int brickLayers = 30;
7259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
7359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    static float brickWidth = .75f, brickHeight = .25f, brickDepth = .25f;
7459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    float radius = 3f;
7559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    float angle = 0;
7659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
7759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
7859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    Material mat;
7959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    Material mat2;
8059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    Material mat3;
8159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    PssmShadowRenderer bsr;
8259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    private Sphere bullet;
8359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    private Box brick;
8459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    private SphereCollisionShape bulletCollisionShape;
8559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
8659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    private BulletAppState bulletAppState;
8759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
8859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    public static void main(String args[]) {
8959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        TestBrickTower f = new TestBrickTower();
9059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        f.start();
9159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
9259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
9359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    @Override
9459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    public void simpleInitApp() {
9559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bulletAppState = new BulletAppState();
9659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
9759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta     //   bulletAppState.setEnabled(false);
9859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        stateManager.attach(bulletAppState);
9959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bullet = new Sphere(32, 32, 0.4f, true, false);
10059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bullet.setTextureMode(TextureMode.Projected);
10159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bulletCollisionShape = new SphereCollisionShape(0.4f);
10259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
10359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        brick = new Box(Vector3f.ZERO, brickWidth, brickHeight, brickDepth);
10459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
10559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
10659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        initMaterial();
10759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        initTower();
10859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        initFloor();
10959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        initCrossHairs();
11059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        this.cam.setLocation(new Vector3f(0, 25f, 8f));
11159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
11259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        cam.setFrustumFar(80);
11359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
11459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        inputManager.addListener(actionListener, "shoot");
11559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        rootNode.setShadowMode(ShadowMode.Off);
11659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bsr = new PssmShadowRenderer(assetManager, 1024, 2);
11759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
11859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bsr.setLambda(0.55f);
11959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bsr.setShadowIntensity(0.6f);
12059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bsr.setCompareMode(CompareMode.Hardware);
12159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        bsr.setFilterMode(FilterMode.PCF4);
12259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        viewPort.addProcessor(bsr);
12359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
12459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
12559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    private PhysicsSpace getPhysicsSpace() {
12659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        return bulletAppState.getPhysicsSpace();
12759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
12859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    private ActionListener actionListener = new ActionListener() {
12959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
13059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        public void onAction(String name, boolean keyPressed, float tpf) {
13159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            if (name.equals("shoot") && !keyPressed) {
13259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                Geometry bulletg = new Geometry("bullet", bullet);
13359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                bulletg.setMaterial(mat2);
13459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                bulletg.setShadowMode(ShadowMode.CastAndReceive);
13559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                bulletg.setLocalTranslation(cam.getLocation());
13659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1);
13759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta//                RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1);
13859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                bulletNode.setLinearVelocity(cam.getDirection().mult(25));
13959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                bulletg.addControl(bulletNode);
14059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                rootNode.attachChild(bulletg);
14159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                getPhysicsSpace().add(bulletNode);
14259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            }
14359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        }
14459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    };
14559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
14659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    public void initTower() {
14759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        double tempX = 0;
14859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        double tempY = 0;
14959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        double tempZ = 0;
15059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        angle = 0f;
15159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        for (int i = 0; i < brickLayers; i++){
15259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            // Increment rows
15359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            if(i!=0)
15459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                tempY+=brickHeight*2;
15559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            else
15659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                tempY=brickHeight;
15759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            // Alternate brick seams
15859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            angle = 360.0f / bricksPerLayer * i/2f;
15959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            for (int j = 0; j < bricksPerLayer; j++){
16059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              tempZ = Math.cos(Math.toRadians(angle))*radius;
16159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              tempX = Math.sin(Math.toRadians(angle))*radius;
16259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              System.out.println("x="+((float)(tempX))+" y="+((float)(tempY))+" z="+(float)(tempZ));
16359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              Vector3f vt = new Vector3f((float)(tempX), (float)(tempY), (float)(tempZ));
16459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              // Add crenelation
16559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              if (i==brickLayers-1){
16659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                if (j%2 == 0){
16759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                    addBrick(vt);
16859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                }
16959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              }
17059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              // Create main tower
17159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              else {
17259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                addBrick(vt);
17359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              }
17459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta              angle += 360.0/bricksPerLayer;
17559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta            }
17659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta          }
17759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
17859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
17959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
18059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    public void initFloor() {
18159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        Box floorBox = new Box(Vector3f.ZERO, 10f, 0.1f, 5f);
18259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        floorBox.scaleTextureCoordinates(new Vector2f(3, 6));
18359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
18459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        Geometry floor = new Geometry("floor", floorBox);
18559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        floor.setMaterial(mat3);
18659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        floor.setShadowMode(ShadowMode.Receive);
18759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        floor.setLocalTranslation(0, 0, 0);
18859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        floor.addControl(new RigidBodyControl(0));
18959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        this.rootNode.attachChild(floor);
19059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        this.getPhysicsSpace().add(floor);
19159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
19259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
19359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    public void initMaterial() {
19459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
19559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
19659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        key.setGenerateMips(true);
19759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        Texture tex = assetManager.loadTexture(key);
19859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        mat.setTexture("ColorMap", tex);
19959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
20059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
20159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        TextureKey key2 = new TextureKey("Textures/Terrain/Rock/Rock.PNG");
20259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        key2.setGenerateMips(true);
20359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        Texture tex2 = assetManager.loadTexture(key2);
20459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        mat2.setTexture("ColorMap", tex2);
20559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
20659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        mat3 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
20759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        TextureKey key3 = new TextureKey("Textures/Terrain/Pond/Pond.jpg");
20859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        key3.setGenerateMips(true);
20959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        Texture tex3 = assetManager.loadTexture(key3);
21059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        tex3.setWrap(WrapMode.Repeat);
21159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        mat3.setTexture("ColorMap", tex3);
21259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
21359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
21459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    public void addBrick(Vector3f ori) {
21559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        Geometry reBoxg = new Geometry("brick", brick);
21659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        reBoxg.setMaterial(mat);
21759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        reBoxg.setLocalTranslation(ori);
21859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        reBoxg.rotate(0f, (float)Math.toRadians(angle) , 0f );
21959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        reBoxg.addControl(new RigidBodyControl(1.5f));
22059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        reBoxg.setShadowMode(ShadowMode.CastAndReceive);
22159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f);
22259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        this.rootNode.attachChild(reBoxg);
22359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        this.getPhysicsSpace().add(reBoxg);
22459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
22559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
22659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    protected void initCrossHairs() {
22759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
22859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        BitmapText ch = new BitmapText(guiFont, false);
22959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
23059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        ch.setText("+"); // crosshairs
23159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        ch.setLocalTranslation( // center
23259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                settings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2,
23359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta                settings.getHeight() / 2 + ch.getLineHeight() / 2, 0);
23459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta        guiNode.attachChild(ch);
23559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta    }
23659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta}