I have a problem with userdata and I need your help. Here is the situation:
I have a test scene with cubes and objects in it in Blender 2.69. I really just created some random objects for test purposes. I added userdata to the red cube called “redCube” in the Logic View and also in the Object Panel > Custom Properties. The image illustrates it:
I exported the scene with OGRE Exporter which I installed via the SDK.
Here is the result .scene file’s contents. I stripped out the unimportant parts.
[java]<scene previous_export_time=“1392239819.8201144” formatVersion=“1.0.1” exported_by=“kruze” export_time=“1392240274.2753677” >
It look like both the Logic Data properties and Custom Properties user data ended in a user_data node.
I’m trying to get the userdata from the code as follows:
// Loads my scene file
Node scene = (Node)assetManager.loadModel(getScenePath(sceneName));
Spatial redCube = scene.getChild(“redCube”);
redCube.getUserData(“customData”); // returns null
redCube.getUserData(“logicData”); // returns null
I can’t get the userdata from the node redCube because it always returns null.
My question is: Why can’t I get neither of the user datas with the getUserData() function of the node called redCube? What am I doing wrong?
Idk if the importer fully translates the tags, does it work when you import the blend file directly?
Thank you for the quick response.
I just tried loading the blend file directly. (Ugly code I know…)
LoadingResults scene = (LoadingResults)assetManager.loadModel(MAP_PATH.replace("%s", meshName) + “.blend”);
Iterator<Node> it = scene.getObjects().iterator();
I just converted it to j3o, loaded it in the game and I could access the userdata I defined at the Object Panel > Custom Properties section. Thanks for your help Normen!
Which way is more accepted or supported by jme3?
Creating scene in blender, exporting it as mesh.xml and converting it to j3o.
Creating scene in blender, saving as blend file, converting blend file to j3o.
Well honestly we are in a transition from 1) to 2)
Ideally you’d store your .blend file where you want your .j3o to be (probably under Models/) and your textures in the folders you want them to be (probably under Textures/), all in the assets folder. This way you can edit the file in blender using the same texture references and the game and SDK find all data because its in the assets folder and you can convert the .blend by simply double-clicking it. The .blend files will be excluded when you distribute the application so you use the j3o files in your application and can still edit the .blend files while you develop your game.