Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 3D / Trouble with loading a model (solved) on: 2007-09-13 02:09:02
Hello,
I tried to load a model into my Program, but the model just doesn't appear Huh. I debugged the whole thing a couple of times and to me it looks like the loading itself is fine. I hope you can help me, because this thing is bugging me for about a week and i can't come up with a solution myself for some unknown reason  Cry

Quote
import java.applet.Applet;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;

import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import com.sun.j3d.utils.applet.MainFrame;

import com.sun.j3d.utils.universe.SimpleUniverse;


import com.sun.j3d.loaders.*;
import com.glyphein.j3d.loaders.milkshape.MS3DLoader;

public class Flasche extends Applet
{
   
   public Flasche()
   {
      setLayout(new BorderLayout());
      GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();
      Canvas3D canvas = new Canvas3D(gc);
      
      add("Center",canvas);
      
      BranchGroup bg = createScene();
      bg.compile();
      
      SimpleUniverse bottle = new SimpleUniverse(canvas);
      bottle.getViewingPlatform().setNominalViewingTransform();
      bottle.addBranchGraph(bg);
      
   }
   
   public BranchGroup createScene()
   {
      BranchGroup root = new BranchGroup();
      Scene scene = null;
      
      Loader loader = new MS3DLoader(MS3DLoader.LOAD_ALL);
      try
      {
      
         java.io.File file = new java.io.File("./flasche.ms3d");
          if (file.getParent() != null)
            if (file.getParent().length() > 0) // figure out the base path
              loader.setBasePath(file.getParent() + java.io.File.separator);
          scene = loader.load(file.getName());

      
      }
      catch(Exception e)
      {
         System.exit(0);
      }
      

      
      
      root.addChild(scene.getSceneGroup());
      
      return root;
   }
   
   public static void main(String[] args)
   {
      Frame mf = new MainFrame(new Flasche(),500,500);
      
   }
}



September 12, 2007, 05:22:26 pm :
solved the problem myself by adding a background, maybe this might help others, who are also new to java3d, because this was never mentioned on any tutorial i read this far

Quote
public BranchGroup createScene()
{
      ... //same code as stated above

       //the new code segment
       Background back = new Background();
       BoundingSphere bounds = new BoundingSphere(new Point3d(0,0,0), 100.0d);
       back.setApplicationBounds(bounds);
       back.setColor(0.0f, 0.0f, 1.0f);
     
       root.addChild(back);
       
     ... //return statement as listed above
}

Finally I can continue my studies on java3d in my spare time Grin
2  Java Game APIs & Engines / Java 3D / Re: Trouble with suns Java 3d tutorial on: 2007-08-24 16:54:43
thanks for your help, it did work:) now it's time to continue my studies on the java 3d tutorial:)
3  Java Game APIs & Engines / Java 3D / Trouble with suns Java 3d tutorial (solved) on: 2007-08-23 19: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)

}
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (31 views)
2014-04-15 18:08:23

BurntPizza (28 views)
2014-04-15 03:46:01

UprightPath (43 views)
2014-04-14 17:39:50

UprightPath (26 views)
2014-04-14 17:35:47

Porlus (43 views)
2014-04-14 15:48:38

tom_mai78101 (64 views)
2014-04-10 04:04:31

BurntPizza (124 views)
2014-04-08 23:06:04

tom_mai78101 (224 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!