Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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 / Problem with 3ds loader on: 2007-10-31 16:26:33
I've tried starfire loader for .3ds files, and I cannot see anything. Yes, it loads OK (no errors) but no image is seen.
here is my code


Quote
import java.awt.*;
import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;
 
import java.applet.Applet;
import com.sun.j3d.utils.applet.MainFrame;
 
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.loaders.Scene;
 
import java.net.URL;
import java.net.MalformedURLException;
 
import com.sun.j3d.loaders.ParsingErrorException;
import com.sun.j3d.loaders.IncorrectFormatException;
import java.io.FileNotFoundException;
 
import com.mnstarfire.loaders3d.Loader3DS;
//import com.microcrowd.loader.java3d.max3ds.Loader3DS;
//import com.mnstarfire.loaders3d.Inspector3DS;
 
 
public class load3d extends Applet
{
      
  private Canvas3D c;
      
       public load3d()
       {
              setLayout(new BorderLayout());
              GraphicsConfiguration config =
              SimpleUniverse.getPreferredConfiguration();
              c = new Canvas3D(config);
              add("Center",c);
              SimpleUniverse u = new SimpleUniverse();
              BranchGroup scene = createSceneBranchGroup();
              u.getViewingPlatform().setNominalViewingTransform();
              u.addBranchGraph(scene);
       }
 
 
 
       protected BranchGroup createSceneBranchGroup()
       {
              BranchGroup objRoot = new BranchGroup();
        
      
              TransformGroup objTrans1 = new TransformGroup();
              Transform3D tr = new Transform3D();
              objTrans1.getTransform( tr );
           // tr.rotX(90.0 * Math.PI / 180.0);
              tr.setScale( 0.7 );
              objTrans1.setTransform( tr );
              TransformGroup objTrans2 = new TransformGroup();
              objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    
    BoundingSphere bounds = new BoundingSphere(
                                      new Point3d(0.0,0.0,0.0), 100.0);
                                      
                                    
              //Set up the global lights
              Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
              Vector3f lDir1 = new Vector3f(1.0f, 1.0f, 1.0f);
              Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
              AmbientLight aLgt = new AmbientLight(alColor);
              aLgt.setInfluencingBounds(bounds);
              DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
              lgt1.setInfluencingBounds(bounds);
              objRoot.addChild(aLgt);
              objRoot.addChild(lgt1);
            
              
             //load the object file
 
              
                Loader3DS loader = new Loader3DS();
    loader.setFlags(Loader3DS.LOAD_ALL);
           
 
                 Scene scene = null;
    try{
    scene = loader.load("3Dimka_Pink_Panther_ready.3DS");
    }
    catch (Exception e)
              {
              scene = null;
              System.err.println(e);
              }
              if( scene == null )
                  System.exit(1);
            
   
              //connect the scenegraph
              objTrans2.addChild( scene.getSceneGroup() );
              objTrans1.addChild( objTrans2 );  
              objRoot.addChild( objTrans1 );
              
    // Set up the background
              Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
              Background bgNode = new Background(bgColor);
              bgNode.setApplicationBounds(bounds);
              objRoot.addChild(bgNode);
    
              return objRoot;
       }
 
 
 
       public static void main(String[] args)
       {
              load3d t = new load3d();              
       }
}


I tried to use obj loader and it work but without the color

what should I do to get the model on screen, is it something wrong with the model if so please show me where I can get a model that works(just for the test).

Does anyone have an example that uses any of the free .3ds loaders that actually WORKS?

THANKS!
2  Java Game APIs & Engines / Java 3D / Re: How can I use loader on: 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.
3  Java Game APIs & Engines / Java 3D / How can I use loader on: 2007-09-30 18:46:10
Hi,
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

code:
Quote
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.media.j3d.*;
 import javax.vecmath.*;
 import java.io.*;

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.media.j3d.*;
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) {
 System.err.println(e);
 System.exit(1);
 }
 catch (ParsingErrorException e) {
 System.err.println(e);
 System.exit(1);
 }
 catch (IncorrectFormatException e) {
 System.err.println(e);
 System.exit(1);
 }

 objRoot.addChild(s.getSceneGroup());
 return objRoot;
 }
 
 public ObjLoad() {
        setLayout(new BorderLayout());
        GraphicsConfiguration config =
           SimpleUniverse.getPreferredConfiguration();

        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.
        simpleU.getViewingPlatform().setNominalViewingTransform();

        simpleU.addBranchGraph(scene);
    } // 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:

java.io.FileNotFoundException: test (The system cannot find the file specified)

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.
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.

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

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

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

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

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

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

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

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

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

toopeicgaming1999 (34 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!