Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (592)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
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  
  How can I use loader  (Read 2362 times)
0 Members and 1 Guest are viewing this topic.
Offline Rahoobah

Junior Newbie

« Posted 2007-09-30 18:46:10 »

I drew the box in 3d max and I want to display it using java 3d
my question are in what format can I export the box and how can I use loader
I tried before and this my tries:
I export the file in .OBJ format

import com.sun.j3d.loaders.objectfile.ObjectFile;
 import com.sun.j3d.loaders.ParsingErrorException;
 import com.sun.j3d.loaders.IncorrectFormatException;
 import com.sun.j3d.loaders.Scene;
 import java.applet.Applet;
 import javax.vecmath.*;

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

 public class ObjLoad extends Applet {

 private String filename = "test";

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

 ObjectFile f = new ObjectFile();
Scene s = null;
 try {
 s = f.load(filename);
 catch (FileNotFoundException e) {
 catch (ParsingErrorException e) {
 catch (IncorrectFormatException e) {

 return objRoot;
 public ObjLoad() {
        setLayout(new BorderLayout());
        GraphicsConfiguration config =

        Canvas3D canvas3D = new Canvas3D(config);
        add("Center", canvas3D);

        BranchGroup scene = createSceneGraph();

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

   // This will move the ViewPlatform back a bit so the
   // objects in the scene can be viewed.

    } // end of HelloJava3Db (constructor)
    //  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 ObjLoad(), 256, 256);
    } // end of main (method of HelloJava3Db)

} // end of class HelloJava3D
and I have this error in the run time: test (The system cannot find the file specified)

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.
Offline darkpegasus

Senior Newbie

« Reply #1 - Posted 2007-09-30 19:28:30 »

It looks like you are trying to load your file as "test".

To test it I would give the full filepath ("C:\images\test..3ds") and specify the file type to start with.

You may need to download a loader specific to your file type since Java only supports a few of the major ones. Here is an example of how I used a 3DS Loader I found on the web somewhere (start a googlin' for one).

Loader3DS myOBJ = new Loader3DS();
Scene myOBJScene = null;
//Attempt to load in the OBJ content using ObjectFile.
try {
   myOBJScene = myOBJ.load("C:\\workspace\\Java3D\\troll.3ds");
} catch (FileNotFoundException e) {
       System.out.println("Could not open OBJ file...exiting");
Offline Rahoobah

Junior Newbie

« Reply #2 - Posted 2007-09-30 20:05:23 »

Thank you darkpegasus ,
I put the full file bath and there was no error , but the box did'nt appear. Embarrassed
I want to use 3DS loader but , I don't know how . Roll Eyes
 Must I download 3DS loader?! and where I can find it ?
and if you have any complete example please give me.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline darkpegasus

Senior Newbie

« Reply #3 - Posted 2007-09-30 20:34:47 »

You'll have to download a JAR file and put it in your classpath. I don't remember exactly where I got mine from but if you do a search for "java 3ds loader" you should find plenty of resources to get that particular format (I don't think you specified exactly which format you were using). If you're using a standard OBJ class you can use the built in loaders.

Here is all of the code I needed to just load an object and add it to the scene. The commented code can be uncommented to load an OBJ file with the standard Java calls.
// Deleted some imports for brevity
import com.microcrowd.loader.java3d.max3ds.Loader3DS;
import com.sun.j3d.loaders.Scene;
import com.sun.j3d.loaders.objectfile.ObjectFile;
import com.sun.j3d.utils.universe.SimpleUniverse;

public class LoaderExample {

public LoaderExample()

   SimpleUniverse universe = new SimpleUniverse();
   BranchGroup group = constructContentBranch();

public static void main( String[] args ) {
   new LoaderExample();

   private BranchGroup constructContentBranch() {
        //ObjectFile myOBJ = new ObjectFile();
        Loader3DS myOBJ = new Loader3DS();
        Scene myOBJScene = null;
        //Attempt to load in the OBJ content using ObjectFile.
        try {
           myOBJScene = myOBJ.load("C:\\workspace\\Java3D\\troll.3ds");
           //myOBJScene = myOBJ.load("C:\\workspace\\Java3D\\troll.obj");
        } catch (FileNotFoundException e) {
          System.out.println("Could not open OBJ file...exiting");
        //Construct and return branch group containing our OBJ scene.
        BranchGroup contentBranchGroup = new BranchGroup();



Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

deepthought (17 views)
2015-06-30 15:39:44

deepthought (20 views)
2015-06-30 15:39:09

deepthought (26 views)
2015-06-30 15:36:52

Za\'Anzabar (20 views)
2015-06-29 05:44:54

TritonDreyja (36 views)
2015-06-24 17:10:40

CopyableCougar4 (33 views)
2015-06-23 00:34:45

BurntPizza (36 views)
2015-06-21 20:36:46

cookiecompiler (80 views)
2015-06-11 15:42:53

cookiecompiler (44 views)
2015-06-11 15:41:14

NegativeZero (71 views)
2015-06-11 09:49:18
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 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‑
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!