1 2 Previous Next 15 Replies Latest reply: May 1, 2010 4:04 AM by 843799 RSS

    LOAD VILLA MODEL WITH TEXTURES

    843799
      HI FOR ALL

      FIRST I HAVE A PROBLEM IN MY GRADUATION PROJECT I WANT TO LOAD A 3D VILLA MODELS WITH TEXTURES

      I LOADED MODELS BUT TEXTURES DID NOT APPEAR PLEASE CAN ANY ONE HELP ME

      SECOND I WANT TO PUT THE JAVA 3D APPLET ON A WEBSITE HOW CAN I PUT THE J3D APPLET IN HTML DOC ??
        • 1. Re: LOAD VILLA MODEL WITH TEXTURES
          794459
          Don't use all caps :)

          Assuming the person running your Java 3D applet has Java 3D installed, I believe you don't need to do anything differently from what you would do for a regular applet. If you don't know how to embed a typical applet in a web page, the HTML to run an applet contained in test.jar whose main class is nameOfJavaClass in a 400-pixel-by-300-pixel space on your web page is:
          <applet code = 'nameOfJavaClass' 
              archive = 'test.jar', 
              width = 400, 
              height = 300 />
          As for your other question, I'm going to say what anyone else would say: please post your code if you want to get suggestions on it. I'll try to help when I see some code.
          • 2. Re: LOAD VILLA MODEL WITH TEXTURES
            843799
            Thanks for your help

            but i have a problem

            my applet acces the data base to get the model url
            but in my html file i wrote the applet tag but i hav an error
            that com.mysql.jdbc.Driver can't found , ithink that the html can't see the mu sql jar file
            second error is as follows
            java.security.AccessControlException: access denied (java.io.FilePermission C:\Users\Mido\Desktop\OBJ-Models\house\casa1\casa1.obj read)
                 at java.security.AccessControlContext.checkPermission(Unknown Source)
                 at java.security.AccessController.checkPermission(Unknown Source)
                 at java.lang.SecurityManager.checkPermission(Unknown Source)
                 at java.lang.SecurityManager.checkRead(Unknown Source)
                 at java.io.FileInputStream.<init>(Unknown Source)
                 at java.io.FileInputStream.<init>(Unknown Source)
                 at java.io.FileReader.<init>(Unknown Source)
                 at com.sun.j3d.loaders.objectfile.ObjectFile.load(ObjectFile.java:675)
                 at showonapplet.OnAppletView.createSceneGraph(OnAppletView.java:107)
                 at showonapplet.OnAppletView.init(OnAppletView.java:247)
                 at sun.applet.AppletPanel.run(Unknown Source)
                 at java.lang.Thread.run(Unknown Source)
            • 3. Re: LOAD VILLA MODEL WITH TEXTURES
              794459
              You're having a SecurityException. An applet isn't allowed to access the local filesystem. If an applet running in a web browser could access local filesystems, Java would have all kinds of security problems with malicious applets trying to steal private information from people's computers. There's a reason Java stops applets from doing this.

              Now...how do you proceed, you might ask. You can either use a signed applet (a "trusted" type of applet that pops up a security dialog when it's run) or you can just switch to using a Java application and forgo running your applet from a browser. For what reason do you need to run from a browser, anyway?
              • 4. Re: LOAD VILLA MODEL WITH TEXTURES
                843799
                i want to put the applet on the web because my graduation project is to make a web application

                the problem still arise please help :)
                • 5. Re: LOAD VILLA MODEL WITH TEXTURES
                  794459
                  Can you tell me what graphics system you're using? Are you using Java 3D, JOGL, or what?
                  • 6. Re: LOAD VILLA MODEL WITH TEXTURES
                    843799
                    JAVA 3D
                    • 7. Re: LOAD VILLA MODEL WITH TEXTURES
                      843799
                      This is my appleT

                      {code */
                      public class OnAppletView extends Applet {

                          public BranchGroup createSceneGraph(SimpleUniverse su) throws MalformedURLException {
                      //        String objUrl="";
                      //         Connection conn=null;
                      //          String UserName="root";
                      //          String Password="password";
                      //          String Url="jdbc:mysql://localhost/City";
                      //                ResultSet rs=null;
                      //                try
                      //          {
                      //          Class.forName("com.mysql.jdbc.Driver").newInstance();
                      //
                      //          conn=DriverManager.getConnection(Url,UserName,Password);
                      //          System.out.println("Database connection established");
                      //
                      //          Statement s=conn.createStatement();
                      //
                      //
                      //          s.executeQuery("select url from resources where obj1='villa' ");
                      //
                      //          rs=s.getResultSet();
                      //
                      //
                      //                if(rs!=null)
                      //         {
                      //              try
                      //              {
                      //
                      //
                      //              while(rs.next())
                      //              {
                      //                   objUrl=rs.getString(1);
                      //                        System.out.println("objjjj"+objUrl);
                      //
                      //              }
                      //
                      //          }
                      //          catch (Exception e) {
                      //                    // TODO: handle exception
                      //               e.printStackTrace();
                      //               }
                      //
                      //     }
                      //
                      //          s.close();
                      //          conn.close();
                      //          System.out.println("DB Connection terminated");
                      //
                      //          }
                      //          catch (Exception e) {
                      //               e.printStackTrace();
                      //
                      //          }

                      // Create the root of the branch graph
                      TransformGroup vpTrans = null;

                      BranchGroup objRoot = new BranchGroup();
                      /****************************************************************/
                      ObjectFile f = new ObjectFile(ObjectFile.RESIZE | ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY );
                      Scene s = null;
                      try {
                      //
                      // f.setBaseUrl( new URL("file:///"));
                      // s = f.load(new URL("file:///C:/Users/Mido/Desktop/ObjectLoader/villa1/villa1.obj"));

                      // f.setBaseUrl(new URL("file:///C:/Users/Mido/Desktop/OBJ-Models/Unterstand&Carport/"));
                      // s = f.load(new URL("file:///C:/Users/Mido/Desktop/OBJ-Models/house/casa1/casa1.obj"));


                      f.setBasePath("C:\\Users\\Mido\\Desktop\\NewVilla\\");
                      s = f.load("C:\\Users\\Mido\\Desktop\\NewVilla\\House02b.obj");

                      } catch (FileNotFoundException e) {
                      System.err.println(e);
                      System.exit(1);

                      } catch (ParsingErrorException e) {

                      System.err.println(e);
                      System.exit(1);
                      } catch (IncorrectFormatException e) {
                      System.err.println(e);
                      System.exit(1);

                      }


                      /// objRoot.addChild(s.getSceneGroup());
                      /****************************************************************/
                      Vector3f translate = new Vector3f();
                      Transform3D T3D = new Transform3D();
                      TransformGroup TG = null;



                      SharedGroup share = new SharedGroup();
                      share.addChild(s.getSceneGroup());

                      float[][] position = {{0.0f, -0.1f, -3.0f},
                      {6.0f, -0.1f, 0.0f},
                      {6.0f, -0.1f, 6.0f},
                      {3.0f, -0.1f, -10.0f},
                      {13.0f, -0.1f, -30.0f},
                      {-13.0f, -0.1f, 30.0f},
                      {-13.0f, -0.1f, 23.0f},
                      {13.0f, -0.1f, 3.0f}};

                      for (int i = 0; i < position.length; i++) {
                      translate.set(position);
                      T3D.setTranslation(translate);
                      TG = new TransformGroup(T3D);
                      TG.addChild(new Link(share));
                      objRoot.addChild(TG);
                      }

                      vpTrans = su.getViewingPlatform().getViewPlatformTransform();
                      translate.set(0.0f, 0.3f, 0.0f);
                      T3D.setTranslation(translate);
                      vpTrans.setTransform(T3D);
                      KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(vpTrans);
                      keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0));
                      objRoot.addChild(keyNavBeh);



                      objRoot.compile();

                      return objRoot;
                      } // end of CreateSceneGraph method of KeyNavigatorApp

                      public void init() {
                      // TODO start asynchronous download of heavy resources
                      setLayout(new BorderLayout());
                      GraphicsConfiguration config =
                      SimpleUniverse.getPreferredConfiguration();

                      Canvas3D canvas3D = new Canvas3D(config);
                      add("Center", canvas3D);

                      // SimpleUniverse is a Convenience Utility class
                      SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

                      BranchGroup scene=null;
                      try {
                      scene = createSceneGraph(simpleU);
                      } catch (MalformedURLException ex) {
                      Logger.getLogger(OnAppletView.class.getName()).log(Level.SEVERE, null, ex);
                      }
                      // LIGHT
                      AmbientLight ambientLight = new AmbientLight(new Color3f(Color.black));
                      ambientLight.setInfluencingBounds(new BoundingSphere(new Point3d(), 100.0));

                      DirectionalLight directionalLight = new DirectionalLight(new Color3f(Color.WHITE), new Vector3f(0.0f, 0.0f, -1.0f));
                      directionalLight.setInfluencingBounds(new BoundingSphere(new Point3d(), 100.0));

                      BranchGroup lightingBG = new BranchGroup();
                      lightingBG.addChild(ambientLight);
                      lightingBG.addChild(directionalLight);
                      PlatformGeometry platformGeometry = new PlatformGeometry();
                      platformGeometry.addChild(lightingBG);
                      simpleU.getViewingPlatform().setPlatformGeometry(platformGeometry);

                      //END OF LIGHT

                      // This will move the ViewPlatform back a bit so the
                      // objects in the scene can be viewed.
                      simpleU.getViewingPlatform().setNominalViewingTransform();

                      // TO INTERACT WITH MOUSE
                      // OrbitBehavior orbitBehavior = new OrbitBehavior(canvas3D , OrbitBehavior.REVERSE_ALL);
                      // orbitBehavior.setBoundsAutoCompute(true);
                      // orbitBehavior.setSchedulingBounds(new BoundingSphere(new Point3d() , 100.0));
                      // simpleU.getViewingPlatform().setViewPlatformBehavior(orbitBehavior);

                      simpleU.addBranchGraph(scene);


                      }


                      // TODO overwrite start(), stop() and destroy() methods
                      }
                      i wanT To implemenT a collision detection to prevent the viewer to walk through the wall what can i do ? there is a class ??                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                      • 8. Re: LOAD VILLA MODEL WITH TEXTURES
                        794459
                        Look up Java Network Launch Protocol. You can deploy Java 3D through a web browser that way.

                        Java 3D does have classes for collision detection. Just Google Java 3D collision detection.
                        • 9. Re: LOAD VILLA MODEL WITH TEXTURES
                          843799
                          i try that but i coudn't do that

                          please help me in my 2 problems
                          • 10. Re: LOAD VILLA MODEL WITH TEXTURES
                            794459
                            You couldn't do what? Why not? What specific problems are you having?

                            Here's a link to some code that uses collision detection in Java 3D: http://www.java-tips.org/other-api-tips/java3d/collision-detection-with-java3d-3.html

                            Edited by: cronosprime1 on Apr 29, 2010 5:04 PM
                            • 11. Re: LOAD VILLA MODEL WITH TEXTURES
                              843799
                              file permission problem was solve

                              buT collision detection classes that i found doesn't match what i need
                              • 12. Re: LOAD VILLA MODEL WITH TEXTURES
                                794459
                                OK. You need to be much more specific. In what way do the collision detection classes not match what you need? What is it that you need, even? How exactly do you want your wall collisions to work? Describe in detail the problem that you're having, what you've tried to solve it, and why those attempts didn't work.
                                • 13. Re: LOAD VILLA MODEL WITH TEXTURES
                                  843799
                                  i want to make a collision detection that prevent the user from walking through the obj models & prevent him from walking too away from a specified area

                                  i didn't find any thing that match my requirements , all collision classes don't do that they may changr the color only & the collision isa made between

                                  two different shapes but i want the collision detection to be between the viewer and the obj model
                                  • 14. Re: LOAD VILLA MODEL WITH TEXTURES
                                    794459
                                    Hmmmm...I don't know how to do that, exactly. You can probably create some kind of invisible bounding box around the viewer and check collision with that. I'm not sure if that's the best way to do it, though.

                                    I'm actually going to be solving this very problem for my own needs soon, so check back in a couple of days.
                                    1 2 Previous Next