Blender's linked Objects

Hey Guys,

Recently I have noticed that Blender’s linked Objects do not get imported at all.
Was that an special issue of mine or is it not implemented?

The Problem is, imagine you are modelling a huge castle or house. Your walls are most likely the same for all four directions.

What I would do is to model some walls and chairs (DOODADS) and then link them into a new mesh where I place them. This makes me capable of working faster as every building will have the same wall and copying them would be a mess (especially when I want to change some small detail).

I know that the SceneComposer can do that as well, but blender is more powerful and more comfortable to use.

@Kaelthas I am highlighting you as you are the Blender Guy :smile:

Making each wall a separate object isn’t a good solution anyway so you better bake that to one object which in turn also adds everything to the blender file you import.

Hey @Darkchaos sorry for my very late response, but I was very busy the last two weeks :frowning:

I will take a look into it today because honestly saying - I never thought about linking objects before :smile:

1 Like

@Darkchaos I have made an object and a linked duplication of it (using Alt+D) and everything loaded fine. What blender version do you use ? Is it possible that you uploaded the model so that I can try it ?

1 Like

I think he means linking from one blender file to another.

1 Like

Exactly. Like File->link object or something.
Should be the lasteSt Version already

The problem is that both blender files would have to be accessible via the AssetManager and the links in blender files are not very useful for finding the other blend file in such a context.

OK I get it now.
I will look into blend file how this situation is handled.
If the other file will be inaccessible by the AssetManager then I will simply issue a warning.

2 Likes

This would be very useful. It would allow much more flexibility and allow blender to be used as a scene editor much more than is currently possible.

blender itself allows relative paths, if they are relative you can simpyl try to throw them against the assetloader, if not you could try the name without the path only.

(As Email Replying did not work, here’s the text)

Are you able to open up a user dialog in the BlenderImporter?

Something like: “Cannot find object2.blend, Please locate it”. And then the BlenderImporter starts to import object2 as well as an .j3o and then uses j3o’s linking internally.

btw: What happens, if two blend files would link each other? IF a circular reference is possible by blender, make sure that jme doesn’t go into endless recursion here.

Thanks for doing that
I hope I can contribute to jme as well, once I have some spare time!

OK I have made some progress on the subject :smile:

It still needs some polishing and refactoring work but I guess it will be ready this week.

However I came accross one problem I’d like to discuss with you.
Currently we have two blender loader classes.

  1. BlenderLoader: the original class that loads the whole scene and returns an instance of LoadingResult class (which derives from Spatial) that contains lists of all loaded features (objects, meshes, materials, etc.)
  2. BlenderModelLoader: this one was made to allow to load only objects (Node in jme) from the scene.

The problem is that by default only the second one is available in AssetManager while the first one can be easily used to keep the instances of assets that may not be assigned to any object.
I can of course register the BlenderLoader for the asset manager but that might not help because jme will choose the first matching loader to load data.
Unregistering the loader for a while is in my opinion not good as well because some other threads might use the loader at the same time.

So at the moment I can think of three solutions.

  1. Api will be added to assetmanager that will allow to force the use of particular loaders for the loading to be performed.
  2. We discard BlenderModelLoader and use the first one (but that will require users and JME SDK to adapt to the returned loading result); the loading result should be then moved to the jme-core
  3. We use only BlenderModelManager and load everything including unlinked data, the unlinked data would be stored in the result’s user data.

I am waiting for your suggestions. Meybe someone will find something better than what I wrote down here.

The AssetManager should return a model that is not dependent on any special classes. What you can do for the other things is either add a locator that allows to load with a special mode like “Models/Blender/mymodel.blend?rawData” “Models/Blender/mymodel.blend?material=myMaterial” or simply allow passing the file location directly, bypassing the AssetManager. Having the “LoadingResult” derive from Spatial is probably not a good idea in the first place. A spatial is something that you can attach to the scenegraph, either a geometry or a node.

hm .scene.blend and .blend? bit cheap but should work.

Nah, the assetManager doesn’t support double endings, the support for mesh.xml etc is basically hacked in. The locator solution I proposed earlier would be the right one in this case. The NeoTexture plugin uses it for example. But since this is mostly a tool for development and not for deployment and the AssetManager is for deployment bypassing the AssetManager would be okay as well.

True, blend files shouldnt be used live anyway.

That’s not entirely right.
Think of 3rd Party Mods. It would be nice to be able to directly load those .blend Files to be used or at least supply a tool which converts them to .j3o

As for the other topic, I can’t really help on that. On one hand I guess most people don’t use the Blender Stuff (except from the “SDK wizard”) and with 3.1 there will be some refactoring work in general I guess?
On the other hand it would be a good thing to remain backwards-compatibility and simply add a parameter (like the assetManager-Locator-Enforcing).

I wonder how you usually pass parameters to the BlenderImporter? Can’t you simply add some “followLinks = true” or similar?

The AssetKey is normally used for specifying what to do on import, all its settings can be configured in the SDK as well. I don’t know what you mean by “not entirely right” though? You basically also say that the importer is used during development and not in a deployed game. Tools in the SDK could use all functions of the blender importer and deployed games should load j3o files created using the importer. An important part of having the blender loader as a normal model loader is that the asset paths have to be determined correctly for the import.

What I meant is that it’s not entirely right to say that one is not using the Importer in a deployed game.
Imagine your gamers want to add some models (like their favorite furniture, whatsoever).
Without having a blender Importer in the game, they need to download the SDK, use the Importer there, grab the .j3o and copy it into the Game’s assets.jar
I just wanted to mention that case where it would be good to have the Importer in the game.

In that case I would suggest having an external tool to import these which would then be similar to doing it right in the SDK. The point of the assetManager is providing a system-independent storage system which blender files aren’t made for.