Esempio n. 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;
 }
Esempio n. 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;
  }
Esempio n. 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);
   }
 }
Esempio n. 4
0
 public float getX() {
   return node.x();
 }
  public void saveGraph(Graph graph, boolean isFilterGraph) {

    int Counter = 0;
    JsonObject attrJson;

    // clear existing graph
    if (!isFilterGraph) {
      nodesMap.clear();
      edgesMap.clear();
    } else {
      nodesMapFilter.clear();
      edgesMapFilter.clear();
    }

    /*
     * Nodes Iteration
     */
    for (Node node : graph.getNodes()) {
      attrJson = new JsonObject();
      for (String attrKey : node.getAttributeKeys()) {
        attrJson.put(attrKey, node.getAttribute(attrKey));
      }

      attrJson.put("x", node.x());
      attrJson.put("y", node.y());
      attrJson.put("cR", node.r());
      attrJson.put("cG", node.g());
      attrJson.put("cB", node.b());
      attrJson.put("size", node.size());

      if (!isFilterGraph) {
        nodesMap.put(Counter++, attrJson);
      } else {
        nodesMapFilter.put(Counter++, attrJson);
      }
    }

    Counter = 0;

    /*
     * Edges Iteration
     */
    for (Edge edge : graph.getEdges()) {
      attrJson = new JsonObject();
      for (String attrKey : edge.getAttributeKeys()) {
        attrJson.put(attrKey, edge.getAttribute(attrKey));
      }
      attrJson.put("source", edge.getSource().getId());
      attrJson.put("target", edge.getTarget().getId());

      attrJson.put("cR", edge.r());
      attrJson.put("cG", edge.g());
      attrJson.put("cB", edge.b());
      attrJson.put("size", edge.getWeight());
      if (!isFilterGraph) {
        edgesMap.put(Counter++, attrJson);
      } else {
        edgesMapFilter.put(Counter++, attrJson);
      }
    }
  }