In java3d, de facto standard for 3rd party loaders was Loader/Scene interface. It was designed to handle scenes - together with all extra info like lights, cameras, fog, etc. While it should work perfectly for complex 3ds scene, it was not used in most geometry loaders. getSceneGroup() and getNamedObjects() were only commonly used methods.
My idea is to create some kind of inteface for xith3d, which would focus on model loading - thing which is useful for games, instead of scene renderers/visualizers.
ModelLoader interface would expose methods for loading models from file/url (possibly more than one model per file). It would return a collection of Model instances.
[i]
- It is highly probable that application will like to create more than one instance of given model. In theory, model can be cloned using java3d cloning functionality, but it is not very intuitive as far as attribute/geometry sharing in concerned. Maybe some kind of explicit method like createModelInstance() would be better ? In such case, maybe ModelLoader can return collection of ModelPrototypes, which in turn can be asked for create Model instances (to avoid need to create first model with textures and all, if it is not needed at the moment)
[/i]
Basic methods are more or less obvious - String getName, String getDescription, BranchGroup getMainNode, MapNode> getNamedNodes. We need to think what extra functionality can be exposed here, while staying generic enough.
2 ) I think that most common extra functionality, which cannot be easily described by just scenegraph alone is animation. Exposing any particular method of animation is out of question, but IMHO it would be possible to standarize on concept of Action. Action could be single animation, sound, particle burst - visualization of action. Model would expose methods Set getAllActions, void performAction(String/Action) and enqueueAction(String/Action). Difference between perform/enqueue would be that perform moves to new action almost immedietly (pending any transition animation), while enqueue adds it to queue to be played after currently playing actions end. Action interface would expose getName, isLooping and getDuration - looping means that animation is supposed to be played for longer period of time (walk/bored stance/etc).
3) There is a question of animation routine entry. In java3d, it could just add a Behaviour to scenegraph, which would be run automagically. With xith3d, manual management of updates is preferred. Probably adding method to Model like updateModel(frame_time, other params?) which would perform needed scenegraph updates would do the trick.
4) What with model LOD ? Should it be displayed in Model interface ? Separate getMainNode for various LOD levels ? Single node, with explicit control of LOD level ? Or just hide it inside Model implementation and let the loader code determine which LOD should be used ?
5) What with combined animations ? In some cases damage animation can be applied over walk/run/fight with given percentage. IMHO it is an overkill for common-ground interface, but it should be considered.
6) What with parametric actions ? Some actions are just on/off, some can require a number of parameters ? Real example would be fire tank gun animation, which would require rotation of tower in specific direction and performing fire animation. I think it is also too specific to put into this interface - let the application rotate the tower through named node and then call ‘FIRE!’ action (some kind of projectile will need to be created anyway).
Comments ?