kev 3ds loaders setBounds

Seems to be the latest xith, 805,000 in size (well, just over). I thought default background colour was still grey, just you can now set a background colour using background node?

Kev

We found the problem causing the loss of RGBA files transparency and the double sided problem (*).

Kev’s just uploaded a new version of the loader which works fine here, now… :slight_smile:

Thanks! :slight_smile:

(*) It’s been because Kev has got a “.” in his classpath, whereas many others, including Ant and me, don’t…

oops- my code is setting it to black… sorry. ;D
old stuff in there that didnt work- all of a sudden now works… lol

scrub that animation works cool- seem to flash on the loop frame here - but im sure i will find thats something im doing…

oh a note of transparent textures. should the transparent part be a different image as a mask? not an image with an aplha? same with bump mapping. this give more power for changing the textures and mixing bumps with other maps. would be better then the way we have it at present.

faces: kev are these still front and back faceing? if so it seems if you render both sides of the face- the inner facing face is white (being 3ds seems to use ambient color as its main colour). this seems to show when the object gets smaller. so i would say it would be better just the render the front facing polygon.

well heres a 3ds file with ‘animation’, ‘transparent texture layer’, ‘bump-map texture’, ‘ambient color’ with vector smoothing on the red main case area of this strange shape.

the green ends are just a ‘transparent serface’ with an 'ambient color; value.

also the red texture has:
diffuse: 0.736
specular: maxed.

nothing seems to happen when setting diffuse and specular. but this could just be me.

file: http://www.topresultmate.com/xith3d/better.zip

looking good…

[quote]oh a note of transparent textures. should the transparent part be a different image as a mask? not an image with an aplha? same with bump mapping. this give more power for changing the textures and mixing bumps with other maps. would be better then the way we have it at present.
[/quote]
Many artists prefer to have a RGB texture file (24 bpp) plus an Alpha mask file (8 bpp) instead of one RGBA (32 bpp) file.
Aside other formats the Lightwave file format does allow this for sure. I am not sure about 3ds however (which is quite old and not developed anymore, because today they user their internal .max format).
So if the 3ds file format doesn’t know RGB + A in different files we’re at a loss with 3ds for that point; as with Multitextures. :frowning:

[quote]faces: kev are these still front and back faceing? if so it seems if you render both sides of the face- the inner facing face is white (being 3ds seems to use ambient color as its main colour). this seems to show when the object gets smaller. so i would say it would be better just the render the front facing polygon.
[/quote]
With the newest version the single sided models should be loaded as single sided… With some test models I get correct results now, but there’s always strange things out there. :wink:

[quote]file: http://www.topresultmate.com/xith3d/better.zip
[/quote]
This causes the loader to throw a class cast exception here…


...
Skipping Chunk: 1201
Frame Count: 200
Skipping Chunk: b009
Translation key frames: 1
        Translation key frame: 0 : (0.0, 0.0, 7.7078085)
Rotation key frames: 1
        Rotation key frame: 0 : (1.0, 0.0, 0.0, -0.0)
Scale key frames: 1
        Scale key frame: 0 : (1.0, 1.0, 1.0)

