Package com.sun.j3d.loaders

Examples of com.sun.j3d.loaders.Scene


        public void actionPerformed(ActionEvent e) {
            if(handler==null){
                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


        // Ask loader to ignore lights, fogs...
        loader.setFlags(loader.getFlags()
            & ~(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");
        }
       
View Full Code Here

  public static BranchGroup file2bgroup(String filename) {
    if(filename.endsWith(".j3f") || filename.endsWith(".J3F")
    || filename.endsWith(".j3f.gz") || filename.endsWith(".J3F.GZ"))
      return jf2bgroup(filename)
    //else 
    Scene s=file2scene(filename);
    if(null==s) return null;
    BranchGroup b =  s.getSceneGroup();
    Hashtable H=s.getNamedObjects();
    if(null!=H) {
      HashMap HM=new HashMap(H);
      //Prolog3D.pp("names="+HM);
      fixMap(HM);
      b.setUserData(HM);
View Full Code Here

    }
    return null;
  }
 
  private static Scene file2scene(String filename) {
    Scene s=null;
    if(filename.endsWith(".obj") || filename.endsWith(".OBJ")
      || filename.endsWith(".obj.gz") || filename.endsWith(".OBJ.GZ"))
      s=obj2scene(filename);
    else if(filename.endsWith(".wrl") || filename.endsWith(".WRL")
      || filename.endsWith(".wrl.gz") || filename.endsWith(".WRL.GZ"))
View Full Code Here

 
  /**
     Loads a .wrl or .wrl.gz VRML file to a Scene
   */
  public static Scene vrml2scene(String filename) {
    Scene s = null;
    VrmlLoader f = new VrmlLoader();
    try {
      filename=Convert.fixFileName(filename);
      if(filename.startsWith("http://"))
        s=f.load(new java.net.URL(filename));
View Full Code Here

    if (!noStripify) flags |= ObjectFile.STRIPIFY;
     
    ObjectFile f =
      new ObjectFile(flags,
      (float)(creaseAngle * Math.PI / 180.0));
    Scene s = null;
    try {
      filename=fixFileName(filename);
      if(filename.startsWith("http://"))
        s=f.load(new java.net.URL(filename));
      else
View Full Code Here



    //Load an obj-file.
    ObjectFile f = new ObjectFile(ObjectFile.RESIZE);
    Scene s = null;

    try
    {
      s = f.load("./eas/miscellaneous/java3D/schiff.obj");
    }
    catch (Exception e)
    {
      System.out.println("File loading failed:" + e);
    }








    //Choose a part of the object (here: schiffrumpf).
    Hashtable namedObjects = s.getNamedObjects();
    Shape3D partOfTheObject = (Shape3D) namedObjects.get("schiffsrumpf");

    //Generate a copy of the chosen part.
    Shape3D extractedObject = (Shape3D) partOfTheObject.cloneTree();
View Full Code Here

    // the SimpleUniverse.
    public void createSceneGraph(SimpleUniverse su) {

        // Load an obj-file.
        ObjectFile f = new ObjectFile(ObjectFile.RESIZE);
        Scene s = null;

        try {
            s = f.load("./eas/miscellaneous/java3D/schiff.obj");
        } catch (Exception e) {
            System.out.println("File loading failed:" + e);
        }

        // Generate a transformation group for the loaded object.
        Transform3D tfObject = new Transform3D();
        tfObject.rotZ(0.4 * Math.PI);
        Transform3D xRotation = new Transform3D();
        xRotation.rotY(0.4 * Math.PI);
        tfObject.mul(xRotation);
        TransformGroup tgObject = new TransformGroup(tfObject);
        tgObject.addChild(s.getSceneGroup());

        // In the following way, the names of the parts of the object can be
        // obtained. The names are printed.
        Hashtable namedObjects = s.getNamedObjects();
        Enumeration enumer = namedObjects.keys();
        String name;
        while (enumer.hasMoreElements()) {
            name = (String) enumer.nextElement();
            System.out.println("Name: " + name);
View Full Code Here

/*     */     }
/*     */     catch (IOException e)
/*     */     {
/* 131 */       throw new FileNotFoundException(e.getMessage());
/*     */     }
/* 133 */     Scene returnScene = load(reader);
/* 134 */     this.fileType = 0;
/* 135 */     return returnScene;
/*     */   }
View Full Code Here

/*     */     throws FileNotFoundException, IncorrectFormatException, ParsingErrorException
/*     */   {
/* 148 */     this.fileType = 2;
/* 149 */     setInternalBasePath(fileName);
/* 150 */     Reader reader = new BufferedReader(new FileReader(fileName));
/* 151 */     Scene returnScene = load(reader);
/* 152 */     this.fileType = 0;
/* 153 */     return returnScene;
/*     */   }
View Full Code Here

TOP

Related Classes of com.sun.j3d.loaders.Scene

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.