Hello everybody…
I was thinking of a new way to export our models or scenes within jme3 (file type), and what better than a new file format (in this chaos JSON).
A while ago I created something similar, only with another json library, although
it worked partially, unfortunately it had several errors (after all, I was a newbie ).
Currently we can export in 2 formats; binary and xml (please correct me if this is incorrect). The idea is to create this exporter and importer for scenes saved with json.
You can see the code I have generated for this new exporter here. At the moment the code is dirty…
I did some testing and it’s pretty stable:
Blue is a cube created from code, red is a cube loaded from a json file.
I haven’t submitted any PR yet, what do you think of this idea?
[ NOTE ]
This crazy idea is simply to have another option (format) when saving our worlds made with jme.
[ EDIT ]
We would have an output for the objects as follows:
{
"metadata": {
"+/jMe3.Signature": 1246577971,
"+/jMe3.Version": 3
},
"root": {
"+/jMe3.Class": "com.jme3.scene.Geometry",
"+/jMe3.Id": "com.jme3.scene.Geometry@1904948097",
"+/jMe3.Versions": [
1,
0
],
"jme3.name": "Box",
"jme3.lights": {
"+/jMe3.Class": "com.jme3.light.LightList",
"+/jMe3.Id": "com.jme3.light.LightList@1601477037",
"+/jMe3.Versions": [
0
],
"jme3.lights": []
},
"jme3.overrides": [],
"jme3.controlsList": [
{
"+/jMe3.Class": "com.jme3.export.json.Test$CubeControl",
"+/jMe3.Id": "com.jme3.export.json.Test$CubeControl@727460961",
"+/jMe3.Versions": [
0,
0
],
"jme3.spatial": {
"+/jMe3.Reference": "com.jme3.scene.Geometry@1904948097"
},
"jme3.speed": 1.5,
"jme3.dir": {
"+/jMe3.Class": "com.jme3.math.Vector3f",
"+/jMe3.Id": "com.jme3.math.Vector3f@-627115336",
"+/jMe3.Versions": [
0
],
"jme3.x": 1.0,
"jme3.y": 1.0,
"jme3.z": 1.0
}
}
],
"jme3.mesh": {
"+/jMe3.Class": "com.jme3.scene.shape.Box",
"+/jMe3.Id": "com.jme3.scene.shape.Box@1108493039",
"+/jMe3.Versions": [
0,
0,
0
],
"jme3.modelBound": {
"+/jMe3.Class": "com.jme3.bounding.BoundingBox",
"+/jMe3.Id": "com.jme3.bounding.BoundingBox@1387908284",
"+/jMe3.Versions": [
0,
0
],
"jme3.xExtent": 1.0,
"jme3.yExtent": 1.0,
"jme3.zExtent": 1.0
},
"jme3.vertCount": 24,
"jme3.elementCount": 12,
"jme3.instanceCount": 1,
"jme3.buffers": {
"0": {
"+/jMe3.Class": "com.jme3.scene.VertexBuffer",
"+/jMe3.Id": "com.jme3.scene.VertexBuffer@459811830",
"+/jMe3.Versions": [
0
],
"jme3.components": 3,
"jme3.usage": "Static",
"jme3.buffer_type": "Position",
"jme3.dataFloat": [
-1.0,
-1.0,
-1.0,
1.0,
-1.0,
-1.0,
1.0,
1.0,
-1.0,
-1.0,
1.0,
-1.0,
1.0,
-1.0,
-1.0,
1.0,
-1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
-1.0,
1.0,
-1.0,
1.0,
-1.0,
-1.0,
1.0,
-1.0,
1.0,
1.0,
1.0,
1.0,
1.0,
-1.0,
-1.0,
1.0,
-1.0,
-1.0,
-1.0,
-1.0,
1.0,
-1.0,
-1.0,
1.0,
1.0,
1.0,
1.0,
-1.0,
1.0,
1.0,
1.0,
-1.0,
1.0,
1.0,
-1.0,
1.0,
-1.0,
-1.0,
-1.0,
-1.0,
-1.0,
-1.0,
1.0,
1.0,
-1.0,
1.0,
1.0,
-1.0,
-1.0
]
},
"2": {
"+/jMe3.Class": "com.jme3.scene.VertexBuffer",
"+/jMe3.Id": "com.jme3.scene.VertexBuffer@639272810",
"+/jMe3.Versions": [
0
],
"jme3.components": 3,
"jme3.usage": "Static",
"jme3.buffer_type": "Normal",
"jme3.dataFloat": [
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0,
0.0,
-1.0,
0.0
]
},
"3": {
"+/jMe3.Class": "com.jme3.scene.VertexBuffer",
"+/jMe3.Id": "com.jme3.scene.VertexBuffer@252854539",
"+/jMe3.Versions": [
0
],
"jme3.components": 2,
"jme3.usage": "Static",
"jme3.buffer_type": "TexCoord",
"jme3.dataFloat": [
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
1.0,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
1.0,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
1.0,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
1.0,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
1.0,
1.0,
1.0,
0.0,
0.0,
0.0,
0.0,
1.0,
1.0,
1.0
]
},
"9": {
"+/jMe3.Class": "com.jme3.scene.VertexBuffer",
"+/jMe3.Id": "com.jme3.scene.VertexBuffer@651101097",
"+/jMe3.Versions": [
0
],
"jme3.components": 3,
"jme3.usage": "Static",
"jme3.buffer_type": "Index",
"jme3.format": "UnsignedShort",
"jme3.dataUnsignedShort": [
2,
1,
0,
3,
2,
0,
6,
5,
4,
7,
6,
4,
10,
9,
8,
11,
10,
8,
14,
13,
12,
15,
14,
12,
18,
17,
16,
19,
18,
16,
22,
21,
20,
23,
22,
20
]
}
},
"jme3.xExtent": 1.0,
"jme3.yExtent": 1.0,
"jme3.zExtent": 1.0
},
"jme3.material": {
"+/jMe3.Class": "com.jme3.material.Material",
"+/jMe3.Id": "com.jme3.material.Material@1252633752",
"+/jMe3.Versions": [
2
],
"jme3.material_def": "Common/MatDefs/Misc/Unshaded.j3md",
"jme3.parameters": {
"BackfaceShadows": {
"+/jMe3.Class": "com.jme3.material.MatParam",
"+/jMe3.Id": "com.jme3.material.MatParam@-2139704160",
"+/jMe3.Versions": [
0
],
"jme3.varType": "Boolean",
"jme3.name": "BackfaceShadows",
"jme3.value_bool": true
},
"PointSize": {
"+/jMe3.Class": "com.jme3.material.MatParam",
"+/jMe3.Id": "com.jme3.material.MatParam@1994856648",
"+/jMe3.Versions": [
0
],
"jme3.varType": "Float",
"jme3.name": "PointSize",
"jme3.value_float": 1.0
},
"Color": {
"+/jMe3.Class": "com.jme3.material.MatParam",
"+/jMe3.Id": "com.jme3.material.MatParam@18566027",
"+/jMe3.Versions": [
0
],
"jme3.varType": "Vector4",
"jme3.name": "Color",
"jme3.value_savable": {
"+/jMe3.Class": "com.jme3.math.ColorRGBA",
"+/jMe3.Id": "com.jme3.math.ColorRGBA@1165711330",
"+/jMe3.Versions": [
0
],
"jme3.r": 0.53376704,
"jme3.g": 0.124457,
"jme3.b": 0.94186205,
"jme3.a": 1.0
}
}
}
}
}
}
The ‘root’ node is where the entire scene (model) is stored, the ‘metadata’ is the exporter’s own.