Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (498)
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  
  New 3DS Loader for Xith  (Read 5629 times)
0 Members and 1 Guest are viewing this topic.
Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Posted 2004-12-12 21:35:53 »

Ok, after trying to get animation working with this loader I can almost taste victory, however... it's still not finished. BUT, I've decided to just release it anyway because it loads models well enough and even supports real shared copies.  Fixing the animation should be a sinch, and as soon as I get an important email it should be finished quickly--all the pieces for animation are basically there...  Also, I'm not sure if it can load models from jar files, but you can give it a shot.

Anyways, this is a port (with permission) of an excellent 3DS loader for Java3D by Josh DeFord that can be found here:
http://www.j3d.org/utilities/loaders/3ds/deford.html

I would also like to thank Kevin Glass for his 3ds loader in xith because it greatly helped with the animation part of the loader (which still isn't finished unfortunetly).

Look at the Example.java file and read the README for instrucitons on how to use it.  Since the original loader used a SceneBase/LoaderBase paradigm, I decided to stick to it but subclassed SceneBase into a TDSModel.  However, this means that you'll have to cast the load() method on Loader3DS all the time like so:
1  
TDSModel model = (TDSModel)(new Loader3DS().load("file.3ds"));


The only classes you need to use are Loader3DS and TDSModel (really just TDSModel).

Everything you need is here.

It's fairly well javadoc'd, I'll try to javadoc everything later. You can find it online here. Or you can compile it yourself with:
'ant javadoc'

Enjoy, I will get animation working soon hopefully.

Features:
* Get individual named Groups in models.
* Real shared copies that work with animation
* Loading using a URL (means jars will load too, see javadoc of Loader3DS)
* Loading using a file name
* Loads models using java.nio (so it's fast!)

* Animation (Semi-working)

Edit (4/27/05): I'm not longer really working on this, anyone is free to take over it.  However if you have any questions about it (such as what all the unorganized comments mean), feel free to ask me any questions. My email is: greg -at- kinostudios -dot- com

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #1 - Posted 2004-12-12 21:53:45 »

Good stuff.

Are you interested in adding this to the org.xith3d group of packages (using the Xith-tk CVS)?

Code in this package group has the advantage of being included in all future Xith3D releases and will be automatically kept up to date with any Xith3D API changes.

Only requirements are:  BSD-like license and half decent javadocs.

Will.

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #2 - Posted 2004-12-12 21:58:00 »

Quote
Good stuff.

Are you interested in adding this to the org.xith3d group of packages (using the Xith-tk CVS)?

Code in this package group has the advantage of being included in all future Xith3D releases and will be automatically kept up to date with any Xith3D API changes.

Only requirements are:  BSD-like license and half decent javadocs.

Will.

Yeah, that'd be great. Take a look at the current level of the javadocs and tell me what you think.  About the BSD-like license, you'll have to help me out there, this is my first "software release" so I'm not familiar with them, all I know is that I kept the GNU lesser public license the original author had, but if there's a problem with that, then just tell me what I should ask him. If it's not too much trouble, could you explain to me the differences in these licenses?

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

JGO Coder


Projects: 2


Fire at will


« Reply #3 - Posted 2004-12-12 22:18:11 »

have a read of this page:  http://opensource.org/licenses/

Look at any Xith3D source file.  You just need to place the copyright/license notice at the top of each source file.

With BSD, you can take the code and do what ever you like so long as you retain the copyright notice and attribution to the original author.  You can use BSD licensed code in a closed source project.

With LGPL, you can call the methods from a closed source project but you can't link the code itself into the project (i.e. no static links.  as this is a C-centric license, for Java it gets a bit blurred).  Any changes you make to the LGPL library you must release (and keep LGPL licensed!).

As you can see, BSD grants you more freedoms regarding the code which makes it more commercial-friendly, but you there are no guarantees that any improvements will be contributed back.

If you have derived your code from an LGPL license, you have to keep it LGPL'd unless you have permission from the original author.

The reason I am insisting on BSD for the org.xith3d package is that I wanted it to be licensed alike to Xith3D itself to avoid confusion (and nasty surprises if you are not careful).

You may still place the LGPL code under the xith-tk CVS, but as a seperate source tree under the /toolkit/ directory.

Cheers,

Will.

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #4 - Posted 2004-12-12 22:38:18 »

Alright, I've sent him an email asking permission and I'll get back to you with his answer as soon as I get it.

Offline DonCrudelis

Junior Member





« Reply #5 - Posted 2004-12-13 11:18:08 »

itistoday, for which 3ds-version is the loader written in?

Alonzo
Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #6 - Posted 2004-12-13 18:18:50 »

Quote
itistoday, for which 3ds-version is the loader written in?

Alonzo

Hmm, I'm not really sure what you mean.  It's loading the format that's specified here.  So far, on all the 3DS files I've tested it on, it has worked.  Most of them have been exported by 3DS Max 6, but it should read most files I think.

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #7 - Posted 2004-12-16 00:58:27 »

Progress on animation is being made, things now move, though I think they might be off-center... I still have to check this.  The problem was actually funny... poorly cast primitives resulting in a time of 0 *doh!*

And guess what... the animation works with sharedcopies!  Cheesy
Once I get everything stable I'll upload them to xith-org (still haven't received an email from the guy) as part of the toolkit, and update them on my site as well, and in the docs section of xith-tk also.

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #8 - Posted 2004-12-18 17:00:30 »

I've updated the code and javadoc some, and added it to the xith-tk documents and file folder.  From now on you should download it from there (or from CVS whenever I get around to putting it there), however,  I will still try keeping the files on my site in sync, and the javadoc is online there for you to look at.  You can try animating your stuff now, but it won't work too well Smiley It only animates position so far, implementing rotation and scaling shouldn't be too hard but I'm waiting for my 3D modeler to give me a nice test file.  Also, I think the position coords are off a bit and probably need to be converted to xith-space.  This will be done soon hopefully, but I'm really busy right now, if anyone can take a look at the code the important classes are:

AnimationGroup -- Basically finished
TimedTransform -- ignore the setTransform method, gonna get rid of it cause the Transform subclasses should manipulate the Transform3D in AnimationGroup directly (see PosTransform).
PosTransform -- Basically finished.
RotTransform -- not yet changed (kev glass's code)
ScaleTransform -- Does it work now?
PositionChunk -- needs coordinate conversion probably
ScaleChunk -- Probably finished?
RotationChunk -- not yet touched

TDSModel -- animations are controlled here by the user.

Edit: OK, I think I might have fixed the position stuff, so now hopefully it's in the right coords.  I've also added Scale animation, but I don't have any models that scale stuff so I can't test it.  It might or might not work.  Either way, that's practically finished, so the last thing to do is the RotationChunk/RotTransform.

Offline aNt

Senior Member




AFK


« Reply #9 - Posted 2004-12-18 19:54:10 »

these are the test model sets i did for kev Smiley
may help:

http://www.topresultmate.com/xith3d/cube_set.zip
http://www.topresultmate.com/xith3d/model_set.zip
http://www.topresultmate.com/xith3d/scaleanim.zip

tip top....
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #10 - Posted 2004-12-18 21:42:16 »

Hmmm... the cube_set, which seem like they could be very useful, don't seem to animate.  I know translation works in other models but in cube_translation.3ds it doesn't.  I tried loading them in the Java3D loader (the one I'm using to port), and it didn't show any animation. Odd...  You sure those animate? I don't have any 3D software other than these loaders to test them.

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #11 - Posted 2005-02-18 19:47:43 »

Ok, so Josh finally replied to my email and said I can release it under the BSD license.  I'll make the changes to the headers in the files soon and then upload them where?

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #12 - Posted 2005-02-18 21:04:19 »

Ok, with my limited knowledge of CVS I think I've successfully commited the source to xith-tk/src/org/xith3d/loader3ds/

Um, and I'd like to also say that I've given up on getting the rotation and scaling animation working, if anyone else wants to give it a shot, be my guest.

Edit: If anyone currently using this loader wants to use it using the xith-tk package, you'll have to change your import statements to reflect the new package name: org.xith3d.loader3ds

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #13 - Posted 2005-02-19 07:36:45 »

Excellent! Grin

That was kind of Josh to allow you a BSD release.

This loader could come in very handy for me.  In a week I will have a bit of time to work on Xith3D and my game, maybe I'll try to help you with the animation stuff.

Do you plan on adding a demo?  It would be great if you used the demo framework I created as it is renderer independant and consistant with the other demos.  I can help out with this if you like.

Cheers,

Will.

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #14 - Posted 2005-02-19 14:10:26 »

I already have a demo Smiley
Just check the 3DSLoader v1.2 in the documents folder in xith-tk or my website. However it uses the old package names.

Right now I'm moving onto some other projects and won't be working much on this loader, but if you have any questions feel free to PM me, or AIM me, or ICQ me Smiley

Offline itistoday

Junior Member




There's too much blood in my caffeine system.


« Reply #15 - Posted 2005-02-20 22:34:33 »

Quote
It would be great if you used the demo framework I created as it is renderer independant and consistant with the other demos.  I can help out with this if you like.

Wait, didn't realize what you meant by this Smiley  What demo framework?

Offline William Denniss

JGO Coder


Projects: 2


Fire at will


« Reply #16 - Posted 2005-02-25 21:46:46 »

Yeah, check out the org.xith3d.test package.

Xith3DTestCanvas is the framework, and Xith3DGeomTest is an example of it in action.

I developed the framework for my game, and then reworked it so it can be used for demos.  The big advantage is that the JOGL/LWJGL display and input stuff is abstracted onto the framework layer, so the demo's can be run with both engines easily.

Will.

Offline antoinelechacal

Junior Member





« Reply #17 - Posted 2005-07-19 10:21:41 »

Could anybody give me  the source code for importing and animating a 3ds file?
Thanks

My name is nobody
Offline Goliath

Junior Newbie





« Reply #18 - Posted 2006-05-15 18:54:28 »

Hello there!

How can i load 3ds scene via your engine with materials and textures correctly?
Offline Amos Wenger

Senior Member




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


« Reply #19 - Posted 2006-05-15 19:04:57 »

Hello there!

How can i load 3ds scene via your engine with materials and textures correctly?
You can use org.xith3d.loaders.loader3ds which is the best of both 3DS loaders.
Just do like that :
Quote
package org.xith3d.test;

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.vecmath.Color3f;
import javax.vecmath.Vector3f;

import org.xith3d.loaders.tds.newdawn.TDSLoader;
import org.xith3d.loaders.tds.newdawn.model.TDSModel;

import com.xith3d.render.CanvasPeer;
import com.xith3d.render.Option;
import com.xith3d.render.RenderOptions;
import com.xith3d.render.RenderPeer;
import com.xith3d.render.jsr231.*;
import com.xith3d.scenegraph.AmbientLight;
import com.xith3d.scenegraph.BranchGroup;
import com.xith3d.scenegraph.Canvas3D;
import com.xith3d.scenegraph.DirectionalLight;
import com.xith3d.scenegraph.Locale;
import com.xith3d.scenegraph.Transform3D;
import com.xith3d.scenegraph.TransformGroup;
import com.xith3d.scenegraph.View;
import com.xith3d.scenegraph.VirtualUniverse;

/**
 * A test for 3DS files
 *
 * @author Kevin Glass
 */
public class TDSTest 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 TDSTest() {
       Frame frame = new Frame();
       
        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( 0, 0, 50),  // location of eye (cubes)
            new Vector3f( 0, 0, 0),     // center of view (cubes)
            new Vector3f( 0, 1, 0));    // vector pointing up
       
        RenderPeer rp = new RenderPeerImpl();
        CanvasPeer cp = rp.makeCanvas(frame, 800, 600, 32, false);
        frame.setSize(800,600);
        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(true);
       
        try {
            long start = System.currentTimeMillis();
            //model = new TDSLoader().load("demo/William.3ds",true);
            model = new TDSLoader().load("demo/jeep1.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);
            //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();
        }
       
        frame.addWindowListener(new WindowAdapter() {
           public void windowClosing(WindowEvent e) {
              System.exit(0);
           }
        });
        frame.setVisible(true);
       
        new Thread(this).start();
    }
   
    public void run() {
       boolean done = false;
       
        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) {
               done = true;
                anim = 0;
            }
            model.setTime(anim);
           
            count++;
        }
    }
   
    public static void main(String argv[]) {       
        new TDSTest();
    }
}

