예제 #1
0
 public boolean isInOctreeLeaf(Octant leaf) {
   //        float radius = node.size() / 2f;
   if (Math.abs(node.x() - leaf.getPosX()) > (leaf.getSize() / 2)
       || Math.abs(node.y() - leaf.getPosY()) > (leaf.getSize() / 2)
       || Math.abs(node.z() - leaf.getPosZ()) > (leaf.getSize() / 2)) {
     return false;
   }
   return true;
 }
예제 #2
0
  public int octreePosition(float centerX, float centerY, float centerZ, float size) {
    // float radius = obj.getRadius();
    int index = 0;

    if (node.y() < centerY) {
      index += 4;
    }
    if (node.z() > centerZ) {
      index += 2;
    }
    if (node.x() < centerX) {
      index += 1;
    }

    return index;
  }
예제 #3
0
 private void clampPosition(NodeModel nodeModel) {
   // Clamp Hack to avoid nodes to be outside octree
   float quantum = size / 2;
   Node node = nodeModel.getNode();
   float x = node.x();
   float y = node.y();
   float z = node.z();
   if (x > root.posX + quantum) {
     node.setX(root.posX + quantum);
   } else if (x < root.posX - quantum) {
     node.setX(root.posX - quantum);
   }
   if (y > root.posY + quantum) {
     node.setY(root.posY + quantum);
   } else if (y < root.posY - quantum) {
     node.setY(root.posY - quantum);
   }
   if (z > root.posZ + quantum) {
     node.setZ(root.posZ + quantum);
   } else if (z < root.posZ - quantum) {
     node.setZ(root.posZ - quantum);
   }
 }