Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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  
  Problem with 3ds loader  (Read 1828 times)
0 Members and 1 Guest are viewing this topic.
Offline Rahoobah

Junior Newbie





« Posted 2007-10-31 17: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!
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #1 - Posted 2007-11-07 16:32:09 »

http://www.flyingguns.com uses Starfires 3DS loader successfully.

If you like, I can give further hints where it is actually used in the source tree. Look for 'scene3d' project as a small-scale example.

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (39 views)
2013-05-17 21:29:12

alaslipknot (47 views)
2013-05-16 21:24:48

gouessej (76 views)
2013-05-16 00:53:38

gouessej (76 views)
2013-05-16 00:17:58

theagentd (84 views)
2013-05-15 15:01:13

theagentd (78 views)
2013-05-15 15:00:54

StreetDoggy (120 views)
2013-05-14 15:56:26

kutucuk (144 views)
2013-05-12 17:10:36

kutucuk (144 views)
2013-05-12 15:36:09

UnluckyDevil (154 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.125 seconds with 21 queries.