How to re-create a scene graph, when not using JME serialisation?

I do not really feel comfortable with putting my “domain information” into a “String-to-whatever” map within the Spatials. There are several reasons for this. Firstly, by using a generic map, one looses most of the benefits of “static typing”; it is likely that the wrong data-type could be used in some places. Also, NullPointerException are a lot easier to produce, then when using primitive fields. And, all those primitive wrappers uses more memory and cause more work for the GC, then primitive fields. I suppose this all makes me “old school”.

But most importantly, I want to keep my domain model separate from the JME API, so I can reuse it on the server, without needing to deploy the engine there too (I am aware this means I need to write my own networking code), in exactly the same way I would not want to deploy a Swing GUI jar on my server either.

I figured at least I could define my own domain interface similar to Control, and have a standard wrapper for all “entities” implementing Control and delegating to my domain model, to keep both sides linked at runtime. OTOH, it would probably be possible to inverse the relationship as well. Idk atm what makes most sense for me.

So my question is this: if you have a completely separate domain model, and the domain model is the “authoritative” source of all information (I mean in particular, the position, scale, and orientation of all Spatials), how does one go about re-creating the scene on “re-load”? Is there some kind of particularly appropriate pattern? Alternatively, I could serialize both (with different serialization APIs) the scene and the domain, but I would need to somehow re-connect them on re-load.

Looking at the side bar (Top Help Topics), I just remembered about the Physics. I guess decoupling the domain model from the engine means not being able to use the built-in physics support. But the physics will have to run on the server anyway, so probably it’s not an issue either, apart from the fact that I cannot implicitly produce the physics model from the mesh model, since the server hasn’t got the mesh model (or at least, not the JME mesh model).

You create them like you would if you would not deserialize them from some data…?

Yeah, I would think if your domain model is already truly separate then your code should already be used to creating visual elements from the domain model and managing them. So load the domain model, construct the scene graph from it… just like you would if objects appear later.

Yeah, if I can create individual “domain objects” (entities) and then for each one create a visual representation, at any point in the game, then I can just go over all my objects and call the same code. What I was wondering was, if there is some “trick” that makes this more efficient when a large number of objects are being created at the same time (the whole scene). I suppose I could put an upper bound on the creation per update cycle, and start with the nearest ones, so that the scene builds progressively.