"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 sialivi

Senior Newbie





« Reply #20 - Posted 2006-05-16 19:02:09 »

org.xith3d.loaders.tds.newdawn?

By the way, when you have multiple loaders, with mostly the same method names, wouldn't it be nice to have them return the same types? Like the example above, the loaders load method returns a TDSModel, but the Loader3ds.load() on the other hand returns a Scene...
Offline croft

Junior Member




Java, Java, Java


« Reply #21 - Posted 2006-05-17 01:51:22 »

By the way, when you have multiple loaders, with mostly the same method names, wouldn't it be nice to have them return the same types? Like the example above, the loaders load method returns a TDSModel, but the Loader3ds.load() on the other hand returns a Scene...

Yes.  I adapted some of the loaders, but not all of them, to a common interface:
http://earth.whoola.com:8080/javadoc/xith3d/com/xith3d/loaders/Loader.html

One of the 3DS loaders was adapted and the other was not.

David Wallace Croft / www.CroftSoft.com / (214) 636-3790 m / Advanced Java Game Programming
Offline Amos Wenger

Senior Member




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


« Reply #22 - Posted 2006-05-17 14:21:50 »

org.xith3d.loaders.tds.newdawn?

By the way, when you have multiple loaders, with mostly the same method names, wouldn't it be nice to have them return the same types? Like the example above, the loaders load method returns a TDSModel, but the Loader3ds.load() on the other hand returns a Scene...
I renamed the name of the packages but this is not in the 0.7.1 release, it's only on the CVS. If you use CVS then yes it's org.xith3d.loaders.tds.newdawn

"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.

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

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

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

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

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

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

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

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

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

CJLetsGame (185 views)
2014-04-01 02:16:10
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

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