Package Hexel.math

Examples of Hexel.math.Vector3i


    }
    if (step %10 == 0)
      this.jump(4.0);
    if (step % (60) == 0){
      ArrayList<Vector3i> blocksIntersectingThing = thingBridge.thingTools.getBlocksIntersectingThing(this, thingBridge.fixOffsetTmps);
      Vector3i tmp = new Vector3i();
      if (thingBridge.engine.getAmbientLight() > .75){
        for (Vector3i v : blocksIntersectingThing){
          Block b = thingBridge.engine.chunks.getBlock(v.x, v.y, v.z, tmp, (Chunk)null);
          if (b instanceof BlockEmpty){
            BlockEmpty be = (BlockEmpty)b;
View Full Code Here


    this.engine = engine;
    this.blockRules = new BlockRules(engine, new PointInSimRange() {
      @Override
      public boolean pointIsInRange(Vector3i v) {
        for (int i = 0; i < toUpdate.size(); i++){
          Vector3i c = toUpdate.get(i);
          if (c.x*32 <= v.x && c.x*32+32 > v.x &&
              c.y*16 <= v.y && c.y*16+16 > v.y &&
              c.z*32 <= v.z && c.z*32+32 > v.z){
            return true;
          }
View Full Code Here

    for (BlockRule rule : rules) {
      int nextSimStep = rule.run(bx, by, bz, fastMode, b, c, hbc, this.chunks, step, new BlockDeltaAdder(){
        @Override
        public void addBlockDelta(BlockDelta delta){
          Vector3i pos = new Vector3i();
          pos.x = delta.x;
          pos.y = delta.y;
          pos.z = delta.z;
          if (hasBlockDelta(pos)){
            try {
View Full Code Here

  public static void save(Chunk chunk) {
    if (!Hexel.session.save)
      return;
    synchronized (lock) {
      Vector3i p = chunk.getXYZ();
      File dir = new File(Hexel.workingDir, getFolder());
      if (!dir.exists()) {
        dir.mkdirs();
      }
      String path = getPath(p);
View Full Code Here

  public Chunk(int cx, int cy, int cz) {
    this.cx = cx;
    this.cy = cy;
    this.cz = cz;
    this.pos = new Vector3i(cx, cy, cz);
  }
View Full Code Here

    if (runOnStart){
      if (!matcher.matches(start))
        return;
    }
    while (!toMatch.isEmpty()) {
      Vector3i curr = toMatch.poll();
      if (!seen.contains(curr)) {
        seen.add(curr);

        Vector3i[] neighbors = HexGeometry.getAllNeighbors(curr.x);

        for (Vector3i n : neighbors) {
          Vector3i next = new Vector3i();
          next.x = curr.x + n.x;
          next.y = curr.y + n.y;
          next.z = curr.z + n.z;
          if (!seen.contains(next)) {
            if (matcher.matches(next)) {
View Full Code Here

      for (int y = -distanceChunksRange; y <= distanceChunksRange; y++) {
        for (int z = -distanceChunksRange; z <= distanceChunksRange; z++) {
          int ncx = cx + x;
          int ncy = cy + y;
          int ncz = cz + z;
          Vector3i cpos = new Vector3i(ncx, ncy, ncz);
         
          boolean pInRenderRange = false;

          if (x >= -renderedChunksRange && x <= renderedChunksRange){
            if (y >= -renderedChunksRange && y <= renderedChunksRange){
              if (z >= -renderedChunksRange && z <= renderedChunksRange){
                pInRenderRange = true;
                inRenderRange.add(cpos);
                Chunk chunk = this.chunks.getChunk(cpos);
                if (!chunk.needFirstSim && !chunk.fastMode){
                  if (!this.renderedChunks.contains(cpos)) {
                    points.add(cpos);
                    chunk.setDirty(false);
                  } else {
                    if (resetLights || chunk.isDirty()) {
                      chunk.setDirty(false);
                      points.add(cpos);
                    }

                  }
                }
                if (points.size() > 10) {
                  this.renderer.loadChunks(points);
                  this.renderedChunks.addAll(points);
                  points = new ArrayList<Vector3i>();
                }
                if (x >= -simulatedChunksRange && x <= simulatedChunksRange){
                  if (y >= -simulatedChunksRange && y <= simulatedChunksRange){
                    if (z >= -simulatedChunksRange && z <= simulatedChunksRange){
                      inSimRange.add(cpos);
                      this.simulatedChunks.add(cpos);
                    }
                  }
                }
              }
            }
            if (!pInRenderRange){
              inDistRange.add(cpos);
            }
          }
        }
      }
    }
    this.renderer.loadChunks(points);
    this.renderedChunks.addAll(points);

    lastLightLevel = lightLevel;

    HashMap<Vector3i, GLChunk> glChunkTable = this.renderer.getGLChunkTable();
    for (Vector3i p : new HashSet<Vector3i>(glChunkTable.keySet())) {
      if (!inRenderRange.contains(p)) {
        this.renderer.unloadGLChunk(p);
      }
    }

    Iterator<Vector3i> iter = this.renderedChunks.iterator();
    ArrayList<Vector3i> toRemove = new ArrayList<Vector3i>();
    while (iter.hasNext()) {
      Vector3i position = iter.next();
      if (!inRenderRange.contains(position) && !points.contains(position)) {
        toRemove.add(position);
      }
    }
    this.renderedChunks.removeAll(toRemove);

    iter = this.simulatedChunks.iterator();
    toRemove = new ArrayList<Vector3i>();
    while (iter.hasNext()) {
      Vector3i position = iter.next();
      if (!inSimRange.contains(position)) {
        toRemove.add(position);
      }
    }
    this.simulatedChunks.removeAll(toRemove);

    iter = this.distanceChunks.iterator();
    toRemove = new ArrayList<Vector3i>();
    while (iter.hasNext()) {
      Vector3i position = iter.next();
      if (!inDistRange.contains(position)) {
        toRemove.add(position);
      }
    }
    this.distanceChunks.removeAll(toRemove);
View Full Code Here

        Camera camera = Renderer.dbgCamera;
        if (camera != null){
          int x = (int) camera.getCameraX();
          int y = (int) camera.getCameraY();
          Vector2d tmp = new Vector2d();
          Vector3i p = new Vector3i();
          HexGeometry.cartesianToBlock(x, y, 0, tmp, p);
          xshift = p.x;
          yshift = p.y;
        }
        repaint(canvas);
View Full Code Here

  @Override
  public int run(int bx, int by, int bz, final boolean fastMode, Block b, Chunk c,
      HighestBlockChunk hbc, final Chunks chunks, final int step, final BlockDeltaAdder blockDeltaAdder) {
    chunk.contents = c;
    highestBlockChunk.contents = hbc;
    final Vector3i start = new Vector3i(bx, by, bz);
    final int startStepsToSim = chunks.getStepsToSim(bx, by, bz, tmp3i, chunk);

    if (blockDeltaAdder.hasBlockDelta(start))
      return 1;
View Full Code Here

      @Override
      public void run() {
        for (Vector3i point : points) {
          Chunk chunk = ChunkRenderer.this.chunks.getChunk(point);
          GLChunk glChunk = new GLChunk(engine, chunk, ChunkRenderer.this.chunks);
          glChunk.position = new Vector3i(chunk.cx, chunk.cy,
              chunk.cz);
          glChunk.genArrayList();
          ChunkRenderer.this.loadGLChunk(glChunk);
          synchronized (chunksToLoad){
            chunksToLoad -= 1;
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.