Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Help in icosahedron file please help very urgent

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help in icosahedron file please help very urgent

    isocahedron.rar
    can someone help me get this obj file working
    This is the code called "Phong.java" that I am trying to run with the icosahedron object file.
    I needed to use Phong.java and the teapot input to create a icosahedron
    I have code for an isocahedron as well as a file that is supposed to be used as an object loader. I need help figuring out what is wrong with the code.
    I am not sure what is wrong but I believe it is the input file because it isn't showing me anything when I run it.
    please please please



    here is the code, need help in fixing it
    import javax.vecmath.*;
     
    import com.sun.j3d.utils.universe.*;
    import javax.media.j3d.*;
     
    import com.sun.j3d.utils.behaviors.vp.*;
    import javax.swing.JFrame;
    import com.sun.j3d.loaders.*;
    import com.sun.j3d.loaders.objectfile.*;
     
     
     
     
    /**
    * An example for constructing an object (tetrahedron) with triangles
    * where normal vectors are interpolated.
    *
    * @author Frank Klawonn
    * Last change 05.07.2005
    * @see GeomArrayExample
    */
    public class Isocahedran extends JFrame
    {
     
      //The canvas to be drawn upon.
      public Canvas3D myCanvas3D;
     
     
      public Isocahedran()
      {
        //Mechanism for closing the window and ending the program.
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
     
        //Default settings for the viewer parameters.
        myCanvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
     
     
        //Construct the SimpleUniverse:
        //First generate it using the Canvas.
        SimpleUniverse simpUniv = new SimpleUniverse(myCanvas3D);
     
     
        //Default position of the viewer.
        simpUniv.getViewingPlatform().setNominalViewingTransform();
     
     
        //The scene is generated in this method.
        createSceneGraph(simpUniv);
     
     
        //Add some light to the scene.
        addLight(simpUniv);
     
     
        //The following three lines enable navigation through the scene using the mouse.
        OrbitBehavior ob = new OrbitBehavior(myCanvas3D);
        ob.setSchedulingBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE));
        simpUniv.getViewingPlatform().setViewPlatformBehavior(ob);
     
     
        //Show the canvas/window.
        setTitle("An object loaded from a file");
        setSize(700,700);
        getContentPane().add("Center", myCanvas3D);
        setVisible(true);
     
      }
     
     
     
     
      public static void main(String[] args)
      {
         Isocahedran nfga = new Isocahedran();
      }
     
     
     
     
     
      //In this method, the objects for the scene are generated and added to 
      //the SimpleUniverse.
      public void createSceneGraph(SimpleUniverse su)
      {
     
     
     
       //Load an obj-file.
        ObjectFile f = new ObjectFile(ObjectFile.RESIZE);
        Scene s = null;
     
        try
        {
          s = f.load("isocahedron.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());
     
     
        Appearance yellowApp = new Appearance();
        setToMyDefaultAppearance(yellowApp,new Color3f(0.5f,0.5f,0.0f));
     
        BranchGroup theScene = new BranchGroup();
     
        //Add the tetrahedron to the scene.
        Background bg = new Background(new Color3f(1.0f,1.0f,1.0f));
        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),Double.MAX_VALUE);
        bg.setApplicationBounds(bounds);
        theScene.addChild(bg);
     
        theScene.compile();
     
        //Add everything to the universe.
        su.addBranchGraph(theScene);
     
        }
     
     
     
      /**
      * Generates a default surface (Appearance) in a specified colour.
      *
      * @param app      The Appearance for the surface.
      * @param col      The colour.
      */
      public static void setToMyDefaultAppearance(Appearance app, Color3f col)
      {
        app.setMaterial(new Material(col,col,col,col,150.0f));
      }
     
     
     
      //Some light is added to the scene here.
      public void addLight(SimpleUniverse su)
      {
     
        BranchGroup bgLight = new BranchGroup();
     
        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
        Color3f lightColour1 = new Color3f(1.0f,1.0f,1.0f);
        Vector3f lightDir1  = new Vector3f(-1.0f,0.0f,-0.5f);
        DirectionalLight light1 = new DirectionalLight(lightColour1, lightDir1);
        light1.setInfluencingBounds(bounds);
     
     
        Vector3f lightDir2  = new Vector3f(1.0f,0.0f,0.5f);
        DirectionalLight light2 = new DirectionalLight(lightColour1, lightDir2);
        light2.setInfluencingBounds(bounds);
     
     
        bgLight.addChild(light1);
        bgLight.addChild(light2);
     
        su.addBranchGraph(bgLight);
      }
     
     
     
    }


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Help in icosahedron file please help very urgent

    If this is truly urgent, then why not read the forum FAQ to see how to ask questions here and how to post code so that it's readable including use of code tags? I've deleted the email address as that's not how things are done here. Please let's communicate all on the forum itself.

    Sorry for the sarcasm, but you really should avoid mentioning urgency as your question is no more important than any other question on this site. So please respect all the other folks asking questions here and leave your urgency out of the equation. Also if you format your code well with code tags, folks will be better able to read it, understand it, and help you.

    --- Update ---

    Also, you'll want to show your data file here in the forum and tell us what problems you may be having. Your post mentions nothing that would allow us to understand what's wrong or how we can help you.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Help in icosahedron file please help very urgent

    Also posted at: Help in icosahedron file please help very urgent - Dev Shed
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 21
    Last Post: November 27th, 2012, 10:58 PM
  2. Read input, read file, find match, and output... URGENT HELP!
    By MooseHead in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 3rd, 2012, 11:01 AM
  3. Need urgent help regarding java word wrap function.. URGENT
    By coldice in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 16th, 2011, 05:43 AM
  4. Urgent - File exist nor working
    By Bagzli in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 2nd, 2011, 04:09 AM
  5. [SOLVED] need help urgent
    By rupa in forum Java Servlet
    Replies: 1
    Last Post: January 19th, 2011, 02:41 PM