Пример #1
0
  /**
   * Handle notification that an ExternProto has resolved.
   *
   * @param index The field index that got loaded
   * @param node The owner of the node
   */
  public synchronized void notifyExternProtoLoaded(int index, VRMLNodeType node) {

    if (!(node instanceof VRMLChildNodeType) && !(node instanceof VRMLProtoInstance))
      throw new InvalidFieldValueException(BAD_PROTO_MSG);

    // TODO: This does not totally guard against notifications during setupFinished as
    // the base class sets inSetup finish true before J3D structures are complete

    if (inSetup) return;

    OGLVRMLNode kid = (OGLVRMLNode) node;

    // Make sure the child is finished first.
    kid.setupFinished();
    Node ogl_node = (Node) kid.getSceneGraphObject();

    oglChildMap.put(node, ogl_node);

    if (ogl_node != null) {
      if (implGroup.isLive()) {
        if (addedChildren == null) addedChildren = new LinkedList();

        addedChildren.add(ogl_node);
        stateManager.addEndOfThisFrameListener(this);
      } else implGroup.addChild(ogl_node);
    }
  }
Пример #2
0
  /**
   * Add a single child node to the list of available children. This auto matically deals with
   * DEF/USE and adds links and branchgroups where appropriate. When nodes are null, we do not add
   * them to the GL representation, only to the vfChildren list.
   *
   * @param node The node to view
   * @throws InvalidFieldValueException This is a bindable node shared
   */
  protected void addChildNode(VRMLNodeType node) throws InvalidFieldValueException {

    super.addChildNode(node);

    OGLVRMLNode n = (OGLVRMLNode) node;

    if (!inSetup) {
      Node ogl_node = (Node) n.getSceneGraphObject();
      oglChildMap.put(node, ogl_node);

      if (implGroup.isLive()) {
        addedChildren.add(ogl_node);
        implGroup.boundsChanged(this);
      } else implGroup.addChild(ogl_node);
    }

    // Finally check for sensors that we need to deal with.
    VRMLPointingDeviceSensorNodeType sensor = null;

    if (node instanceof VRMLPointingDeviceSensorNodeType)
      sensor = (VRMLPointingDeviceSensorNodeType) node;
    else if (node instanceof VRMLProtoInstance) {
      Object impl = ((VRMLProtoInstance) node).getImplementationNode();

      if (impl instanceof VRMLPointingDeviceSensorNodeType)
        sensor = (VRMLPointingDeviceSensorNodeType) impl;
    }

    if (sensor != null) {
      // So we have a valid sensor. Let's now add it to the
      // system. We only add the sensor itself, even if wrapped in a
      // proto. This is so that the processing of sensors doesn't need
      // to stuff around with the details of protos. As far as the proto
      // node is concerned it just wants the full events, not the
      // restricted view the outside of the proto would give.
      if (inSetup) sensorList.add(sensor);
      else {
        OGLUserData data = (OGLUserData) implGroup.getUserData();

        if (data == null) {
          data = new OGLUserData();
          implGroup.setUserData(data);
        }

        if (data.sensors == null) {
          data.sensors = new VRMLPointingDeviceSensorNodeType[1];
          data.sensors[0] = sensor;
        } else {
          int size = data.sensors.length;
          VRMLPointingDeviceSensorNodeType[] tmp = new VRMLPointingDeviceSensorNodeType[size + 1];

          System.arraycopy(data.sensors, 0, tmp, 0, size);
          tmp[size] = sensor;
          data.sensors = tmp;
        }
      }
    }
  }
Пример #3
0
  /**
   * Notification that the construction phase of this node has finished. If the node would like to
   * do any internal processing, such as setting up geometry, then go for it now.
   */
  public void setupFinished() {
    if (!inSetup) return;

    super.setupFinished();

    if (isStatic && shareCount == 0) {
      oglImplGroup = implGroup;
    } else {
      oglImplGroup = new SharedGroup();
      oglImplGroup.addChild(implGroup);
    }

    // Check what sensors we have available and register those with the
    // user data information.
    if (!isStatic && (sensorList.size() != 0)) {
      OGLUserData data = new OGLUserData();
      implGroup.setUserData(data);

      data.sensors = new VRMLPointingDeviceSensorNodeType[sensorList.size()];

      sensorList.toArray(data.sensors);
    }

    sensorList = null;

    oglChildMap = new HashMap();
    oglChildList = new LinkedList();

    for (int i = 0; i < childCount; i++) {
      OGLVRMLNode node = (OGLVRMLNode) vfChildren.get(i);

      Node ogl_node = (Node) node.getSceneGraphObject();
      implGroup.addChild(ogl_node);

      oglChildList.add(ogl_node);
      oglChildMap.put(node, ogl_node);
    }

    if (!isStatic) {
      removedChildren = new LinkedList();
      addedChildren = new LinkedList();
    }

    // Need to fix this, not handling the list being different size to th
    // real values.
    System.out.println("OGLCADLayer not handling numVisible correctly");
    implGroup.setMask(vfVisible);
  }