/// <summary> /// Creates a JSON object containing PathTerrain and Path data. /// </summary> /// <returns>A JSON Value containing PathTerrain and Path data. You can ToString this for the JSON string.</returns> public Ferr_JSONValue ToJSON() { Ferr_JSONValue result = new Ferr_JSONValue(); result["fill"] = "" + fill; result["fillY"] = fillY; result["fillZ"] = fillZ; result["splitCorners"] = splitCorners; result["smoothPath"] = smoothPath; result["splitDist"] = splitDist; result["pixelsPerUnit"] = pixelsPerUnit; result["stretchThreshold"] = stretchThreshold; result["vertexColor"] = Ferr_Color.ToHex(vertexColor); result["createCollider"] = createCollider; result["create3DCollider"] = create3DCollider; result["depth"] = depth; result["surfaceOffset.0"] = surfaceOffset[0]; result["surfaceOffset.1"] = surfaceOffset[1]; result["surfaceOffset.2"] = surfaceOffset[2]; result["surfaceOffset.3"] = surfaceOffset[3]; result["colliders.bottom"] = collidersBottom; result["colliders.top"] = collidersTop; result["colliders.left"] = collidersLeft; result["colliders.right"] = collidersRight; result["directionOverrides"] = 0; Ferr_JSONValue dir = result["directionOverrides"]; for (int i = 0; i < directionOverrides.Count; i++) { dir[i] = directionOverrides[i].ToString(); } result["path"] = path.ToJSON(); return(result); }
/// <summary> /// Creates a TerrainMaterial from a JSON object. Does NOT recreate mesh data automatically or link materials! /// </summary> /// <param name="aJSON">A parsed JSON value containing PathTerrain and Path data</param> public void FromJSON(Ferr_JSONValue aJSON) { fill = (Ferr2DT_FillMode)Enum.Parse(typeof(Ferr2DT_FillMode), aJSON["fill", "Closed"]); fillY = aJSON["fillY", 0]; fillZ = aJSON["fillZ", 0.2f]; splitCorners = aJSON["splitCorners", true]; smoothPath = aJSON["smoothPath", false]; splitDist = aJSON["splitDist", 4]; pixelsPerUnit = aJSON["pixelsPerUnit", 32]; stretchThreshold = aJSON["stretchThreshold", 0.5f]; vertexColor = Ferr_Color.FromHex(aJSON["vertexColor", "FFFFFF"]); createCollider = aJSON["createCollider", true]; create3DCollider = aJSON["create3DCollider", false]; depth = aJSON["depth", 4]; surfaceOffset[0] = aJSON["surfaceOffset.0", 0]; surfaceOffset[1] = aJSON["surfaceOffset.1", 0]; surfaceOffset[2] = aJSON["surfaceOffset.2", 0]; surfaceOffset[3] = aJSON["surfaceOffset.3", 0]; collidersBottom = aJSON["colliders.bottom", true]; collidersTop = aJSON["colliders.top", true]; collidersLeft = aJSON["colliders.left", true]; collidersRight = aJSON["colliders.right", true]; Ferr_JSONValue overrides = aJSON["directionOverrides"]; for (int i = 0; i < overrides.Length; i++) { directionOverrides.Add((Ferr2DT_TerrainDirection)Enum.Parse(typeof(Ferr2DT_TerrainDirection), overrides[i, "None"])); } path.FromJSON(aJSON["path"]); }
/// <summary> /// Creates a JSON object containing PathTerrain and Path data. /// </summary> /// <returns>A JSON Value containing PathTerrain and Path data. You can ToString this for the JSON string.</returns> public Ferr_JSONValue ToJSON() { Ferr_JSONValue result = new Ferr_JSONValue(); result["fill"] = "" + fill; result["fillY"] = fillY; result["fillZ"] = fillZ; result["splitCorners"] = splitCorners; result["smoothPath"] = smoothPath; result["splitDist"] = splitDist; result["splitCount"] = splitCount; result["splitMiddle"] = splitMiddle; result["pixelsPerUnit"] = pixelsPerUnit; result["stretchThreshold"] = stretchThreshold; result["vertexColor"] = Ferr_Color.ToHex(vertexColor); result["createTangents"] = createTangents; result["randomBWC"] = randomByWorldCoordinates; result["slantAmount"] = slantAmount; result["createCollider"] = createCollider; result["create3DCollider"] = create3DCollider; result["isTrigger"] = isTrigger; result["ssCollisions"] = smoothSphereCollisions; result["sharpCorners"] = sharpCorners; result["sharpCornerDist"] = sharpCornerDistance; result["depth"] = depth; result["uvOffset.x"] = uvOffset.x; result["uvOffset.y"] = uvOffset.y; result["surfaceOffset.0"] = surfaceOffset[0]; result["surfaceOffset.1"] = surfaceOffset[1]; result["surfaceOffset.2"] = surfaceOffset[2]; result["surfaceOffset.3"] = surfaceOffset[3]; result["colliders.bottom"] = collidersBottom; result["colliders.top"] = collidersTop; result["colliders.left"] = collidersLeft; result["colliders.right"] = collidersRight; result["directionOverrides"] = 0; Ferr_JSONValue dir = result["directionOverrides"]; for (int i = 0; i < directionOverrides.Count; i++) { dir[i] = directionOverrides[i].ToString(); } result["path"] = Path.ToJSON(); return(result); }
/// <summary> /// Creates a TerrainMaterial from a JSON object. Does NOT recreate mesh data automatically or link materials! /// </summary> /// <param name="aJSON">A parsed JSON value containing PathTerrain and Path data</param> public void FromJSON(Ferr_JSONValue aJSON) { fill = (Ferr2DT_FillMode)Enum.Parse(typeof(Ferr2DT_FillMode), aJSON["fill", "Closed"]); fillY = aJSON["fillY", 0]; fillZ = aJSON["fillZ", 0.2f]; splitCorners = aJSON["splitCorners", true]; smoothPath = aJSON["smoothPath", false]; splitCount = (int)aJSON["splitCount", 4]; splitDist = aJSON["splitDist", 1]; splitMiddle = aJSON["splitMiddle", true]; pixelsPerUnit = aJSON["pixelsPerUnit", 32]; stretchThreshold = aJSON["stretchThreshold", 0.5f]; vertexColor = Ferr_Color.FromHex(aJSON["vertexColor", "FFFFFF"]); createTangents = aJSON["createTangents", false]; createCollider = aJSON["createCollider", true]; create3DCollider = aJSON["create3DCollider", false]; depth = aJSON["depth", 4]; isTrigger = aJSON["isTrigger", false]; sharpCorners = aJSON["sharpCorners", false]; sharpCornerDistance = aJSON["sharpCornerDist", 2]; smoothSphereCollisions = aJSON["ssCollisions", false]; randomByWorldCoordinates = aJSON["randomBWC", false]; slantAmount = aJSON["slantAmount", 0]; uvOffset.x = aJSON["uvOffset.x", 0]; uvOffset.y = aJSON["uvOffset.y", 0]; surfaceOffset[0] = aJSON["surfaceOffset.0", 0]; surfaceOffset[1] = aJSON["surfaceOffset.1", 0]; surfaceOffset[2] = aJSON["surfaceOffset.2", 0]; surfaceOffset[3] = aJSON["surfaceOffset.3", 0]; collidersBottom = aJSON["colliders.bottom", true]; collidersTop = aJSON["colliders.top", true]; collidersLeft = aJSON["colliders.left", true]; collidersRight = aJSON["colliders.right", true]; Ferr_JSONValue overrides = aJSON["directionOverrides"]; for (int i = 0; i < overrides.Length; i++) { directionOverrides.Add((Ferr2DT_TerrainDirection)Enum.Parse(typeof(Ferr2DT_TerrainDirection), overrides[i, "None"])); vertScales.Add(1); } Path.FromJSON(aJSON["path"]); }