Skip to content

Commit

Permalink
partial revert of PR #2060 (JSON parser abstraction) (#2278)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold authored and scenemax3d committed Jun 11, 2024
1 parent 3459b55 commit 9a11aa6
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 55 deletions.
4 changes: 2 additions & 2 deletions jme3-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ dependencies {
implementation project(':jme3-networking')
implementation project(':jme3-niftygui')
implementation project(':jme3-plugins')
implementation project(':jme3-plugins-json')
implementation project(':jme3-plugins-json-gson')
// implementation project(':jme3-plugins-json')
// implementation project(':jme3-plugins-json-gson')
implementation project(':jme3-terrain')
implementation project(':jme3-awt-dialogs')
runtimeOnly project(':jme3-testdata')
Expand Down
3 changes: 1 addition & 2 deletions jme3-plugins/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ sourceSets {

dependencies {
api project(':jme3-core')
implementation project(':jme3-plugins-json')
implementation project(':jme3-plugins-json-gson')
api 'com.google.code.gson:gson:2.9.1'
testRuntimeOnly project(':jme3-desktop')
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2023 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,10 +31,9 @@
*/
package com.jme3.scene.plugins.gltf;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.jme3.asset.AssetLoadException;
import com.jme3.plugins.json.JsonArray;
import com.jme3.plugins.json.JsonElement;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,8 +31,7 @@
*/
package com.jme3.scene.plugins.gltf;


import com.jme3.plugins.json.JsonElement;
import com.google.gson.JsonElement;
import java.io.IOException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.scene.plugins.gltf;
import com.jme3.plugins.json.JsonElement;

import com.google.gson.JsonElement;

/**
* Interface to handle a glTF extra.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2023 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,10 +31,12 @@
*/
package com.jme3.scene.plugins.gltf;

import com.jme3.plugins.json.JsonArray;
import com.jme3.plugins.json.JsonObject;
import com.jme3.plugins.json.JsonPrimitive;
import com.jme3.plugins.json.JsonElement;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import com.jme3.anim.*;
import com.jme3.asset.*;
import com.jme3.material.Material;
Expand Down Expand Up @@ -121,7 +123,7 @@ protected Object loadFromStream(AssetInfo assetInfo, InputStream stream) throws
defaultMat.setFloat("Roughness", 1f);
}

docRoot = parse(stream);
docRoot = JsonParser.parseReader(new JsonReader(new InputStreamReader(stream))).getAsJsonObject();

JsonObject asset = docRoot.getAsJsonObject().get("asset").getAsJsonObject();
getAsString(asset, "generator");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,15 +31,13 @@
*/
package com.jme3.scene.plugins.gltf;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.jme3.asset.AssetInfo;
import com.jme3.asset.AssetLoadException;
import com.jme3.math.*;
import com.jme3.scene.*;
import com.jme3.plugins.json.Json;
import com.jme3.plugins.json.JsonParser;
import com.jme3.plugins.json.JsonArray;
import com.jme3.plugins.json.JsonObject;
import com.jme3.plugins.json.JsonElement;
import com.jme3.texture.Texture;
import com.jme3.util.*;
import java.io.*;
Expand All @@ -61,18 +59,7 @@ public class GltfUtils {
private GltfUtils() {
}


/**
* Parse a json input stream and returns a {@link JsonObject}
* @param stream the stream to parse
* @return the JsonObject
*/
public static JsonObject parse(InputStream stream) {
JsonParser parser = Json.create();
return parser.parse(stream);
}

public static Mesh.Mode getMeshMode(Integer mode) {
public static Mesh.Mode getMeshMode(Integer mode) {
if (mode == null) {
return Mesh.Mode.Triangles;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,9 +31,9 @@
*/
package com.jme3.scene.plugins.gltf;

import com.jme3.plugins.json.JsonArray;
import com.jme3.plugins.json.JsonObject;
import com.jme3.plugins.json.JsonElement;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.jme3.asset.AssetLoadException;
import com.jme3.light.DirectionalLight;
import com.jme3.light.Light;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 jMonkeyEngine
* Copyright (c) 2023-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -32,7 +32,7 @@
package com.jme3.scene.plugins.gltf;

import com.jme3.asset.AssetKey;
import com.jme3.plugins.json.JsonElement;
import com.google.gson.JsonElement;
import java.io.IOException;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2020 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -34,7 +34,7 @@
import com.jme3.asset.AssetKey;

import java.io.IOException;
import com.jme3.plugins.json.JsonElement;
import com.google.gson.JsonElement;
import static com.jme3.scene.plugins.gltf.GltfUtils.getAsColor;
import static com.jme3.scene.plugins.gltf.GltfUtils.getAsFloat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2022 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -31,9 +31,9 @@
*/
package com.jme3.scene.plugins.gltf;

import com.jme3.plugins.json.JsonArray;
import com.jme3.plugins.json.JsonObject;
import com.jme3.plugins.json.JsonElement;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.jme3.asset.AssetLoadException;
import com.jme3.math.Matrix3f;
import com.jme3.math.Vector3f;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2021 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -30,7 +30,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.jme3.scene.plugins.gltf;
import com.jme3.plugins.json.JsonElement;

import com.google.gson.JsonElement;
import com.jme3.asset.AssetKey;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2023 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -32,10 +32,10 @@

package com.jme3.scene.plugins.gltf;

import com.jme3.plugins.json.JsonArray;
import com.jme3.plugins.json.JsonElement;
import com.jme3.plugins.json.JsonObject;
import com.jme3.plugins.json.JsonPrimitive;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.jme3.scene.Spatial;

import java.lang.reflect.Array;
Expand Down

0 comments on commit 9a11aa6

Please sign in to comment.