Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Trouble with suns Java 3d tutorial (solved)  (Read 1616 times)
0 Members and 1 Guest are viewing this topic.
Offline Rabe

Junior Newbie





« Posted 2007-08-23 17:27:15 »

Hallo, i tried to learn something about java 3d by following sun's java 3d tutorial step by step but everytime i try to compile i get a NullPointerException. The code from the Example is listed below, I'm working with the Eclipse IDE on a Windows system (which shouldn't matter anyway, because it should work on any IDE / OS, but I listed those things just in case...)


Quote

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.*;
import javax.vecmath.*;

public class HelloJava3Da extends Applet
{
   public HelloJava3Da()
  {
      setLayout(new BorderLayout());
      Canvas3D canvas3D = new Canvas3D(null);
      add("Center", canvas3D);

      BranchGroup scene = createSceneGraph();
      scene.compile();

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

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

      simpleU.addBranchGraph(scene);
   } // end of HelloJava3Da (constructor)

   public BranchGroup createSceneGraph()
   {
   // Create the root of the branch graph
      BranchGroup objRoot = new BranchGroup();

   // Create a simple shape leaf node, add it to the scene graph.
   // ColorCube is a Convenience Utility class
      objRoot.addChild(new ColorCube(0.4));

      return objRoot;
   } // end of createSceneGraph method of HelloJava3Da
   // The following allows this to be run as an application
   // as well as an applet

   public static void main(String[] args)
   {
       Frame frame = new MainFrame(new HelloJava3Da(), 256, 256);
   } // end of main (method of HelloJava3Da)

}
Offline InteractiveMesh

Senior Newbie





« Reply #1 - Posted 2007-08-24 08:43:55 »

Hi,

a null GraphicsConfiguration throws a NullPointerException in the current Java 3D 1.5.x release. Give this a try:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
import java.awt.GraphicsConfiguration;
 
GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();

Canvas3D canvas3D = null;
try {
    canvas3D = new Canvas3D(gc);
}
catch (NullPointerException e) {
    // handle exception
}
catch (IllegalArgumentException e) {
    // handle exception
}              


Good luck, August
Offline Rabe

Junior Newbie





« Reply #2 - Posted 2007-08-24 14:54:43 »

thanks for your help, it did work:) now it's time to continue my studies on the java 3d tutorial:)
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (75 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (47 views)
2014-11-29 21:32:03

toopeicgaming1999 (113 views)
2014-11-26 15:22:04

toopeicgaming1999 (100 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!