コード例 #1
0
  void traverseSwitchChild(
      int child,
      HashKey key,
      int index,
      SwitchRetained switchRoot,
      boolean init,
      boolean swChanged,
      boolean switchOn,
      int switchLevel,
      ArrayList<SwitchState> updateList) {

    SwitchRetained sw;
    LinkRetained ln;
    Object obj;
    int i, j, k;

    ArrayList<NodeRetained> childSwitchLinks = childrenSwitchLinks.get(child);
    for (i = 0; i < childSwitchLinks.size(); i++) {
      obj = childSwitchLinks.get(i);

      if (obj instanceof SwitchRetained) {
        sw = (SwitchRetained) obj;
        for (j = 0; j < sw.children.size(); j++) {
          sw.traverseSwitchChild(
              j, key, index, switchRoot, init, swChanged, switchOn, switchLevel, updateList);
        }
      } else { // LinkRetained
        ln = (LinkRetained) obj;
        switchKey.set(key);
        switchKey.append(LinkRetained.plus).append(ln.nodeId);

        if (ln.sharedGroup.localToVworldKeys != null) {

          j =
              switchKey.equals(
                  ln.sharedGroup.localToVworldKeys, 0, ln.sharedGroup.localToVworldKeys.length);
          if (j < 0) {
            System.err.println("SharedGroupRetained : Can't find hashKey");
          }

          if (j < ln.sharedGroup.localToVworldKeys.length) {
            for (k = 0; k < ln.sharedGroup.children.size(); k++) {
              ln.sharedGroup.traverseSwitchChild(
                  k,
                  ln.sharedGroup.localToVworldKeys[j],
                  j,
                  switchRoot,
                  init,
                  swChanged,
                  switchOn,
                  switchLevel,
                  updateList);
            }
          }
        }
      }
    }
  }
コード例 #2
0
  void updateChildLocalToVworld(
      HashKey key,
      int index,
      ArrayList<TransformGroupRetained> dirtyTransformGroups,
      ArrayList keySet,
      UpdateTargets targets,
      ArrayList blUsers) {

    LinkRetained ln;
    TransformGroupRetained tg;
    int i, j;
    Object obj;

    CachedTargets ct = j3dCTs[index];
    if (ct != null) {
      targets.addCachedTargets(ct);
      if (ct.targetArr[Targets.BLN_TARGETS] != null) {
        gatherBlUsers(blUsers, ct.targetArr[Targets.BLN_TARGETS]);
      }
    }

    synchronized (childTransformLinks) {
      for (i = 0; i < childTransformLinks.size(); i++) {
        obj = childTransformLinks.get(i);

        if (obj instanceof TransformGroupRetained) {
          tg = (TransformGroupRetained) obj;
          tg.updateChildLocalToVworld(
              tg.localToVworldKeys[index], index, dirtyTransformGroups, keySet, targets, blUsers);

        } else { // LinkRetained
          ln = (LinkRetained) obj;
          currentKey.set(key);
          currentKey.append(LinkRetained.plus).append(ln.nodeId);
          if (ln.sharedGroup.localToVworldKeys != null) {
            j =
                currentKey.equals(
                    ln.sharedGroup.localToVworldKeys, 0, ln.sharedGroup.localToVworldKeys.length);
            if (j < 0) {
              System.err.println("SharedGroupRetained : Can't find hashKey");
            }

            if (j < ln.sharedGroup.localToVworldKeys.length) {
              ln.sharedGroup.updateChildLocalToVworld(
                  ln.sharedGroup.localToVworldKeys[j],
                  j,
                  dirtyTransformGroups,
                  keySet,
                  targets,
                  blUsers);
            }
          }
        }
      }
    }
  }
コード例 #3
0
  // for shared case
  void updateChildLocalToVworld(
      HashKey key,
      int index,
      ArrayList dirtyTransformGroups,
      ArrayList keySet,
      UpdateTargets targets,
      ArrayList blUsers) {

    int i, j;
    Object obj;
    Transform3D lToVw, childLToVw;
    TransformGroupRetained tg;
    LinkRetained ln;
    CachedTargets ct;

    synchronized (this) { // sync with setLive/clearLive
      if (localToVworld != null) {
        perPathData[index].markedDirty = false;
        // update immediate child's localToVworld

        if (perPathData[index].switchState.currentSwitchOn) {
          lToVw = getCurrentLocalToVworld(index);
          childLToVw = getUpdateChildLocalToVworld(index);
          childLToVw.mul(lToVw, currentTransform);
          dirtyTransformGroups.add(this);
          keySet.add(key);
          ct = j3dCTs[index];
          if (ct != null) {
            targets.addCachedTargets(ct);
            if (ct.targetArr[Targets.BLN_TARGETS] != null) {
              gatherBlUsers(blUsers, ct.targetArr[Targets.BLN_TARGETS]);
            }
          }
        } else {
          perPathData[index].switchDirty = true;
          // System.err.println("tg.updateChild skip");
        }

        // update child's localToVworld of its children
        // transformLink may contain link nodes
        synchronized (childTransformLinks) {
          for (i = 0; i < childTransformLinks.size(); i++) {
            obj = childTransformLinks.get(i);

            if (obj instanceof TransformGroupRetained) {
              tg = (TransformGroupRetained) obj;
              tg.updateChildLocalToVworld(
                  tg.localToVworldKeys[index],
                  index,
                  dirtyTransformGroups,
                  keySet,
                  targets,
                  blUsers);
            } else { // LinkRetained
              ln = (LinkRetained) obj;
              currentKey.set(localToVworldKeys[index]);
              currentKey.append(LinkRetained.plus).append(ln.nodeId);
              if ((ln.sharedGroup != null) && (ln.sharedGroup.localToVworldKeys != null)) {
                j =
                    currentKey.equals(
                        ln.sharedGroup.localToVworldKeys,
                        0,
                        ln.sharedGroup.localToVworldKeys.length);
                if (j < 0) {
                  System.err.println("TransformGroupRetained : Can't find hashKey");
                }

                if (j < ln.sharedGroup.localToVworldKeys.length) {
                  ln.sharedGroup.updateChildLocalToVworld(
                      ln.sharedGroup.localToVworldKeys[j],
                      j,
                      dirtyTransformGroups,
                      keySet,
                      targets,
                      blUsers);
                }
              }
            }
          }
        }
      }
    }
  }