Android Open Source - block-composer Level Dimensions






From Project

Back to project page block-composer.

License

The source code is released under:

MIT License

If you think the Android project block-composer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package bwr.blockcomposer.gamedata;
// w  w w.  j  a v  a2s .c  o  m
import bwr.blockcomposer.types.IntVector;

public class LevelDimensions {
  
  public final IntVector max = new IntVector();
  public final IntVector min = new IntVector();

  private float diameter = -1f;
  
  public LevelDimensions() {
    max.x = Integer.MIN_VALUE;
    max.y = Integer.MIN_VALUE;
    max.z = Integer.MIN_VALUE;

    min.x = Integer.MAX_VALUE;
    min.y = Integer.MAX_VALUE;
    min.z = Integer.MAX_VALUE;
  }
  
  public void expandFor(IntVector location) {
    if(location.x > max.x) max.x = location.x;
    if(location.y > max.y) max.y = location.y;
    if(location.z > max.z) max.z = location.z;
    if(location.x < min.x) min.x = location.x;
    if(location.y < min.y) min.y = location.y;
    if(location.z < min.z) min.z = location.z;
    
    diameter = -1f; // Reset diameter
  }
  
  public LevelDimensions(IntVector max, IntVector min) {
    this.max.copy(max);
    this.min.copy(min);
  }
  
  public int getSizeX() {
    return max.x-min.x+1;
  }
  
  public int getSizeY() {
    return max.y-min.y+1;
  }
  
  public int getSizeZ() {
    return max.z-min.z+1;
  }
  
  public int getCenterX() {
    return (max.x + min.x)/2;
  }
  
  public int getCenterY() {
    return (max.y + min.y)/2;
  }
  
  public int getCenterZ() {
    return (max.z + min.z)/2;
  }
  
  public float getDiameter() {
    if(diameter < 0) {
      if(diameter < getSizeX()) diameter = getSizeX();
      if(diameter < getSizeY()) diameter = getSizeY();
      if(diameter < getSizeZ()) diameter = getSizeZ();
    }
    return diameter;
  }
  
  public IntVector mapToArrayCoords(IntVector v) {
    IntVector r = v.duplicate();
    
    r.sub(min);
    
    return r;
  }
  
  public boolean isOnLevel(IntVector l) {
      if(l.x > max.x || l.x < min.x || l.y > max.y || l.y < min.y || l.z > max.z || l.z < min.z) return false;
      return true;
  }
}




Java Source Code List

bwr.blockcomposer.AnimationFinishedListener.java
bwr.blockcomposer.BlockComposerActivity.java
bwr.blockcomposer.BlockComposerRenderer.java
bwr.blockcomposer.BlockComposer.java
bwr.blockcomposer.Camera.java
bwr.blockcomposer.GameResources.java
bwr.blockcomposer.OnUpdateAction.java
bwr.blockcomposer.gamedata.Block.java
bwr.blockcomposer.gamedata.GameEntity.java
bwr.blockcomposer.gamedata.GameState.java
bwr.blockcomposer.gamedata.LevelDimensions.java
bwr.blockcomposer.gamedata.LevelMask.java
bwr.blockcomposer.gamedata.LevelMetadata.java
bwr.blockcomposer.gamedata.LevelStore.java
bwr.blockcomposer.gamedata.Level.java
bwr.blockcomposer.gamedata.Move.java
bwr.blockcomposer.gamedata.StaticLevelStore.java
bwr.blockcomposer.gamedata.UserLevelStore.java
bwr.blockcomposer.misc.GLUtility.java
bwr.blockcomposer.misc.Timer.java
bwr.blockcomposer.models.AxisRenderer.java
bwr.blockcomposer.models.Model.java
bwr.blockcomposer.models.SelectBoxRenderer.java
bwr.blockcomposer.modes.EditMode.java
bwr.blockcomposer.modes.GameDialogMode.java
bwr.blockcomposer.modes.GameMode.java
bwr.blockcomposer.modes.LevelImportMode.java
bwr.blockcomposer.modes.LevelSelectMode.java
bwr.blockcomposer.modes.LogoDisplayMode.java
bwr.blockcomposer.modes.ModeController.java
bwr.blockcomposer.modes.Mode.java
bwr.blockcomposer.modes.OverlayMode.java
bwr.blockcomposer.types.FlipRotateFloat.java
bwr.blockcomposer.types.FloatValueVector3.java
bwr.blockcomposer.types.FloatValue.java
bwr.blockcomposer.types.IntVector.java
bwr.blockcomposer.types.RotatingFloat.java
bwr.blockcomposer.ui.TextRenderer.java
bwr.blockcomposer.ui.UIElementPicture.java
bwr.blockcomposer.ui.UIElementText.java
bwr.blockcomposer.ui.UIElement.java