Add custom properties in j3o

Hello everybody.

Maybe i didn’t look well enough, but i didn’t found a way to add custom properties in a j3o scene with the editor. I know that this editor is not finished yet, but i wonder if this will be in it in the futur.

Actually, i need this when i want to add “meaning” to some elements in a scene/object. For exemple:

-“the player can start here” (in a multiplayer game with many map, i would be able to put the “start point location” directly on the map)
-“this is a reactor for this spaceship, with a strenght of XXX and consume Y quantity of Z fuel type”
-“this is a place where you can put some addon of type XXX on this weapon.”

or even
-“the nickname of this weapon is Decimator”
-“the version of this model is XXX”
-“the email of the creator is XXX” (hot ! ^^)

etc.

This is a lot of things i would like to add in my models. Informations related to a specifi subpart of the model or more “global”.

I think that as long as the type of these datas is “standard” (i.e. String, int, long etc), “savable” or “enum” it shouldn’t be too hard to store it, for exemple in the “userdata”.

Right now, the only solution i have is to add an xml file to the scene and put all these informations in it. However, i then have to parse it myself and do the association myself. It’s a bit boring, and it leads to have 2 file instead of one. I know, i can group these two file in one with a “zip” but it will become even slower and even uglier. I would like to avoid this solution if possible.

Did i miss something that is already in the ide ? Is it coming ? Am i dreaming ? Will i find a girlfriend someday ?

Oops ^^

Thanks for reading.

You could write a custom app to edit user data in the J3O file.

@sgold said: You could write a custom app to edit user data in the J3O file.
You can edit user data directly in the SDK.

@bubuche, I wouldn’t mix that much game data and game presentation if I were you. Your additional xml is not that bad IMO, you could make it your primary data source and have the j3o model used for display as an attribute of your game logic object in that xml file.
You can store things in the user data, but it should only be related to display really. Strength, and quantity of fuel are game logic data that should not be stored in a presentation object.

EDIT : I can’t tell for the girlfriend part though…but you can purchase a JME thong and hang around in the street until you catch the eye of a female monkey…

the “.j3o” as an attribute of an xml tag in my xml file was exatcly what i did in the past. Actually, i even added some way to add a script (usually in lua) to handle some specific properties in the model (like the management of bullets for a weapon : how much ammo are used per shot, how much the bullet spread, what they do when they hit etc. It was even a way to add some “procedural-cube” thing on a model). But, then, i had potentially 3 file for only one thing (.lua .xml and .j3o).

You know, i think that when a game is made by many person with a lot of money, when a game is an AAA game or anything big, i think that it’s a good idea to have many files. I mean : you can split the presentation and the logic etc. and it helps you when you want to develop or change your game.

But, when you create a game alone, it can become very painfull to have all of this “well designed” things that you’ll never use anyway. You know, it’s “overengineering”.
I know i shouldn’t mess the logic and the presentation, but here it’s not that stupid. For exemple, if you have a ctf map (like in unreal tournament) you may want to put the information of where the flag is or where people/weapon can spawn. I mean : this IS related to the presentation. I cannot spawn in a wall.
Same thing happens for the ammo : if i have a minigun and a flame thrower, they don’t use the same ammo. It’s not about the logic of the game, it’s about the design of the weapon : i CAN’T plug a barrel of fuel in a minigun, it just doesn’t fit.

Ok, for the strength of the weapon it’s maybe a more “logic” thing. But, for a lot of things, it would be nice to have a way to add some semantic into the model. Instead of just saying “it looks like that” have a way to say “it’s that”.

Maybe you are absolutly right and we shouldn’t put such a thing into the j3o. But, maybe then it would be also nice to have a way in the sdk to add some semantic information on the model, i mean, with a view. When i used the xml file it was a pain in the ass because i needed to create the link between the tag element and the graphic element myself, with my hands. What i am looking for is more something like “right-click on the element > select “edit custom props” in the menu > click the button “add new property” and select a value type in a list > enter a name and a value for the property”.

Actually, i would be a better idea to have a different file for these things, as we would be able to re-generate the j3o without losing everything. But it would still be something very usefull to have this. The xml hand-writed solution is really a source of bugs and a lost of time (write the reader, maintain it). It can be a good idea when a huge society decide the xml format once and for all, but when you are a working alone you appreciate the possibility of adding data directly “in place”.

Maybe adding data in j3o is not a good idea, but adding data to spatials which are stored in j3o is really something that we should consider.

@nehon said: You can edit user data directly in the SDK.

Where is that done at? I was looking for this the other day and I came to the conclusion its just no there. (looking at the proprties windows with a spatial selected in the scene explorer)

@icamefromspace said: Where is that done at? I was looking for this the other day and I came to the conclusion its just no there. (looking at the proprties windows with a spatial selected in the scene explorer)

Right click on the node in the scene explorer tree. Select “Add User Data”.

I like to save some j3o files with just an empty node that has some user data fields predefined and use them as markers in the scene. Then when you load the j3o you can scan the scene and put whatever game elements in place.

@normen said: I like to save some j3o files with just an empty node that has some user data fields predefined and use them as markers in the scene. Then when you load the j3o you can scan the scene and put whatever game elements in place.

You give me hope :slight_smile:
I will need to do something similar to import assets from Neverwinter Nights, particularly the NwN1 player and creature models.

@pspeed said: Right click on the node in the scene explorer tree. Select "Add User Data".

Nice, but how can I view or edit the existing user data?

@axnsoftware said: Nice, but how can I view or edit the existing user data?
Select the Spatial in the SceneComposer and edit it in the Properties window.
@normen said: Select the Spatial in the SceneComposer and edit it in the Properties window.

Thanks!