How to generate lightmaps and import to Java3D?

Does anyone have experience of generating lightmaps of models created in a 3D-modeling app and importing those lightmaps along with the original textured models into Java3D?

I am using Maya and currently exporting to Java3D as VRML using the Xj3D loader. The only ways that I have been able to think of to get global illumination into my scenes are either to bake the lighting into my single-textures or write a multi-texture export plugin for Maya and a Java3D loader that can handle multitextures. Neither solution works for me and I welcome any tips on solving this problem, even if it means switching to 3DS Max or some other modeling application.

Be very careful of the differences in outputs of a non-realtime modelling tool like Maya and realtime rendering code like the X3D spec (which is implemented courtesy of Java3D). A classic example of this is multitextured bump maps. Maya exports a height map, where realtime rendering engines what normal maps.

The X3D specification includes MultiTexture support, so have a read up on it. Xj3D supports about 90% of that spec.

Ok, thanks, so I might not have to write my own Java3D loader if I use X3D’s mulitexturing support. Can you perhaps also recommend a way to get the data from Maya to X3D?

I guess it might be possible to export two files (possibly in the VRML format) with identical geometry from Maya, one with UV-sets and texture paths to the lightmaps and the other with the same info for the detail textures, and combine the info from both the files into multitexture nodes in a tool like X3D-Edit. However, the VRML-to-X3D converter that X3D-Edit uses does not seem to work correctly on the VRML-files that Maya generates (when I use Xj3D to load the X3D files that X3D-Edit creates from Maya’s VRML files a bunch of “No field: textureCoordinate for: TextureCoordinate” lines are spewed out and the textures are messed up).

Xj3D correctly loads VRML files from Maya directly though, can Xj3D somehow be used to convert from VRML to X3D? or do you know of any other ways to convert models from Maya to X3D?

Btw, I know Maya has support for generating the types of lightmaps that I want. It’s actually quite surprising to see that no one seems to have done these very basic game-tasks in Java before. I hope to contribute some info on the subject in the form of a tutorial or library if I get it worked out during my project (5 weeks to go).

From William
" Btw, I know Maya has support for generating the types of lightmaps that I want. It’s actually quite surprising to see that no one seems to have done these very basic game-tasks in Java before. I hope to contribute some info on the subject in the form of a tutorial or library if I get it worked out during my project (5 weeks to go)."

May people have done these very basec game-tasks in Java before (but I think you mean Java3D). :slight_smile: just not using X3D or VRML because those exporters are limited. We wrote our own loaders for Maya and Creator before that. Both support multitexture as well as many of things not available in typical loaders and free formats (for example special collision geometry)

This is also typical of traditional game production, that is to write your own exporter and loader for your render engine., and it’s how we have been doign it for some time.

Perhaps someone on the forum here knows of other Java3D loaders that support more functionality and that are available on the web other than www.j3d.org’s otherwise it’s roll your own time. Besides writting a loader is one of THE BEST exercises you can do to understand the particular render engine you may be working with.

Good coding!

[quote] Can you perhaps also recommend a way to get the data from Maya to X3D?
[/quote]
Maya 4.5 has an X3D-XML exporter. It was written back in September so it is a fraction out of date, but not much. I believe you can find it in the developer SDK kit.

[quote]combine the info from both the files into multitexture nodes in a tool like X3D-Edit. However, the VRML-to-X3D converter that X3D-Edit uses does not seem to work correctly on the VRML-files that Maya generates
[/quote]
X3D-Edit is a bit out of date relative to Xj3D, that tracks the spec by the minute (at least the CVS version does!). There may be a few bugs though, so send us anything you find that really looks correct and we’ll check it out.

[quote]can Xj3D somehow be used to convert from VRML to X3D?
[/quote]
Yes. In the latest development releases we have an example converter application that allows you to convert both directions and to either of the X3D file formats. They’re still a bit underdevelopment, but they seem to work well enough for all our tests so far.

Shawn: I track all the known loaders at http://www.j3d.org/utilities/loaders.html. If people have sent me a link to their loader, it’s on there. Plenty more than just what is available in the code repository (although I would like to encourage more!).

Wow, Maya does indeed have an X3D exporter (polyX3DExporter) in the devkit. Yes, it is too out of date to be able to export directly to Xj3D, but I can live with having to make small corrections to the files. Worse, however, is that it does not seem to support multitexturing either. When it encounters a layered shader it just exports one of the textures as a standard image texture.

Btw, nice work on Xj3D, it seems to work very well for the great majority of files. I will try its VRML-to-X3D converter on Monday to see if I can use the solution where I export each scene as two single-textured VRML files and manually combine their texture nodes.

Update for the records. I solved the problem by calculating and exporting vertex colors in Maya. I then combine the object color (interpolated from the vertex colors) with the texture color using the modulate mode in my Java3D code.

The bad thing about this solution is that the geometry need to be heavily subdivided in order for this to look good. However, that is acceptable for my application since my scene is small and easily culled (two rooms with a twisted pathway between then) and since it is an exhibition piece that is only supposed to run smoothly on fast hardware (2Ghz P4 with 512 Mb ram and Nvidia Ti4600 128 Mb graphics card).