Package net.cis.client.game

Source Code of net.cis.client.game.TestModelLoading

/**
*
*/
package net.cis.client.game;

import net.cis.client.game.scenery.factory.SkyBoxFactory;

import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.BloomFilter;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

/**
* @author Matze
*
*/
public class TestModelLoading extends SimpleApplication {

  /*
   * (non-Javadoc)
   *
   * @see com.jme3.app.SimpleApplication#simpleInitApp()
   */
  @Override
  public void simpleInitApp() {

    initializeScenery();

  }

  private void initializeScenery() {
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
    fpp.addFilter(bloom);
    viewPort.addProcessor(fpp);

    // Skybox
    rootNode.attachChild(SkyBoxFactory.createSimpleSkyBox(assetManager));
    Spatial tree = assetManager.loadModel("stuff/trees/fir/Tree.mesh.xml");
    tree.scale(0.05f, 0.05f, 0.05f);
    rootNode.attachChild(tree);

    Spatial leaves = assetManager
        .loadModel("stuff/trees/fir/Leaves.mesh.xml");
    leaves.scale(0.05f, 0.05f, 0.05f);
    rootNode.attachChild(leaves);

    Spatial sign = assetManager.loadModel("stuff/signs/Sign.mesh.xml");
    sign.setLocalTranslation(0.3f, 0.1f, 0f);

    // Spatial tree =
    // assetManager.loadModel("stuff/trees/fir/Tree.mesh.xml");
    // tree.scale(0.05f, 0.05f, 0.05f);
    // rootNode.attachChild(tree);
    //
    // Spatial leaves =
    // assetManager.loadModel("stuff/trees/fir/Leaves.mesh.xml");
    // leaves.scale(0.05f, 0.05f, 0.05f);
    // rootNode.attachChild(leaves);
    //
    // Spatial sign = assetManager.loadModel("stuff/signs/Sign.mesh.xml");
    // sign.setLocalTranslation(0.3f, 0.1f, 0f);
    // Material mat_asteroid = new Material(assetManager,
    // "Common/MatDefs/Misc/Unshaded.j3md");
    // mat_asteroid.setTexture("ColorMap",
    // assetManager.loadTexture("stuff/signs/sign.jpg"));
    // sign.setMaterial(mat_asteroid);
    // sign.scale(0.02f, 0.02f, 0.02f);
    //
    // rootNode.attachChild(sign);
    //
    Node ship = new Node("Carrier");
    Spatial cube = assetManager
        .loadModel("spaceobject/station/platform/Platform.mesh.xml");

    Material mat_asteroid = new Material(assetManager,
        "Common/MatDefs/Light/Lighting.j3md");
    mat_asteroid.setTexture("DiffuseMap", assetManager
        .loadTexture("spaceobject/station/platform/hull.jpg"));
    cube.setMaterial(mat_asteroid);
    ship.attachChild(cube);

    Spatial wall = assetManager
        .loadModel("spaceobject/station/platform/Towers.mesh.xml");
    Material mat_wall = new Material(assetManager,
        "Common/MatDefs/Light/Lighting.j3md");
    mat_wall.setTexture("DiffuseMap", assetManager
        .loadTexture("spaceobject/station/platform/city2.jpg"));
    mat_wall.setTexture("GlowMap", assetManager
        .loadTexture("spaceobject/station/platform/city2_glow.jpg"));
    wall.setMaterial(mat_wall);
    ship.attachChild(wall);

    // Spatial flight =
    // assetManager.loadModel("spaceobject/station/cube/Flight.mesh.xml");
    // flight.setMaterial(mat_wall);
    // ship.attachChild(flight);
    // Spatial cube =
    // assetManager.loadModel("ship/smallCarrier/Hull.mesh.xml");
    // Material mat_asteroid = new Material(assetManager,
    // "Common/MatDefs/Misc/Unshaded.j3md");
    // mat_asteroid.setTexture("ColorMap",
    // assetManager.loadTexture("spaceobject/station/station.png"));
    // cube.setMaterial(mat_asteroid);
    // ship.attachChild(cube);
    // ship.attachChild(assetManager.loadModel("spaceobject/station/Sphere.mesh.xml"));
    // ship.attachChild(assetManager.loadModel("ship/smallCarrier/Window.mesh.xml"));
    // ship.attachChild(assetManager.loadModel("ship/smallCarrier/WingGun.mesh.xml"));
    // ship.attachChild(assetManager.loadModel("ship/smallCarrier/Cargo.mesh.xml"));
    // ship.scale(0.1f);
    // ship.setLocalTranslation(0.3f, 0.1f, 0f);
    rootNode.attachChild(ship);

    // Light
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
    rootNode.addLight(sun);
  }

  public static void main(String[] args) {
    new TestModelLoading().start();
  }

}
TOP

Related Classes of net.cis.client.game.TestModelLoading

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.