Package Hexel.math

Examples of Hexel.math.Vector3i


  public void render(GL2 gl) {

    Vector3d dir = getDirectionLooking();
    dir.times(10);

    Vector3i closestBlock = this.thingBridge
        .getClosestNonEmptyBlockOnVector(
            new Vector3d(getCameraX(), getCameraY(), getCameraZ()), dir);

    Vector3i closestEmptyBlock = this.thingBridge
        .getClosestEmptyBlockOnVector(new Vector3d(getCameraX(),
            getCameraY(), getCameraZ()), dir);

    if (closestBlock != null) {
      Face f = HighlightBlockFace.getBetweenFace(closestBlock,
View Full Code Here


    if (this.createBlock) {
      lastDeleteBlock = this.deleteBlock;
      this.createBlock = false;
      if (!this.inventory.hasBlock(this.blockToPlace))
        return null;
      Vector3i closestBlock = this.thingBridge
          .getClosestEmptyBlockOnVector(
              new Vector3d(getCameraX(), getCameraY(),
                  getCameraZ()), dir);
      if (closestBlock != null) {
        AddBlock ab = new AddBlock();
        ab.x = closestBlock.x;
        ab.y = closestBlock.y;
        ab.z = closestBlock.z;
        ab.block = getBlockToPlace();
        return ab;
      } else {
        return null;
      }
    } else if (this.deleteBlock) {
      boolean justClickedDelete = this.deleteBlock != lastDeleteBlock;
      lastDeleteBlock = this.deleteBlock;
      this.deleteBlock = false;
      ArrayList<Vector3i> blocksAttacking = this.thingBridge.getNonEmptyBlocksOnVector(
          new Vector3d(getCameraX(), getCameraY(), getCameraZ()), dir);
      Set<Thing> things = this.thingBridge.getIntersectingThings(blocksAttacking);
      things.remove(this);
      if (things.size() > 0){
        if (justClickedDelete){
          for (Thing thing : things){
            if (thing instanceof Zombie){
              Long lastAttackTime = lastAttack.get(thing);
              lastAttack.put(thing, System.currentTimeMillis());
              Zombie zombie = (Zombie)thing;
              if (lastAttackTime == null || System.currentTimeMillis() - lastAttackTime > 100){
                zombie.health -= .25;
                zombie.hurt = 10;
                break;
              }
            }
            else if (thing instanceof Deer){
              Long lastAttackTime = lastAttack.get(thing);
              lastAttack.put(thing, System.currentTimeMillis());
              Deer deer = (Deer)thing;
              if (lastAttackTime == null || System.currentTimeMillis() - lastAttackTime > 100){
                deer.health -= .25;
                deer.lastHurt = deer.step;
                if (deer.health <= 0)
                  this.hunger = 1;
                break;
              }
            }
          }
        }
      }
      else {
        Vector3i closestBlock = blocksAttacking.get(blocksAttacking.size()-1);
        Vector3i tmp3i = new Vector3i();
        Block b = thingBridge.engine.chunks.getBlock(closestBlock.x, closestBlock.y, closestBlock.z, tmp3i, (Chunk)null);
        if (!(b instanceof BlockEmpty || b instanceof BlockWater)){
          if (closestBlock != null) {
            RemoveBlock ab = new RemoveBlock();
            ab.x = closestBlock.x;
View Full Code Here

  public boolean inWater(Volumetric v) {
    return this.thingTools.collidesWater(v, zeroOffset, this.fixOffsetTmps);
  }

  public boolean isUnderwater(double x, double y, double z) {
    Vector3i tmp3i = new Vector3i();
    Vector2d tmp2d = new Vector2d();
    return this.thingTools.collidesWater(x, y, z, tmp2d, tmp3i);
  }
View Full Code Here

    Vector3d step = Vector3d.Sub(t, v);
    step.unit();
    step.times(STEP_SIZE);

    Vector2d tmp2d = new Vector2d();
    Vector3i tmp3i = new Vector3i();

    Vector3i blockPos = new Vector3i();

    while (v.mag() < t.mag()) {
      v.add(step);

      HexGeometry.cartesianToBlock(v.x + offset.x, v.y + offset.y, v.z + offset.z, tmp2d, blockPos);

      Block b = this.chunks.getBlock(blockPos.x, blockPos.y, blockPos.z, tmp3i, (Chunk)null);
      blocks.add(new Vector3i(blockPos));
      if (!(b instanceof BlockEmpty || b instanceof BlockWater)) {
        break;
      }
    }
    return blocks;
View Full Code Here

    Vector3d step = Vector3d.Sub(t, v);
    step.unit();
    step.times(STEP_SIZE);

    Vector2d tmp2d = new Vector2d();
    Vector3i tmp3i = new Vector3i();

    Vector3i blockPos = new Vector3i();

    while (v.mag() < t.mag()) {
      v.add(step);

      HexGeometry.cartesianToBlock(v.x + offset.x, v.y + offset.y, v.z
View Full Code Here

    Vector3d v = new Vector3d();
    Vector3d step = Vector3d.Sub(t, v);
    step.unit();
    step.times(STEP_SIZE);

    Vector3i farthestEmpty = new Vector3i();
    Vector3i blockPos = new Vector3i();

    Vector2d tmp2d = new Vector2d();
    Vector3i tmp3i = new Vector3i();

    while (v.mag() < t.mag()) {
      v.add(step);
      HexGeometry.cartesianToBlock(v.x + offset.x, v.y + offset.y, v.z
          + offset.z, tmp2d, blockPos);
View Full Code Here

  public void addThing(Thing thing) {
    this.thingsToAdd.add(thing);
  }

  public void step(double fps) {
    Vector3i tmp = Resources.vector3iResourcePool.aquire();
    Vector3d tmp3d = Resources.vector3dResourcePool.aquire();
    Vector2i tmp2 = Resources.vector2iResourcePool.aquire();
    synchronized (this.things){
      thingsToRemove.clear();
      for (Thing t : this.thingsToAdd){
View Full Code Here

    this.engine = engine;
    this.chunks = chunks;
  }
 
  public ArrayList<Vector3i> getBlocksIntersectingThing(final Cuboid c, final FixOffsetTmps fixOffsetTmps){
    Vector3i checkBlockPos = new Vector3i();
    Vector2d tmp = new Vector2d();
    HexGeometry.cartesianToBlock(c.getX(), c.getY(), c.getZ(), tmp, checkBlockPos);
    final ArrayList<Vector3i> blocks = new ArrayList<Vector3i>();
    BlockTools.pointFloodSearch(checkBlockPos, new PointFloodSearchMatcher(){
      @Override
      public boolean matches(Vector3i p) {
        Vector3d partialFix = Resources.vector3dResourcePool.aquire();
        partialFix.x = 0;
        partialFix.y = 0;
        partialFix.z = 0;
        collides(c, zeroOffset, p.x, p.y, p.z, partialFix, fixOffsetTmps.collidesTmps);
        if (partialFix.x != 0 || partialFix.y != 0 || partialFix.z != 0){
          blocks.add(new Vector3i(p));
          return true;
        }
        else {
          Resources.vector3dResourcePool.recycle(partialFix);
        }
View Full Code Here

      return false;
    }
  }

  public boolean collidesWater(double x, double y, double z, Vector2d tmp2d, Vector3i tmp3i) {
    Vector3i blockPos = new Vector3i();
    HexGeometry.cartesianToBlock(x, y, z, tmp2d, blockPos);
    Block b = this.chunks.getBlock(blockPos.x, blockPos.y, blockPos.z, tmp3i, (Chunk)null);
    return b instanceof BlockWater;
  }
View Full Code Here

      boolean considerNeighbors, final CheckCollidableBlock checkCollidableBlock, final FixOffsetTmps tmps) {

    tmps.toCheck.clear();
    tmps.toFixBlockSet.clear();

    Vector3i checkBlockPos = tmps.tmp3i;
    HexGeometry.cartesianToBlock(c.getX(), c.getY(), c.getZ(), tmps.tmp2d, checkBlockPos);
    BlockTools.pointFloodSearch(checkBlockPos, new PointFloodSearchMatcher(){
      @Override
      public boolean matches(Vector3i p) {
        Vector3d partialFix = Resources.vector3dResourcePool.aquire();
View Full Code Here

TOP

Related Classes of Hexel.math.Vector3i

Copyright © 2018 www.massapicom. 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.