コード例 #1
0
  /**
   * collect all nodes
   *
   * @param branch
   */
  private void collectNodes(KNode branch) {
    Camera cam = engine.getCamera();

    Iterator<KNode> nodeIterator = branch.getLeafs().iterator();
    while (nodeIterator.hasNext()) {
      KNode n = nodeIterator.next();

      n.updateMatrix();

      if (n.isVisible()) {
        if (n instanceof VisualNode) {
          if (cam == null || (cam != null && cam.isVisible((VisualNode) n))) {
            visuals.add((VisualNode) n);
          }
        }

        collectNodes(n);
      }
    }
  }
コード例 #2
0
  public void renderScene(GL2 gl, KNode branch) {
    // enter model view matrix
    gl.glMatrixMode(GL2.GL_MODELVIEW);

    if (branch.isVisible() == false) return;

    if (updateNeeded) {
      // collect nodes
      visuals.clear();
      collectNodes(branch);
    }

    // TODO: sort nodes, when transformations changed
    // TODO: split in transparent / opaque

    // render nodes
    for (VisualNode n : visuals) {
      gl.glPushMatrix();
      renderVisualNode(gl, n);
      gl.glPopMatrix();
    }
  }