Spatial and user data in jme3

Is there a way to associate user properties to Spatials in JME3? Reading the source code i would say no. Maybe the feature is planned but not yet implemented. If so, would it be possible to have a different system than what we have in JME2? Maybe something like:


Serializable getUserData(String)
Serializable setUserData(String, Serializable) //returns the replaced value or null
List<String> getUserDataKeys() // returns Collections.emptyList<String>() if actual user data map is null

Hm, sounds like an ok idea but I am not quite sure if something like this should be at such a low level already… This one should definitely be there for game entities etc. later, but I dont think that they will necessarily always extend Spatial… On the other hand if the user wants to do more with the spatial it should be easy enough to just extend it with these functions…

Bu as said, dunno… :slight_smile:



Cheers,

Normen

Actually it is not easy to extends Spatial, since nearly half of jme is based on it, i would need to change all imports to my own Spatial then, and break update compability.



But i don#t think there is a need for a String, i more suggest a UserPointer to a undefined object.

(For examply I could link my nodes/spatials with the logical entity, and therefore quickly access it without having to search for the logicentity responsible)





(I however would not need the ability to be serialized then, as i would serialize my logic entity, and let it respawn the jme one when instanced)

Seems spatial can't be used like old times?

I encounterd the problem, while converting from jME2



Geometry, Spatial and Node can't be used together with a simple "newclass = (class) oldclass"

What happend?

DarkPhoenixX said:

What happend?

jme3 has been rewritten from scratch and so misses some features of jme2 and some things are done differently. You can use the deepClone or clone methods to duplicate spatials.

I’d love to be able to associate an object of my choice with a Spatial. Doesn’t look like it would be a difficult thing to add.

No it isnt, but as soon as its in developers will be using it so we a) have to think about if we want this feature in this form and b) think about how to implement it best if we want it :slight_smile: For now, you can always extend your Spatial of choice.

Cheers,

Normen