I was wondering how I could locate all the different objects in a scene. A single, .j3o scene made in Blender that has multiple objects on it. Say it had campfires in it, for example. How would I get the location of these campfires so as to attach a fire effect to them in-engine? Thanks
Blender scenes import as a scene graph and TL;DR answer is you traverse the graph.
A more useful answer is that note nodes have names and blender has names on its nodes as well. So you name things in your blend file. This is how i do it, i have a formal naming convention. But note that blender has quite a bit of scene graph structure in its own data. So a object contains a mesh. Both can be named. it pays to inspect the scene in the SDK and get very familiar with how things import.
I see. BlenderLoader won’t get recognized by my SDK. I see in the Docs that it’s a plugin, but the SDK can’t communicate with plugins server, so I went and looked up about downloading it manually but I saw a thread which said the BlenderLoader was now default for JME3. /confused
No I mean the Java Monkey Engine SDK. It is stuck for now with jME 3.0. But the blender stuff is fine and its great for playing around. It imports blender files directly and you get a nice view of the scene and tree UI for exploring how the data is arranged after import.
Sorry to keep asking these understandably silly questions, but it’s hard to find this info. The docs don’t really have a guide, they just semi-explain what it can do, not how to do so (at least not the “Blender” side of the docs). I see the importer has all the objects loaded but how exactly do I access those? I created a node for one of the objects, for example:
But how do I actually “get” this Node? What can I access it through? Thanks
this shows the scene graph. Typically you would transverse this graph programatically. Also i understand the SDK will let you delete/save parts of the sub graph you want. So you can explicitly save your fireplace as a asset in the much faster jME native formats.
If you don’t know how to transverse the scene graph. I would take a step back. And try and make something simple with geometry you can make directly. Put this into the scene graph and manipulate it. There is a lot of little details you will just have to learn on the way.
Also for a blender object i typically group all the meshes into a single mesh. I forget the command. J or something. Splitting and joining meshes in blender is easy. I just constantly forget the commands.
With blenderResource here do you mean the scene.j3o?
I tried using the SceneGraphVisitor and SceneGraphVisitorAdapter to traverse the scene and it’s simple enough, I can get all the names of the objects I have. The issue is still the same I had at the start. This only gives me the name. I’ve tried fiddling around with its methods but I’m probably just stupid because I can’t find anything that will say “Hey, give me the location of that object right there called ‘WeaponsShop’”!
Well I already read up on those before I started delving into the engine. From what I gathered they’re graphs based on a tree-structure where you have parent-child relationships between nodes. the rootNode for example is the parent node every other node in my program. But how does this tell me what method to use to “catch” my objects?
We are simply not going to make progress this way. This is really way back at how to program. Traversing a tree structure IS catching your object. When you have the node that you named in your blender file that is the object.
Sorry but i am at a loss on where the misunderstanding is. And typically means is a lot further back.
Write something very simple in jME with no assets outside say some boxes. have some Boxes move in a group. This will go a long way to finding the gaps in knowledge i think.
Well… I’m confused because I have the traversing working i.e it gets the names of all spatials. But again, there’s a really tiny gap of knowledge: I don’t know the method to get the location. I tried to do all sorts of things like
doesn’t work (NullPointerException). I tried node.getChild(0); that just gives me an ArrayIndexOutOfBounds. I am looking through all the docs and found a tutorial but I still don’t understand very well how to get the location of the object maybe I’ve been going at it too much. It’s 5 am here and I’ve been programming all day. Perhaps a fresh start tomorrow could help…
Yes because you in fact DON’T know how to traverse a graph, this is not a small gap. You are using a visitor pattern and you probably shouldn’t, if you in fact even know what it is. Your probably cutting and pasting code. Sorry but you NEED to work with something MUCH simpler.
It is fairly clear you are new to programming.
Why won’t you follow the suggestion of doing something much simpler with putting a cube in a scene. Then have a set of cubes move together?
I feel you’re underestimating my programming abilities just because I don’t know how to use jMonkeyEngine. I’m not stupid and I’m frankly offended you’d think I’m new to programming, because I’ve been putting a crap ton of effort into it for a few years now…
I’m sorry if I offended you in any way, too. I’ve however solved the issue. It was a very silly oversight on my part, too. I was trying to get the local translation + the name at the same time without realising it. I realise now how stupid that was, probably due to my tiredness at the moment. Here is the code in case anybody were interested in it:
I don’t mean to offend. But you clearly don’t know how to traverse tree or graph data structures. That is not a jME thing. It is a basic programming thing that should come up very early in learning to code.
Also Why won’t you do the simple example i suggest? It will help. Start at the start.