Package org.pollux3d.map

Source Code of org.pollux3d.map.Ship

package org.pollux3d.map;

import org.pollux3d.cam.CamTarget;
import org.pollux3d.core.Pollux;
import org.pollux3d.menu.CircleMarker;
import org.pollux3d.menu.Markable;

import com.jme3.asset.AssetManager;
import com.jme3.math.FastMath;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

public class Ship extends MapEntity implements CamTarget, Markable{
 
  private AssetManager assetManager;
  private Node mesh;
  private CircleMarker marker;

  public Ship(String name, String modelPath) {
    super(name);
    assetManager = Pollux.get().getAssetManager();
    mesh = (Node) assetManager.loadModel(modelPath);
    mesh.rotate(0, FastMath.PI, 0);
    this.attachChild(mesh);
    marker = new CircleMarker(8);
    marker.hideMark();
    this.attachChild(marker);
    registerGeometries();
  }

  public float getZoomDistance() {
    return 50;
  }

  public Spatial getTarget() {
    return this;
  }

  public void registerGeometries() {
    for (Spatial s : mesh.getChildren()) {
      if (s instanceof Geometry) {
        Geometry g = (Geometry) s;
        Pollux.get().getGeometryManager().registerGeometry(g, this);
      }
    }
  }

  public void hideMark() {
    marker.hideMark();
  }

  public void showMark() {
    marker.showMark();
  }

}
TOP

Related Classes of org.pollux3d.map.Ship

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.