Results 1 to 10 of 10
Thread: Question about the program
- 08-25-2010, 08:33 AM #1
Member
- Join Date
- Aug 2010
- Posts
- 5
- Rep Power
- 0
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 ); } }
- 08-25-2010, 11:32 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
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
Website: Learn Java by Examples
- 08-25-2010, 12:27 PM #3
can you please post the file hand1.obj or the content of this file?
- 08-25-2010, 01:44 PM #4
Member
- Join Date
- Aug 2010
- Posts
- 5
- Rep Power
- 0
Here is the hand1.obj.
i have added j3dtree.jar
- 08-25-2010, 02:48 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
- 08-25-2010, 02:58 PM #6
Member
- Join Date
- Aug 2010
- Posts
- 5
- Rep Power
- 0
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)
- 08-25-2010, 03:10 PM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
And what is the unresolved compilation problem?
- 08-25-2010, 03:16 PM #8
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
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.Website: Learn Java by Examples
- 08-25-2010, 03:16 PM #9
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?
- 08-25-2010, 03:45 PM #10
Member
- Join Date
- Aug 2010
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Question mark colon operator question
By orchid in forum Advanced JavaReplies: 9Last Post: 12-19-2010, 08:49 AM -
JAVA Program Question! .class file
By 0_0 in forum New To JavaReplies: 6Last Post: 04-06-2010, 11:23 PM -
question in java program
By Moiz in forum New To JavaReplies: 1Last Post: 09-13-2009, 11:33 PM -
Simple Paint program question
By StressaJune in forum New To JavaReplies: 1Last Post: 03-30-2009, 08:46 PM -
Question/Java Program
By icedragon770 in forum Java AppletsReplies: 7Last Post: 10-13-2008, 06:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks