Something wrong with the import things
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
Code Java:
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 );
}
}
Re: Something wrong with the import things
Quote:
Originally Posted by
mingming8888
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?
add the j3d-jars to your classpath. can you please attach the file hand1.obj?
1 Attachment(s)
Re: Something wrong with the import things
Re: Something wrong with the import things