Results 1 to 10 of 10
  1. #1
    mingming88 is offline Member
    Join Date
    Aug 2010
    Posts
    5
    Rep Power
    0

    Default Question about the program

    Hi
    i try to run the program below, but i don't know why i can't run it.
    There is something wrong with the import com.sun.j3d, how can i fix it?
    Thank you

    Java Code:
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    
    import javax.media.j3d.*;
    import javax.vecmath.*;
    
    import com.sun.j3d.utils.applet.MainFrame;
    
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.loaders.Scene;
    
    import javax.swing.JFrame;
    import javax.swing.WindowConstants;
    
    /**
    * Renders a 3D shape using a 3D rendering engine
    * that was written from scratch using AWT for
    * graphics operations.
    */
    public class main extends JFrame
    {
    	private static int 				m_kWidth = 400;
    	private static int 				m_kHeight = 400;
       
       private RenderingEngine			renderingEngine = new AwtRenderingEngine();
       private GeometryUpdater			geometryUpdater = new RotatingGeometryUpdater();
       private RenderingSurface		renderingSurface;
    
    	public main( )
    	{
       	// load the object file
    		Scene scene = null;
    		Shape3D shape = null;
    
    		// read in the geometry information from the data file
    		ObjectFile objFileloader = new ObjectFile( ObjectFile.RESIZE );
    
    		try
    		{
    			scene = objFileloader.load( "hand1.obj" );
    		}
    		catch ( Exception e )
    		{
    			scene = null;
    			System.err.println( e );
    		}
    
    		if( scene == null )
    			System.exit( 1 );
    
    		// retrieve the Shape3D object from the scene
    		BranchGroup branchGroup = scene.getSceneGroup( );
    		shape = (Shape3D) branchGroup.getChild( 0 );
    
           GeometryArray geometryArray = (GeometryArray) shape.getGeometry();
          
           // add the geometry to the rendering engine...       
           renderingEngine.addGeometry( geometryArray );
           
           // create a rendering surface and bind the rendering engine
           renderingSurface = new RenderingSurface( renderingEngine, geometryUpdater );
           
           // start the rendering surface and add it to the content panel
           renderingSurface.start();
           getContentPane().add( renderingSurface );
           
        	// disable automatic close support for Swing frame.
    		setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE );
    			
    		// adds the window listener
    		addWindowListener( 
    			new WindowAdapter()
    			{
    				// handles the system exit window message
    				public void windowClosing( WindowEvent e )
    				{
    					System.exit( 0 );				
                   }
    			}
    		);
    	}
       
    	public static void main( String[] args )
    	{
    		main main = new main();
    		main.setTitle( "3D" );
    		main.setSize( 300, 300 );
    		main.setVisible( true );
    	}
    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    762
    Rep Power
    10

    Default

    Do you have the required 3D library required by your program? I believe you can download it from the following link: Java SE Desktop Technologies - Java 3D API

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    8

    Default

    can you please post the file hand1.obj or the content of this file?

  4. #4
    mingming88 is offline Member
    Join Date
    Aug 2010
    Posts
    5
    Rep Power
    0

    Default

    Here is the hand1.obj.
    i have added j3dtree.jar
    Attached Files Attached Files

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,062
    Rep Power
    23

    Default

    Quote Originally Posted by mingming88 View Post
    Hi
    i try to run the program below, but i don't know why i can't run it.
    There is something wrong with the import com.sun.j3d, how can i fix it?
    Thank you
    What error do you get?

    Posting all the code is pointless without telling us what is actually going wrong.

  6. #6
    mingming88 is offline Member
    Join Date
    Aug 2010
    Posts
    5
    Rep Power
    0

    Default

    can't import these,
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.loaders.Scene;

    so the Scene and ObjectFile has error on it.
    When i try to run the program, it show this message
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    at main.main(main.java:115)

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,062
    Rep Power
    23

    Default

    And what is the unresolved compilation problem?

  8. #8
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    762
    Rep Power
    10

    Default

    Hi,

    Are you sure that the classes your are importing is in the j3dtree.jar? Because on my Java3D installation the classes is inside the j3dutils.jar.

  9. #9
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    8

    Default

    Quote Originally Posted by mingming88 View Post
    can't import these,
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.loaders.Scene;

    i've made a file main.java in eclipse and all imports were ok. but i got this errors:

    RenderingEngine cannot be resolved to a type, same error for AwtRenderingEngine, RotatingGeometryUpdater and RenderingSurface. so, must these classes be implemented or can these classes be imported by a package?

  10. #10
    mingming88 is offline Member
    Join Date
    Aug 2010
    Posts
    5
    Rep Power
    0

    Default

    Yes, those classes are implemented. Maybe my java3D is not installed correctly. i will try again. Thank you for helping

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 09:49 AM
  2. JAVA Program Question! .class file
    By 0_0 in forum New To Java
    Replies: 6
    Last Post: 04-06-2010, 11:23 PM
  3. question in java program
    By Moiz in forum New To Java
    Replies: 1
    Last Post: 09-13-2009, 11:33 PM
  4. Simple Paint program question
    By StressaJune in forum New To Java
    Replies: 1
    Last Post: 03-30-2009, 08:46 PM
  5. Question/Java Program
    By icedragon770 in forum Java Applets
    Replies: 7
    Last Post: 10-13-2008, 06:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •