Package javax.media.j3d

Examples of javax.media.j3d.BranchGroup


   *    the Event Dispatch Thread. 
   */
  public void loadModel(final Content content,
                        boolean synchronous,
                        ModelObserver modelObserver) {
    BranchGroup modelRoot;
    synchronized (this.loadedModelNodes) {
      modelRoot = this.loadedModelNodes.get(content);
    }
    if (modelRoot != null) {
      // Notify cached model to observer with a clone of the model
      modelObserver.modelUpdated((BranchGroup)cloneNode(modelRoot));
    } else if (synchronous) {
      try {
        modelRoot = loadModel(content);
        synchronized (this.loadedModelNodes) {
          // Store in cache model node for future copies
          this.loadedModelNodes.put(content, (BranchGroup)modelRoot);
        }
        modelObserver.modelUpdated((BranchGroup)cloneNode(modelRoot));
      } catch (IOException ex) {
        modelObserver.modelError(ex);
      }
    } else if (!EventQueue.isDispatchThread()) {
      throw new IllegalStateException("Asynchronous call out of Event Dispatch Thread");
    } else
      if (this.modelsLoader == null) {
        this.modelsLoader = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
      }
      List<ModelObserver> observers = this.loadingModelObservers.get(content);
      if (observers != null) {
        // If observers list exists, content model is already being loaded
        // register observer for future notification
        observers.add(modelObserver);
      } else {
        // Create a list of observers that will be notified once content model is loaded
        observers = new ArrayList<ModelObserver>();
        observers.add(modelObserver);
        this.loadingModelObservers.put(content, observers);
       
        // Load the model in an other thread
        this.modelsLoader.execute(new Runnable() {
          public void run() {
            try {
              final BranchGroup loadedModel = loadModel(content);
              synchronized (loadedModelNodes) {
                // Update loaded models cache and notify registered observers
                loadedModelNodes.put(content, loadedModel);
              }
              EventQueue.invokeLater(new Runnable() {
View Full Code Here


            & ~(Loader.LOAD_LIGHT_NODES | Loader.LOAD_FOG_NODES
                | Loader.LOAD_BACKGROUND_NODES | Loader.LOAD_VIEW_GROUPS));
        // Return the first scene that can be loaded from model URL content
        Scene scene = loader.load(urlContent.getURL());

        BranchGroup modelNode = scene.getSceneGroup();
        // If model doesn't have any child, consider the file as wrong
        if (modelNode.numChildren() == 0) {
          throw new IllegalArgumentException("Empty model");
        }
       
        // Update transparency of scene window panes shapes
        updateShapeNamesAndWindowPanesTransparency(scene);
View Full Code Here

  /**
   * Returns the node of the outline model.
   */
  private Node getOutlineModelNode() {
    TransformGroup transformGroup = (TransformGroup)getChild(0);
    BranchGroup branchGroup = (BranchGroup)transformGroup.getChild(0);
    if (branchGroup.numChildren() > 1) {
      return branchGroup.getChild(1);
    } else {
      return null;
    }
  }
View Full Code Here

   */
  private void updatePieceOfFurnitureModelNode(Node modelNode,
                                               TransformGroup normalization,
                                               boolean ignoreDrawingMode,
                                               boolean waitTextureLoadingEnd) {   
    BranchGroup modelBranch = new BranchGroup();
    normalization.addChild(modelNode);
    normalization.setCapability(ALLOW_CHILDREN_READ);
    // Add model node to branch group
    modelBranch.addChild(normalization);
    if (!ignoreDrawingMode) {
      // Add outline model node
      modelBranch.addChild(createOutlineModelNode(normalization));
    }

    setModelCapabilities(modelBranch);

    TransformGroup transformGroup = (TransformGroup)getChild(0);
View Full Code Here

        setCapability(BranchGroup.ALLOW_DETACH);
        highlight.setCapability(Material.ALLOW_COMPONENT_READ);
        highlight.setCapability(Material.ALLOW_COMPONENT_WRITE);
        highlightEffect.setSchedulingBounds(BoardModel.bounds);
        addChild(highlightEffect);
        BranchGroup back = new BranchGroup();
        Appearance sapp = new Appearance();
        sapp.setColoringAttributes(new ColoringAttributes(SKY, ColoringAttributes.SHADE_FLAT));
        sapp.setPolygonAttributes(C.noCull);
        sapp.setTexture(tileManager.getTexture("data/images/misc/clouds.jpg"));
        TransformGroup tg = new TransformGroup(new Transform3D(C.mkquat(1, 0, 0, Math.PI/2), new Vector3d(), 1.0));
        tg.addChild(new Sphere(1f, Primitive.GENERATE_TEXTURE_COORDS, 100, sapp));
        back.addChild(tg);
        Background bg = new Background(back);
        bg.setApplicationBounds(bounds);
        addChild(bg);
    }
View Full Code Here

        interpolator1.setSchedulingBounds(BoardModel.bounds);
        interpolator2.setSchedulingBounds(BoardModel.bounds);
        interpolator3.setSchedulingBounds(BoardModel.bounds);

        BranchGroup bg = new BranchGroup();
        bg.addChild(interpolator1);
        bg.addChild(interpolator2);
        bg.addChild(interpolator3);
        addChild(bg);

        alpha.setStartTime(System.currentTimeMillis()+1000);
    }
View Full Code Here

    static ViewTransform create(int index, SimpleUniverse universe) {
        try {
            ViewTransform v = (ViewTransform)transforms[index].newInstance();
            v.universe = universe;
            v.controllers = new BranchGroup();
            v.controllers.setCapability(BranchGroup.ALLOW_DETACH);

            MultiTransformGroup mtg = universe.getViewingPlatform().getMultiTransformGroup();

            for (int i = 0; i < mtg.getNumTransforms(); i++) {
View Full Code Here

        f.addChild(r);
        r.addChild(p);
        p.addChild(t);
        t.addChild(obj);

        BranchGroup bg = new BranchGroup();
        MouseRotate behavior1 = new MouseRotate(t);
        behavior1.setFactor(0.0, -0.002);
        bg.addChild(behavior1);
        behavior1.setSchedulingBounds(BoardModel.bounds);

        MouseRotate behavior2 = new MouseRotate(r);
        behavior2.setFactor(-0.002, 0.0);
        bg.addChild(behavior2);
        behavior2.setSchedulingBounds(BoardModel.bounds);

        bg.addChild(f);

        return bg;
    }
View Full Code Here

        v.setFrontClipPolicy(View.VIRTUAL_EYE);
        v.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);

        tileManager = new TileTextureManager(this, game);

        cursors = new BranchGroup();
        cursors.setPickable(false);
        cursors.addChild(cursor = new CursorModel(C.cyan));
        cursors.addChild(highlightCursor = new CursorModel(C.white));
        cursors.addChild(selectCursor = new CursorModel(C.blue));
        cursors.addChild(firstLOSCursor = new CursorModel(LOS_COLOR));
View Full Code Here

        addChild(new ArtilleryAttackModel(TilesetManager.ARTILLERY_INCOMING, aaa, game, tileManager));
    }

    public void remove(Entity entity) {
        for (Enumeration<?> e = getAllChildren(); e.hasMoreElements();) {
            BranchGroup bg = (BranchGroup)e.nextElement();
            AttackAction a = (AttackAction)bg.getUserData();
            if (a != null && a.getEntityId() == entity.getId()) bg.detach();
        }
    }
View Full Code Here

TOP

Related Classes of javax.media.j3d.BranchGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.