New 3DS Loader for Xith

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:

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

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.

[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.
[/quote]
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?

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.

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.

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

Alonzo

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

Alonzo
[/quote]
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.

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! :smiley:
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.

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 :slight_smile: 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.

these are the test model sets i did for kev :slight_smile:
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…

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.

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?

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

Excellent! ;D

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.

I already have a demo :slight_smile:
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 :slight_smile:

[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.
[/quote]
Wait, didn’t realize what you meant by this :slight_smile: What demo framework?

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.

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

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 :