// Path: core/src/com/github/fauu/helix/datum/Tile.java
// public class Tile {
// 
//   private TilePermission permissions;
// 
//   private TileAreaPassage areaPassage;
// 
//   public Tile() {
//     setPermissions(TilePermission.LEVEL0);
//   }
// 
//   public TilePermission getPermissions() {
//     return permissions;
//   }
// 
//   public void setPermissions(TilePermission permissions) {
//     this.permissions = permissions;
//   }
// 
//   public TileAreaPassage getAreaPassage() {
//     return areaPassage;
//   }
// 
//   public void setAreaPassage(TileAreaPassage passage) {
//     areaPassage = passage;
//   }
// 
//   public static Tile get(Tile[][] tiles, IntVector2 coords) {
//     return tiles[coords.y][coords.x];
//   }
// 
// }
// 
// Path: core/src/com/github/fauu/helix/displayable/ModelDisplayable.java
// public abstract class ModelDisplayable extends Displayable
//                                        implements RenderableProvider {
// 
//   protected ModelInstance instance;
// 
//   protected AnimationController animationController;
// 
//   public AnimationController getAnimationController() {
//     return animationController;
//   }
// 
//   public boolean animateIfAnimationExists(String id) {
//     for (Animation animation : instance.animations) {
//       if (animation.id.equalsIgnoreCase(id)) {
//         animationController.setAnimation(id);
// 
//         return true;
//       }
//     }
// 
//     return false;
//   }
// 
//   public void updateTranslation(Vector3 translation) {
//     instance.transform.setToTranslation(translation);
//   }
// 
//   public void updateOpacity(float opacity) {
//     for (Material material : instance.materials) {
//       BlendingAttribute ba
//           = (BlendingAttribute) material.get(BlendingAttribute.Type);
// 
//       ba.opacity = opacity;
//     }
//   }
// 
// }


import java.util.Map;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.Renderable;
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute;
import com.badlogic.gdx.graphics.g3d.utils.MeshBuilder;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool;
import com.github.fauu.helix.datum.Tile;
import com.github.fauu.helix.displayable.ModelDisplayable;
import java.util.HashMap;
/*
 * Copyright (C) 2014-2016 Helix Engine Developers
 * (http://github.com/fauu/HelixEngine)
 *
 * This software is licensed under the GNU General Public License
 * (version 3 or later). See the COPYING file in this distribution.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this software. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Piotr Grabowski <fau999@gmail.com>
 */

package com.github.fauu.helix.editor.displayable;



public class TilePermissionsGridDisplayable extends ModelDisplayable {

  private static final float Z_OFFSET = -0.02f;

  private TextureAtlas atlas;

  private ModelInstance instance;

  public TilePermissionsGridDisplayable(Tile[][] tiles, TextureAtlas atlas) {
    this.atlas = atlas;

    MeshBuilder meshBuilder = new MeshBuilder();

    meshBuilder.begin(VertexAttributes.Usage.Position |
                      VertexAttributes.Usage.TextureCoordinates,
                      GL20.GL_TRIANGLES);

    for (int y = 0; y < tiles.length; y++) {
      for (int x = 0; x < tiles[y].length; x++) {
        // TODO: Cache regions
        meshBuilder.setUVRange(
            atlas.findRegion(tiles[y][x].getPermissions().name()));

        meshBuilder.rect(x,     y,     0,
                         x + 1, y,     0,
// Path: core/src/com/github/fauu/helix/datum/Tile.java
// public class Tile {
// 
//   private TilePermission permissions;
// 
//   private TileAreaPassage areaPassage;
// 
//   public Tile() {
//     setPermissions(TilePermission.LEVEL0);
//   }
// 
//   public TilePermission getPermissions() {
//     return permissions;
//   }
// 
//   public void setPermissions(TilePermission permissions) {
//     this.permissions = permissions;
//   }
// 
//   public TileAreaPassage getAreaPassage() {
//     return areaPassage;
//   }
// 
//   public void setAreaPassage(TileAreaPassage passage) {
//     areaPassage = passage;
//   }
// 
//   public static Tile get(Tile[][] tiles, IntVector2 coords) {
//     return tiles[coords.y][coords.x];
//   }
// 
// }
// 
// Path: core/src/com/github/fauu/helix/displayable/ModelDisplayable.java
// public abstract class ModelDisplayable extends Displayable
//                                        implements RenderableProvider {
// 
//   protected ModelInstance instance;
// 
//   protected AnimationController animationController;
// 
//   public AnimationController getAnimationController() {
//     return animationController;
//   }
// 
//   public boolean animateIfAnimationExists(String id) {
//     for (Animation animation : instance.animations) {
//       if (animation.id.equalsIgnoreCase(id)) {
//         animationController.setAnimation(id);
// 
//         return true;
//       }
//     }
// 
//     return false;
//   }
// 
//   public void updateTranslation(Vector3 translation) {
//     instance.transform.setToTranslation(translation);
//   }
// 
//   public void updateOpacity(float opacity) {
//     for (Material material : instance.materials) {
//       BlendingAttribute ba
//           = (BlendingAttribute) material.get(BlendingAttribute.Type);
// 
//       ba.opacity = opacity;
//     }
//   }
// 
// }


// Path: editor/src/com/github/fauu/helix/editor/displayable/TilePermissionsGridDisplayable.java
import java.util.Map;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.ModelInstance;
import com.badlogic.gdx.graphics.g3d.Renderable;
import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute;
import com.badlogic.gdx.graphics.g3d.utils.MeshBuilder;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool;
import com.github.fauu.helix.datum.Tile;
import com.github.fauu.helix.displayable.ModelDisplayable;
import java.util.HashMap;

/*
 * Copyright (C) 2014-2016 Helix Engine Developers
 * (http://github.com/fauu/HelixEngine)
 *
 * This software is licensed under the GNU General Public License
 * (version 3 or later). See the COPYING file in this distribution.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this software. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Piotr Grabowski <fau999@gmail.com>
 */

package com.github.fauu.helix.editor.displayable;



public class TilePermissionsGridDisplayable extends ModelDisplayable {

  private static final float Z_OFFSET = -0.02f;

  private TextureAtlas atlas;

  private ModelInstance instance;

  public TilePermissionsGridDisplayable(Tile[][] tiles, TextureAtlas atlas) {
    this.atlas = atlas;

    MeshBuilder meshBuilder = new MeshBuilder();

    meshBuilder.begin(VertexAttributes.Usage.Position |
                      VertexAttributes.Usage.TextureCoordinates,
                      GL20.GL_TRIANGLES);

    for (int y = 0; y < tiles.length; y++) {
      for (int x = 0; x < tiles[y].length; x++) {
        // TODO: Cache regions
        meshBuilder.setUVRange(
            atlas.findRegion(tiles[y][x].getPermissions().name()));

        meshBuilder.rect(x,     y,     0,
                         x + 1, y,     0,
                         x + 1, y + 1, 0,