Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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  
  3DS Loader from Xith Toolkit problem  (Read 2603 times)
0 Members and 1 Guest are viewing this topic.
Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Posted 2004-08-24 10:14:28 »

I have a problem with Xith3D toolkit, the 3DS loader part.
       
       I want to load a model created with Wings3D and with a BMP or JPG texture ( they both won't load ).
       
       My texture is created with the Gimp.
       
       I launch my test program with the following command, under Linux :
       java -classpath../libs/xith3d.jar:./xith-3ds.jar:./ TDSTest2
       
       Here is the program output :
       Available 0: GLCapabilities[DoubleBuffered: true, Stereo: false, HardwareAccelerated: true,DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0,Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS:false 0 Score: 132
       Available 1: GLCapabilities[DoubleBuffered: true, Stereo: false, HardwareAccelerated: true,DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0,Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS:false 0 Score: 132
[...]
       Available 23: GLCapabilities[DoubleBuffered: false, Stereo: false, HardwareAccelerated: true,DepthBits: 0, StencilBits: 0, Red: 8, Green: 8, Blue: 8, Alpha: 8, RedAccum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS:false 0 Score: 1944
       Chosen index: 0
       Chosen capabilities:
       GLCapabilities [DoubleBuffered:true, Stereo: false, HardwareAccelerated: true, DepthBits: 24,StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 0, Red Accum: 16,Green Accum: 16, Blue Accum: 16, Alpha Accum: 16 ] MS: false 0
       Load took: 0.073 seconds
       Init GL isnet.java.games.jogl.impl.x11.X11GLImpl
       OpenGL Renderer = GeForce2MX/AGP/SSE/3DNOW!
       OpenGL Version = 1.5.1 NVIDIA61.06
       OpenGL Vendor = NVIDIA Corporation
       OpenGL Extensions =GL_ARB_imaging GL_ARB_multitexture GL_ARB_point_parameters
[...]
GL_SUN_slice_accum

       
       After that, i have a black window on my Linux desktop with nothingdisplayed on it.
       
       I tried the same model without textures : it's all right.
       
       The texture is in the right directory and the program find it,otherwise it would display the message "texture not found".

Here's the source code ( nothing very interesting ) :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
import com.xith3d.scenegraph.VirtualUniverse;
import com.xith3d.scenegraph.View;
import com.xith3d.scenegraph.Locale;
import com.xith3d.scenegraph.BranchGroup;
import com.xith3d.scenegraph.Canvas3D;
import com.xith3d.scenegraph.DirectionalLight;
import com.xith3d.scenegraph.AmbientLight;
import com.xith3d.scenegraph.TransformGroup;
import com.xith3d.scenegraph.Transform3D;

import com.xith3d.render.RenderOptions;
import com.xith3d.render.Option;
import com.xith3d.render.CanvasPeer;
import com.xith3d.render.RenderPeer;
import com.xith3d.render.jogl.RenderPeerImpl;

import javax.vecmath.Vector3f;
import javax.vecmath.Color3f;
import java.util.ArrayList;

import org.newdawn.xith3d.threeds.TDSLoader;
import org.newdawn.xith3d.threeds.model.TDSModel;

/**
 * A test for OBJ files
 *
 * @author Kevin Glass
 */

public class TDSTest2 implements Runnable {
    private View view;
    private double lightAngle;
    private double modelAngle;
    private float anim = 0.0f;
    private DirectionalLight light;
    private TransformGroup tg = new TransformGroup();
    private TDSModel model;
   
    public TDSTest2() {
      VirtualUniverse universe = new VirtualUniverse();
        view = new View();            
        view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION);
        universe.addView(view);
        Locale locale = new Locale();
        universe.addLocale(locale);
       
        view.setBackClipDistance(500.0f);
       
        // setup view        
        view.getTransform().lookAt(
            new Vector3f( 20, 10, 0),  // location of eye (cubes)
            new Vector3f( 0, 10, 0),     // center of view (cubes)
            new Vector3f( 0, 1, 0));    // vector pointing up
       
        RenderPeer rp = new RenderPeerImpl();
        CanvasPeer cp = rp.makeCanvas(null, 800, 600, 32, false);
        Canvas3D canvas = new Canvas3D();
        canvas.set3DPeer(cp);
        view.addCanvas3D(canvas);
       
        RenderOptions options = new RenderOptions();
        options.setOption(Option.USE_SHADOWS,true);
        options.setOption(Option.USE_LIGHTING,true);
       
        cp.setRenderOptions(options);
       
        BranchGroup root = new BranchGroup();
        locale.addBranchGraph(root);
       
        Color3f ambientColor = new Color3f(0.5f, 0.5f, 0.5f);
      AmbientLight ambientLightNode = new AmbientLight(ambientColor);
      root.addChild(ambientLightNode);
       
        light = new DirectionalLight(true,new Color3f(1f,1f,1f),new Vector3f(0,0,1));
        root.addChild(light);
       
        TDSLoader.setDebug(false);
       
        try {
            long start = System.currentTimeMillis();
            //model = new TDSLoader().load("model/character.3ds",true);
            //model = new TDSLoader().load("model/cube_set/cube_rotation.3ds");
            //model = new TDSLoader().load("model/jeep/jeep1.3ds",true);
            //model = new TDSLoader().load("angel/angel.3ds",true);
            //model = new TDSLoader().load("angel/chalice.3ds",true);
            //model.setShowBounds(true,true);
          model = new TDSLoader().load("model/WA/William.3ds",true);
            //tg.addChild(model);
           
            //model = new TDSLoader().load("model_set/redbox_max.3DS",true);
            //model = new TDSLoader().load("jeep2/jeep.3ds",true);
            //model = new TDSLoader().load("jeep2/scale.3ds",true);
            //model = new TDSLoader().load("others/Tube.3ds",true);
            //model = new TDSLoader().load("samples/Kugel.3ds",true);
            //model = new TDSLoader().load("samples/building09.3ds",true);
            //model = new TDSLoader().load("scaleanim/output.3ds",true);
            System.out.println("Load took: "+((System.currentTimeMillis() - start) / 1000.0)+" seconds");
           
            tg.addChild(model);
            //model.setShowBounds(true,true);
            root.addChild(tg);
        } catch (Exception e) {
            e.printStackTrace();
        }
       
        new Thread(this).start();
    }
   
         
    public void run() {
        int count = 0;
        while (true) {
            try { Thread.sleep(10); } catch (Exception e) {};
         
            view.renderOnce();
            lightAngle -= 0.01;
            Vector3f dir = new Vector3f((float) -Math.cos(lightAngle),0,(float) Math.sin(lightAngle));            
            //light.setDirection(dir);
           
            modelAngle += 0.01;
            Transform3D yrot = new Transform3D();
            yrot.rotY((float) modelAngle);
            Transform3D xrot = new Transform3D();
            //xrot.rotX((float) modelAngle);
            //xrot.rotX((float) -Math.PI/2);
            yrot.mul(xrot);
            tg.setTransform(yrot);
           
            /*anim += 0.005f;
            if (anim > 1) {
                anim = 0;
            }
            model.setTime(anim);*/

           
            count++;
        }
    }
   
    public static void main(String argv[]) {        
        new TDSTest2();
    }
}

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline aNt

Senior Devvie




AFK


« Reply #1 - Posted 2004-08-24 10:50:20 »

is your model and texture in a .jar?
Offline aNt

Senior Devvie




AFK


« Reply #2 - Posted 2004-08-24 10:58:51 »

if u want the models off the file system try this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public static TDSModel loadBuilding(String bFileName) {
    try {
      TDSLoader tload = new TDSLoader();
      tload.setDebug(false);
      File f = new File(bFileName);
      TDSModel model = tload.load(f.getParent() + "\\", new FileInputStream(f), true);
      return(model);
    } catch (Exception ex) {
      ex.printStackTrace();
      return(null);
    }
  }


hope that helps?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2004-08-24 11:00:04 »

Are the material settings on the model setup. What colour for instance is the model? How bright is the material? etc...

Incidently, do the packaged models work for you, e.g. the jeep?

Kev

Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #4 - Posted 2004-08-25 06:51:41 »

My model and texture aren't in a .jar archive. They are in the directory model/WA.

I don't really understant the piece of code posted by aNt. If it for load models and textures in a .jar archive ?

I can send you the 3DS file, if you want.

The jeep model is running correctly. A curious thing is that if I load the model in Wings3D, when it import the texture, it says :
Corrupt JPEG data: 15 extraneous bytes before marker 0xee
Is it because my texture model isn't corrupted that it won't load ?  Huh So strange !

I will try to apply the texture jeep1.jpg on my model and see what the 3DS loader do.

The model's color is white and the texture William.jpg is covering the entire model.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #5 - Posted 2004-08-25 06:52:49 »

I forgot to say that the texture jeep1.jpg is loaded correctly by Wings3D even it's corrupted.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline aNt

Senior Devvie




AFK


« Reply #6 - Posted 2004-08-25 11:40:01 »

my code is for loading from a directory not a .jar. the
code in Kevs demo works with .jar's (handy later in the
game).

make sure your textures are of sizes 128*128, 512*512, 1024*1024 etc..

u can send me over your model- i can try it in my loader
tests [see your messages]. i dont use Wing3D mind-
more of a Maya dude.
Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #7 - Posted 2004-08-26 16:55:56 »

Haven't had a chance to try this yet, will do very soon (i.e. now Wink)

Kev

Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #8 - Posted 2004-08-26 17:07:13 »

aNt,

your code is running correctly with the jeep model but not with my model.

I think I will change for MD2 models.

Is it a good idea to use MD2 models for characters AND other objects like the earth surface, trees, rocks, and so...

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #9 - Posted 2004-08-26 17:22:36 »

Character models yes, static models no..

Could you send me the non-textured model, the textured model appears to have no triangle-mesh information in it (no chunk 0x4000)

In addition, if you want to change for static models, how about ascii 3ds or OBJ?

Kev

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #10 - Posted 2004-08-27 10:04:15 »

OK, I send you the non-textured model.

Why should'nt I use MD2 format for static models ? it's not a problem to have just one frame in the model ?

Anybody knows if there is a good modeler/animator for Linux that edit MD2 models ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #11 - Posted 2004-08-27 10:07:02 »

Is it possible to texture a model in the OBJ format ?

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
Offline kevglass

« JGO Spiffy Duke »


Medals: 208
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #12 - Posted 2004-08-27 11:57:20 »

You'll get a bit overhead with MD2 for single frame model. No real hardship its just not what they were designed for..

OBJ - texture, yep.

Kev

Offline Amos Wenger

Senior Devvie




Everything's possible, but not everything's fun...


« Reply #13 - Posted 2004-08-28 10:05:29 »

Okay. Thanks everybody for all your answers.

"Once you start working on something, don't be afraid of failure and don't abandon it. People who work sincerely are the happiest"
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.

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

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

toopeicgaming1999 (10 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (26 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!