Package org.pollux3d.state

Source Code of org.pollux3d.state.MapState

package org.pollux3d.state;

import java.util.ArrayList;
import java.util.List;

import org.pollux3d.cam.CamTarget;
import org.pollux3d.core.Pollux;
import org.pollux3d.map.MapEntity;
import org.pollux3d.map.Planet;
import org.pollux3d.map.Ship;
import org.pollux3d.map.Sun;

import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.collision.CollisionResults;
import com.jme3.light.AmbientLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Ray;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;

public class MapState extends AbstractAppState implements Map {
  private Node mapNode = new Node("Map Node");
  private List<MapEntity> entities = new ArrayList<MapEntity>();
  private Planet test;
 
  public Node getMapNode() {
    return mapNode;
  }
 
  public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
   
    test = new Planet(app.getAssetManager(), "Earth", "Textures/Planets/Earth/Earth.jpg", "Textures/Planets/Clouds/Cloud1.jpg", 60, new Vector3f(600, 0, 0), true, null);
    mapNode.attachChild(test);
   
    Planet test2 = new Planet(app.getAssetManager(), "Uriel", "Textures/Planets/Uriel/Uriel.jpg", null, 60, new Vector3f(0, 0, 600), false, null);
    mapNode.attachChild(test2);
   
    Planet test3 = new Planet(app.getAssetManager(), "Dominion", "Textures/Planets/Dominion/Dominion.jpg", null, 60, new Vector3f(-600, 0, 0), true, new Vector3f(0.4f, 0.6f, 0.7f));
    mapNode.attachChild(test3);
   
   
    /*
    Planet perun = new Planet("Perun", "perun2.jpg", 60);
    perun.setPosition(600, 100, 0);
    addEntity(perun);
   
    Planet dominion = new Planet("dominion", "dominion.jpg", 60);
    dominion.setPosition(-800, 300, -1000);
    addEntity(dominion);
   
    Planet lucifersurface = new Planet("lucifersurface", "lucifersurface.jpg", 60);
    lucifersurface.setPosition(0, -100, 1400);
    addEntity(lucifersurface);
   
    Planet seraphius = new Planet("seraphius", "seraphius.jpg", 60);
    seraphius.setPosition(1800, 0, 1200);
    addEntity(seraphius);
   
    Planet uriel = new Planet("uriel", "uriel.jpg", 60);
    uriel.setPosition(3000, -200, -1200);
    addEntity(uriel);
    */
   
    Sun sung = new Sun("Sun");
    sung.setPosition(0, 0, 0);
    mapNode.addLight(sung.getLight());
    Pollux.get().getStateManager().getPlanetAnimation().setSunLocation(sung.getLocalTranslation());
   
    addEntity(sung);
   
   
    //ship = new Ship("Falcon", "Models/Falcon/Body.mesh.xml");
    //addEntity(ship);
   
   
   
    //addEntity(new RoidField("Roids", "Models/RoidField/Roid.mesh.xml"));
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.5f));
    mapNode.addLight(al);
   
   
    /*
    DirectionalLight sun = new DirectionalLight();
      sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());
      sun.setColor(ColorRGBA.White);
      mapNode.addLight(sun);
      */
     
  }
 
  public CamTarget getDefaultTarget() {
    return test;
  }
 
  private void addEntity(MapEntity entity) {
    entities.add(entity);
    mapNode.attachChild(entity);
  }
 
  public CollisionResults getCollisions(Ray ray) {
    CollisionResults results = new CollisionResults();
    mapNode.collideWith(ray, results);
    return results;
  }
}
TOP

Related Classes of org.pollux3d.state.MapState

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.