How can I easily add reference points to a j3o scene?

I need to be able to mark specific points on my j3o scene for future reference. For instance, marking an enemy spawn point or where a road is.

Is there some way to do this without manually defining each point in the code (preferably using SceneComposer)?

Edit: I accidentally closed the SceneExplorer window and can’t get it back. :stuck_out_tongue_winking_eye:
How do I open that back up…?

I think creating blank nodes along the scene, you can use sdk scene composer to do so.

1 Like

Also I think it’s common enough to place some kind of marker geometry and then tag them with user data so that they can be cleaned up on load (and turned into whatever game structure is necessary).

Especially common for entity-component-system (ECS) based games to have some kind of entity placement scheme like this.

1 Like

In my case, I have developed my ECS-based scene editor, I use it to place entities on the scene, and on export, it generates a JSON file that includes the object type, spawn-position, and an optional tag name.

1 Like

How do I tag the data, and how will the code get that data from the j3o file?

https://javadoc.jmonkeyengine.org/v3.4.0-stable/com/jme3/scene/Spatial.html#getUserData-java.lang.String-

2 Likes

How do I use getUserData() on my scene to get specific geometries contained in the scene as well as their locations?

I’m not exactly sure how getUserData() works, since there isn’t documentation for it. You’d have to explain the finer points for me (like which keys I should use to get what).

UserData is just that, it is your data. Just a HashMap (probably, didn’t check, but at least works as such) on a spatial. So you make your own keys.

1 Like

In the scene editor. Set user data on your geometry or whatever.

When you load your j3o, traverse the scene… with a scene traverser (don’t have time to google the javadoc for you at the moment). Find the geometry with your user data. Do stuff with it.

What it is is up to you.

1 Like