java.lang.ClassCastException
  at org.newdawn.xith3d.threeds.SclTrackProcessor.processs(SclTrackProcessor.java:86)
  at org.newdawn.xith3d.threeds.TDSLoader.processChunk(TDSLoader.java:1
  at org.newdawn.xith3d.threeds.TDSLoader.load(TDSLoader.java:93)
  ...

I’m having trouble with the 3ds loader when it comes to packing all to one big JAR.

Loading resources in general I handle with InputStreams, so my code works with the resource files being stored in the OS filesystem (next to the classes folder) as well as in a big JAR. Say the routine handling file accesses is: InputStream fetchStream(String filename)

The file structure at dev time is:


|  JustCode.jar  or  classes directory holding all the .class files
|
+-- Models
 ..... Tube.3ds
 ..... tube.png

Running the code does:


String path = "Models/";
String file = "Tube.3ds";
InputStream bistream = fetchStream(path + file); 
TDSLoader dsloader = new TDSLoader();
TDSModel  model    = dsloader.load(path, bistream, true);

This works fine when the resources are in the OS’ filesystem. However it fails at loading textures when the code and resources is in one big JAR. The JAR structure is:


+--- myPackageName
| ..... mainclass.class
|
+--- Models
 ..... Tube.3ds
 ..... tube.png

How do you master this?

PS: When I load textures manually with Xith3d I don’t use RegisterPath/Jar because I always give an InputStream to Xith3d, no file name strings.


import java.awt.image.BufferedImage;
import java.io.*;

public class ImageLoader {

  public static final BufferedImage loadImage(String textureLocation){
    BufferedImage bufferedImage = null;
    ClassLoader  fileLoader  = ImageLoader.class.getClassLoader();
    InputStream  input       = fileLoader.getResourceAsStream(textureLocation);

    try {
      if(input == null)
         input =  new FileInputStream(textureLocation);
      bufferedImage = javax.imageio.ImageIO.read(input);
    }
    catch( Exception e){
      try{
        bufferedImage = javax.imageio.ImageIO.read(new java.io.File(textureLocation));
      }catch( Exception newE){}
    }
    return bufferedImage;
  }
}

This example works in every case out there :slight_smile:

[quote]This example works in every case out there :slight_smile:
[/quote]
Yes. :slight_smile: My mentioned method “InputStream fetchStream(String filename)” works similar. And it works, but…
The 3ds loader in my above example manages to fetch the “File.3ds” correctly (because I give an InputStream of that file to one of Kev’s three loading methods) but then the 3ds loader fails when it calls Xith3d to load that PNG bitmap… :frowning:

When the files are on the filesystem the loader works, but when I pack all into a JAR my call to the 3ds-loader fails with an texture-loading-exception (“can’t find … blabla”).

My calls to Xith3d in one JAR work fine…

i get an error also with my models with the new loader. i have no idea why- the old loader worked fine. :(. humm… ok will debug with kevs src…:slight_smile:

shame about the 3ds not letting us use different file refs to the different layers on the model.

heres the stacktrace on the loading of my model:

java.lang.ClassCastException
at org.newdawn.xith3d.threeds.SclTrackProcessor.process(SclTrackProcessor.java:86)
at org.newdawn.xith3d.threeds.TDSLoader.processChunk(TDSLoader.java:126)
at org.newdawn.xith3d.threeds.TDSLoader.load(TDSLoader.java:93)

hummm :frowning: - must be my model if yours are working Bombadil. Mind you i do get this error with the character.3ds:

java.lang.ArrayIndexOutOfBoundsException: 64
at org.newdawn.xith3d.threeds.SmoothGroupProcessor.process(SmoothGroupProcessor.java:57)
at org.newdawn.xith3d.threeds.TDSLoader.processChunk(T.DSLoader.java:126)
at org.newdawn.xith3d.threeds.TDSLoader.load(TDSLoader.java:93)

java.lang.ArrayIndexOutOfBoundsException: 64

bling bling. not sure why it all worked in the last loader version. also your Tube model has transparency in the new version dude. and the jeep1 loads ok.

tops

Bing! New vesion.

The reason you model only failed was because of animation. Fixed.

The reason the character.3ds model failed was because of all the hacking being done in the smoothing groups stuff.

Kev

u the man kev :)- works and looks great

bump :slight_smile:

[quote]I’m having trouble with the 3ds loader when it comes to packing all to one big JAR.
[/quote]
The JAR structure is:


+--- myPackageName
| ..... mainclass.class
|
+--- Models
 ..... Tube.3ds
 ..... tube.png

Would like to pack my classes plus resources into one JAR, like quoted above (so the textures don’t stay in the root path of the JAR, but in sub-folders).
How do you master this?

Runing outside one big JAR (but with same sub-folders) works with the following:


String path = "Models/";
String file = "Tube.3ds";
InputStream bistream = fetchStream(path + file); 
TDSLoader dsloader = new TDSLoader();
TDSModel  model    = dsloader.load(path, bistream, true);

To clarify (because my English is strange, sorry): I’ve no problem with loading resources within one big JAR and within the filesystem, but to tell the 3ds-loader where to find the textures which the model will need (you just give the model’s path + name to the constructor of the loader)…

Packing your application plus resources inside one big JAR work great as long as you don’t put the 3dsLoader (xith-3ds.jar) into your JRE/…/Ext folder (which I did; I’ve got the Xith.jar in there, so I can use it happily from any project without any path adaption).

Because of this:
org/newdawn/xith3d/threeds/TexMapProcessor.java :


private Texture loadTexture(String filename) {
  URL realURL = TexMapProcessor.class.getClassLoader().getResource(filename);
  ...
}

So when:

  • the org/newdawn/… classes tree is part of the application’s JAR file (including the resources),
  • or the Application.jar’s manifest includes the xith-3ds.jar,
  • or you call your application via something like: java -cp App.jar;xith-3ds.jar,
    everything works fine. Because class.getClassLoader() is relative to the resource’s tree then.

How do you guys out there use libs like Xith.jar, xith-3ds.jar, etc, with more than one project at development time in a handy way?

[quote]Packing all inside one big JAR works great as long as you don’t put the xith-3ds.jar into your JRE/…/Ext folder (which I did; I’ve got the Xith.jar in there, so I can use it happily from any project without any path adaption).

Because of this:
org/newdawn/xith3d/threeds/TexMapProcessor.java :


private Texture loadTexture(String filename) {
  URL realURL = TexMapProcessor.class.getClassLoader().getResource(filename);
  ...
}

So when:

  • the org/newdawn/… classes tree is part of the Application’s JAR file (including the resources),
  • or the Application.jar’s manifest includes the xith-3ds.jar,
  • or you call your App by something like java -cp App.jar;xith-3ds.jar,
    everything works. Because class.getClassLoader() is relative to the resource’s tree then.

How do you guys out there use libs like Xith.jar, xith-3ds.jar, etc, with more than one project at development time in a handy way?
[/quote]
heed my warning - don’t put .jar files which are constantly updated or have anything to do with image loading in your jre/lib/ext! I used to recommend this for xith3d.jar in the installation tute but due to wasting an hour and nearly going bald I now strongly recommend against it. It does bad things to JWS and other things as well (and coincidentally the problems were always with image loading).

JOGL/JOAL .jar’s are perfectly fine IMHO as they are pretty static (for our needs), as is vecmath, junit, log4j, etc… Although don’t forget that they are there and may need updating occasionally (jogl and joal especially).

So how do I get around the problem? There are two good ways I know - once is have all the checked out cvs projects in the one directory and reference the libs like so: …/…/xith3d/lib/xith3d.jar - or create a lib directory in your project and symlink the nessesary libs (if you use linux).

Will.

sorry to bring this up kev :slight_smile: but scale animation dont seem to work… heres a model that scales over 100 frames.

http://www.topresultmate.com/xith3d/scale.3ds

Being at models which can cause trouble… :slight_smile:

I’ve loaded the Jeep from Kev’s archive and grouped all the wheels to the base group (with DeepExploration). When exporting the model it can’t be loaded again with the 3dsloader… The following stacktrace is being printed:

The modified Jeep I’ve put in this Zip archive.

Well, maybe DeepExploration corrupts something? Or maybe it’s really just a small thing at the loader… (I’m not very familiar with that code :wink:
Ant: would you mind loading my modifed Jeep with your 3dStudio/Maya please, to see if it’s correct?

PS: Thanks a lot to Kev and Will for the help with the former Jre/…/Ext/ lib jar trouble.

make sure u have the new xith3d build- build the src yourself with ‘ant’ the xith3d.jar form cvs is out of date. build the cvs dude… the jeep and everything works sweet here…

just scaling on animation dont work :frowning: so no explotion animations for me as yet… bish bosh kev- u no u want to make the don loader of um all… an so far i think it rocks!

Moo! This url don’t work…

http://www.topresultmate.com/xith3d/scale.3ds

Kev

[quote]make sure u have the new xith3d build- build the src yourself with ‘ant’ the xith3d.jar form cvs is out of date. build the cvs dude…
[/quote]
Yes I’ve done so 2-3 days ago: compiled the entire Xith from CVS. :slight_smile:

[quote]the jeep and everything works sweet here…
[/quote]
The original Jeep.3ds from Kev’s loader archive.zip works, that’s right. But what about my modified one (with group hierarchy)? Please find it in this Zip archive.
Does it load at your PCs? I see the above mentioned error message then…

Fixed the jeep thing (at least it loads now). Although the wheels and steering column have been moved away from the main body, is that right?

Give me dat scaling 3ds… come on! :slight_smile:

Kev