Package javax.media.j3d

Examples of javax.media.j3d.BranchGroup


    public ArrayList<BranchGroup> getSceneGraphs() {
        Enumeration<?> e = _rootLocale.getAllBranchGraphs();
        ArrayList<BranchGroup> res = new ArrayList<BranchGroup>();
        while (e.hasMoreElements()) {
            BranchGroup bg = (BranchGroup) e.nextElement();
            if (!(bg instanceof ViewingPlatform)) {
                res.add(bg);
            }
        }
        return res;
View Full Code Here


        try {
            SceneGraphFileWriter w = new SceneGraphFileWriter(f, null, false,
                    "TBDuinverseName", null);
            Enumeration<?> e = _rootLocale.getAllBranchGraphs();
            while (e.hasMoreElements()) {
                BranchGroup bg = (BranchGroup) e.nextElement();
                if (!(bg instanceof ViewingPlatform)) {
                    // TODO serialize a name ???
                    w.writeBranchGraph(bg, null);
                }
            }
View Full Code Here

        Enumeration<?> e=getAllLocales();
        while(e.hasMoreElements()){
            Locale l=(Locale)e.nextElement();
            Enumeration<?> el=l.getAllBranchGraphs();
            while(el.hasMoreElements()){
                BranchGroup bg=(BranchGroup)el.nextElement();
                if(nodeClass.isAssignableFrom(bg.getClass())){
                    res.add(bg);
                }
                getNodes(res, nodeClass, bg);
            }
        }
View Full Code Here

    static class AddBranchGroupAction extends AbstractNodeAction {
        // required for dynamic action creation
        public AddBranchGroupAction() {
        }
        public void actionPerformed(ActionEvent e) {
            ((GroupNode)getNode()).addChildUndoable(new BranchGroup());
            getNode().refresh();
        }
View Full Code Here

                handler=new LoaderHandler();
            }
            if(handler.select()){
                Scene sc=handler.load();
                if(sc!=null){
                    BranchGroup bg=sc.getSceneGroup();
                    if(bg!=null){
                        GroupNode gn=(GroupNode)getNode();
                        gn.addChild(bg);
                        getNode().refresh();
                    }
View Full Code Here

    } else {
      setModelChangeTexts(preferences);
      // Read model in modelLoader executor
      this.modelLoader.execute(new Runnable() {
          public void run() {
            BranchGroup model = null;
            try {
              model = readModel(piece.getModel());
            } catch (IOException ex) {
              // Model loading failed
            }
            final BranchGroup readModel = model;
            // Update components in dispatch thread
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                  if (readModel != null) {
                    controller.setModel(piece.getModel());
View Full Code Here

              showModelChoiceError(modelName, preferences);
            }
            return;
          }
         
          BranchGroup model = null;
          Vector3f    modelSize = null;
          try {
            model = readModel(modelContent);
            modelSize = ModelManager.getInstance().getSize(model);
            // Copy model to a temporary OBJ content with materials and textures
            modelContent = copyToTemporaryOBJContent(model, modelName);
          } catch (IOException ex) {
            model = null;
          } catch (IllegalArgumentException ex) {
            // Model is empty
            model = null;
          }
         
          if (model == null) {
            try {
              // Copy model content to a temporary content
              modelContent = TemporaryURLContent.copyToTemporaryURLContent(modelContent);
            } catch (IOException ex2) {
              if (!ignoreException) {
                showModelChoiceError(modelName, preferences);
              }
              return;
            }
           
            // If content couldn't be loaded, try to load model as a zipped file
            ZipInputStream zipIn = null;
            try {
              URLContent urlContent = (URLContent)modelContent;
              // Open zipped stream
              zipIn = new ZipInputStream(urlContent.openStream());
              // Parse entries to see if one is readable
              for (ZipEntry entry; (entry = zipIn.getNextEntry()) != null; ) {
                try {
                  String entryName = entry.getName();
                  // Ignore directory entries and entries starting by a dot
                  if (!entryName.endsWith("/")) {
                    int slashIndex = entryName.lastIndexOf('/');
                    String entryFileName = entryName.substring(++slashIndex);
                    if (!entryFileName.startsWith(".")) {
                      URL entryUrl = new URL("jar:" + urlContent.getURL() + "!/"
                          + URLEncoder.encode(entryName, "UTF-8").replace("+", "%20").replace("%2F", "/"));
                      modelContent = new TemporaryURLContent(entryUrl);
                      model = readModel(modelContent);
                      modelSize = ModelManager.getInstance().getSize(model);
                      break;
                    }
                  }
                } catch (IOException ex3) {
                  // Ignore exception and try next entry
                  model = null;
                } catch (IllegalArgumentException ex3) {
                  // Model is empty
                  model = null;
                }
              }
            } catch (IOException ex2) {
              model = null;
            } finally {
              try {
                if (zipIn != null) {
                  zipIn.close();
                }
              } catch (IOException ex2) {
                // Ignore close exception
              }
            }
          }
         
          final BranchGroup readModel = model;
          final Vector3f    readModelSize = modelSize;
          final Content     readContent = modelContent;
          // Update components in dispatch thread
          EventQueue.invokeLater(new Runnable() {
              public void run() {
View Full Code Here

            updatePreviewComponentsModel(null);
          }
        });
           
      // Load piece model
      final BranchGroup modelNode = ModelManager.getInstance().loadModel(modelContent);
     
      // Change live object in Event Dispatch Thread
      EventQueue.invokeLater(new Runnable() {
          public void run() {
            updatePreviewComponentsModel(modelNode);
View Full Code Here

* Test ModelManager class.
* @author Emmanuel Puybaret
*/
public class ModelManagerTest extends TestCase {
  public void testDAELoader() throws IOException {
    BranchGroup model = ModelManager.getInstance().loadModel(
        new URLContent(ModelManagerTest.class.getResource("resources/test.dae")));
    assertTrue("Model shouldn't be empty", getShapesCount(model) > 0);
  }
View Full Code Here

        new URLContent(ModelManagerTest.class.getResource("resources/test.dae")));
    assertTrue("Model shouldn't be empty", getShapesCount(model) > 0);
  }

  public void testOBJLoader() throws IOException {
    BranchGroup model = ModelManager.getInstance().loadModel(
        new URLContent(ModelManagerTest.class.getResource("resources/test.obj")));
    assertTrue("Model shouldn't be empty", getShapesCount(model) > 0);
  }
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.