private void displayPlayersPositions() {
    Map<Vector3f, Integer> playerPositions = gm.getMapManager().getBoard().getPlayerPositions();

    Iterator it = playerPositions.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry pairs = (Map.Entry) it.next();
      Vector3f pos = (Vector3f) pairs.getKey();
      Integer number = (Integer) pairs.getValue();

      Box b = new Box(Vector3f.ZERO, 2.0f, 1.0f, 2.0f);
      Geometry geom = new Geometry("Box", b);
      Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
      mat.setColor("Color", ColorRGBA.randomColor());

      geom.setMaterial(mat);
      geom.setLocalTranslation(pos.x, 0, pos.z);

      String geomName = "PLAYERMARKER";
      geom.setName(geomName);
      geom.setUserData(geomName, pos);

      playerNodes.attachChild(geom);

      displayLocationName(number.toString(), new Vector3f(pos.x, 1, pos.z));
    }
  }
Example #2
0
  @Override
  public void simpleInitApp() {
    // add a random cube
    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.randomColor());
    geom.setMaterial(mat);
    geom.move(
        (FastMath.nextRandomFloat() * 10) - 5,
        (FastMath.nextRandomFloat() * 10) - 5,
        (FastMath.nextRandomFloat() * -10));
    rootNode.attachChild(geom);

    // add saved cubes
    String userHome = System.getProperty("user.home");
    BinaryImporter importer = BinaryImporter.getInstance();
    importer.setAssetManager(assetManager);
    try {
      File file = new File(userHome + "/mycoolgame/savedgame.j3o");
      Node sceneNode = (Node) importer.load(file);
      sceneNode.setName("My restored node");
      rootNode.attachChild(sceneNode);
      Logger.getLogger(SaveAndLoad.class.getName()).log(Level.INFO, "Success: Loaded saved node.");
    } catch (IOException ex) {
      Logger.getLogger(SaveAndLoad.class.getName())
          .log(Level.INFO, "Warning: Could not load saved node.", ex);
    }
  }
Example #3
0
 /** A cube object for target practice */
 protected Geometry makeCube(String name, float x, float y, float z) {
   Box box = new Box(new Vector3f(x, y, z), 1, 1, 1);
   Geometry cube = new Geometry(name, box);
   Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
   mat1.setColor("Color", ColorRGBA.randomColor());
   cube.setMaterial(mat1);
   return cube;
 }
Example #4
0
  Line(AssetManager assetmanager_) {
    assetmanager = assetmanager_;

    Mesh mesh = new Mesh();
    mesh.setMode(Mesh.Mode.Lines);
    mesh.setBuffer(VertexBuffer.Type.Position, 3, new float[] {0, 0, 0, 0, 0, 0});
    mesh.setBuffer(VertexBuffer.Type.Index, 2, new short[] {0, 1});

    // Box b = new Box(Vector3f.ZERO, 1, 1, 1);
    geom = new Geometry("Box", mesh);
    Material mat = new Material(assetmanager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.randomColor());
    geom.setMaterial(mat);

    geom.getMesh().getBuffer(Type.Position).setUpdateNeeded();
    // geom.getMesh().getBuffer(Type.TexCoord).setUpdateNeeded();
    geom.getMesh().getBuffer(Type.Index).setUpdateNeeded();

    geom.getMesh().updateBound();
    geom.getMesh().updateCounts();
    geom.updateModelBound();
  }