-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// unset:none | ||
using System; | ||
|
||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
[Serializable] | ||
public class GLTFContainerData : ComponentData | ||
{ | ||
public DCLGLTFMesh mesh; | ||
|
||
public GLTFContainerData(DCLGLTFMesh mesh) | ||
{ | ||
this.mesh = mesh; | ||
} | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
[Serializable] | ||
public class MaterialData : ComponentData | ||
{ | ||
public DCLMaterial material; | ||
} | ||
|
||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// unset:none | ||
using System; | ||
using System.Collections.Generic; | ||
using Unity.Plastic.Newtonsoft.Json; | ||
using UnityEngine; | ||
using Utility.Primitives; | ||
|
||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
[Serializable] | ||
public class MeshRendererData : ComponentData | ||
{ | ||
public DCLMesh mesh; | ||
} | ||
|
||
[JsonConverter(typeof(MeshRendererDataConverter))] | ||
[Serializable] | ||
public abstract class DCLMesh | ||
{ | ||
public abstract void InstantiateMesh(Transform parent, DCLMaterial material, Dictionary<string, string> contentTable); | ||
} | ||
|
||
|
||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// unset:none | ||
using System; | ||
using Unity.Plastic.Newtonsoft.Json; | ||
using Unity.Plastic.Newtonsoft.Json.Linq; | ||
|
||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
public class MaterialDataConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) => | ||
(objectType == typeof(DCLMaterial)); | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
JObject jsonObject = JObject.Load(reader); | ||
DCLMaterial dclMaterial = null; | ||
switch (jsonObject["$case"].Value<string>()) | ||
{ | ||
case MaterialConstants.PBR: | ||
dclMaterial = new PBRMaterial(); | ||
serializer.Populate(jsonObject["pbr"].CreateReader(), dclMaterial); | ||
break; | ||
case MaterialConstants.Unlit: | ||
dclMaterial = new UnlitMaterial(); | ||
serializer.Populate(jsonObject["unlit"].CreateReader(), dclMaterial); | ||
break; | ||
} | ||
return dclMaterial; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using Unity.Plastic.Newtonsoft.Json; | ||
using Unity.Plastic.Newtonsoft.Json.Linq; | ||
|
||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
public class MeshRendererDataConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) => | ||
(objectType == typeof(MeshRendererData)); | ||
|
||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
JObject jsonObject = JObject.Load(reader); | ||
|
||
DCLMesh dclMesh = null; | ||
switch (jsonObject["$case"].Value<string>()) | ||
{ | ||
case MeshConstants.Box: | ||
dclMesh = new Box(); | ||
serializer.Populate(jsonObject["box"].CreateReader(), dclMesh); | ||
break; | ||
case MeshConstants.Cylinder: | ||
dclMesh = new Cylinder(); | ||
serializer.Populate(jsonObject["cylinder"].CreateReader(), dclMesh); | ||
break; | ||
} | ||
|
||
return dclMesh; | ||
} | ||
|
||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// unset:none | ||
using System; | ||
using Unity.Plastic.Newtonsoft.Json; | ||
using Unity.Plastic.Newtonsoft.Json.Linq; | ||
|
||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
public class RenderableEntityDataConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) => | ||
(objectType == typeof(RenderableEntity)); | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
JObject jsonObject = JObject.Load(reader); | ||
|
||
RenderableEntity renderableEntity = new RenderableEntity(); | ||
renderableEntity.entityId = jsonObject["entityId"].Value<int>(); | ||
renderableEntity.componentName = jsonObject["componentName"].Value<string>(); | ||
renderableEntity.componentId = jsonObject["componentId"].Value<int>(); | ||
|
||
ComponentData componentData = null; | ||
switch (renderableEntity.componentName) | ||
{ | ||
case RenderableEntityConstants.Transform: | ||
componentData = new TransformData(); | ||
break; | ||
case RenderableEntityConstants.Material: | ||
componentData = new MaterialData(); | ||
break; | ||
case RenderableEntityConstants.GLTFContainer: | ||
componentData = new GLTFContainerData(new DCLGLTFMesh(jsonObject["data"]["src"].Value<string>())); | ||
break; | ||
case RenderableEntityConstants.MeshRenderer: | ||
componentData = new MeshRendererData(); | ||
break; | ||
} | ||
|
||
if (componentData != null) | ||
serializer.Populate(jsonObject["data"].CreateReader(), componentData); | ||
|
||
renderableEntity.data = componentData; | ||
|
||
return renderableEntity; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// unset:none | ||
using System; | ||
using Unity.Plastic.Newtonsoft.Json; | ||
using Unity.Plastic.Newtonsoft.Json.Linq; | ||
|
||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
public class TextureDataConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) => | ||
(objectType == typeof(Texture)); | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
JObject jsonObject = JObject.Load(reader); | ||
Texture texture = new Texture(); | ||
texture.src = jsonObject["texture"]["src"].Value<string>(); | ||
return texture; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// unset:none | ||
namespace AssetBundleConverter.LODs.JsonParsing | ||
{ | ||
public class RenderableEntityConstants | ||
{ | ||
public const string Transform = "core::Transform"; | ||
public const string Material = "core::Material"; | ||
public const string GLTFContainer = "core::GltfContainer"; | ||
public const string MeshRenderer = "core::MeshRenderer"; | ||
} | ||
|
||
public class MeshConstants | ||
{ | ||
public const string Box = "box"; | ||
public const string Cylinder = "cylinder"; | ||
} | ||
|
||
public class MaterialConstants | ||
{ | ||
public const string PBR = "pbr"; | ||
public const string Unlit = "unlit"; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.