WIP remove PartialExtensionBase

This commit is contained in:
ousttrue 2020-11-19 21:32:35 +09:00
parent 07bb9d6cdb
commit 846fff82fa
39 changed files with 684 additions and 906 deletions

View File

@ -9,28 +9,5 @@ namespace UniGLTF
{
return JsonUtility.FromJson<T>(json);
}
[Test]
public void PrimitivesExtensionsTest()
{
{
var r = deserialize<glTFPrimitives_extensions>("");
Assert.AreEqual(null, r);
}
{
var r = deserialize<glTFPrimitives_extensions>("{}");
Assert.NotNull(r);
// This is a curious behaviour of JsonUtility.
// TODO: We should replace a library which treats JSON from JsonUtility
//Assert.Null(r.KHR_draco_mesh_compression);
}
{
var r = deserialize<glTFPrimitives_extensions>("{\"KHR_draco_mesh_compression\":{}}");
Assert.NotNull(r);
//Assert.NotNull(r.KHR_draco_mesh_compression);
}
}
}
}

View File

@ -1,4 +1,5 @@
using NUnit.Framework;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
@ -30,8 +31,8 @@ namespace UniGLTF
var gltfMaterial = materialExporter.ExportMaterial(srcMaterial, textureManager);
var shaderStore = new ShaderStore(null);
var materialImporter = new MaterialImporter(shaderStore, (int index) => {return null;});
var dstMaterial = materialImporter.CreateMaterial(0,gltfMaterial, false);
var materialImporter = new MaterialImporter(shaderStore, (int index) => { return null; });
var dstMaterial = materialImporter.CreateMaterial(0, gltfMaterial, false);
Assert.AreEqual(dstMaterial.mainTextureOffset.x, offset.x, 0.001f);
Assert.AreEqual(dstMaterial.mainTextureOffset.y, offset.y, 0.001f);
@ -53,9 +54,9 @@ namespace UniGLTF
{
baseColorFactor = new float[] { 1, 0, 0, 1 },
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -70,9 +71,9 @@ namespace UniGLTF
{
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -88,9 +89,9 @@ namespace UniGLTF
baseColorFactor = new float[] { 1, 0, 0, 1 },
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -105,9 +106,9 @@ namespace UniGLTF
{
baseColorFactor = new float[] { 1, 0, 0, 1 },
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -122,9 +123,9 @@ namespace UniGLTF
{
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -140,9 +141,9 @@ namespace UniGLTF
baseColorFactor = new float[] { 1, 0, 0, 1 },
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -157,9 +158,9 @@ namespace UniGLTF
{
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -175,9 +176,9 @@ namespace UniGLTF
baseColorFactor = new float[] { 1, 0, 0, 1 },
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
@ -187,9 +188,9 @@ namespace UniGLTF
// default
var shader = shaderStore.GetShader(new glTFMaterial
{
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit { }
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
}
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);

View File

@ -237,12 +237,13 @@ namespace UniGLTF
{
POSITION = 0,
},
extras = new glTFPrimitives_extras
extras = new KeyValuePair<string, object>[]
{
targetNames = new List<String>
new KeyValuePair<string, object>(
"targetNames", new List<String>
{
"aaa",
}
})
}
};

View File

@ -1,10 +0,0 @@
using System;
namespace UniGLTF
{
[Serializable]
public partial class glTFPrimitives_extensions : ExtensionsBase<glTFPrimitives_extensions>
{
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 2d21c7591557c7744a6fa34a7acace91
timeCreated: 1533605595
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UniJSON;
namespace UniGLTF
@ -24,18 +25,11 @@ namespace UniGLTF
roughnessFactor = 0.9f,
metallicFactor = 0.0f,
},
extensions = new glTFMaterial_extensions
extensions = new KeyValuePair<string, object>[]
{
KHR_materials_unlit = new glTF_KHR_materials_unlit(),
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit()),
},
};
}
}
[Serializable]
public partial class glTFMaterial_extensions : ExtensionsBase<glTFMaterial_extensions>
{
[JsonSchema(Required = true)]
public glTF_KHR_materials_unlit KHR_materials_unlit;
}
}

View File

@ -27,11 +27,4 @@ namespace UniGLTF
[ItemJsonSchema(Minimum = 0)]
public int texCoord;
}
[Serializable]
public class glTFTextureInfo_extensions : ExtensionsBase<glTFTextureInfo_extensions>
{
[JsonSchema(Required = true)]
public glTF_KHR_texture_transform KHR_texture_transform;
}
}

View File

@ -1,27 +0,0 @@
using System;
using UniJSON;
namespace UniGLTF
{
[Serializable]
[ItemJsonSchema(ValueType = ValueNodeType.Object)]
public partial class glTFOrthographic_extensions : ExtensionsBase<glTFOrthographic_extensions> { }
[Serializable]
public partial class glTFOrthographic_extras : ExtraBase<glTFOrthographic_extras> { }
[Serializable]
[ItemJsonSchema(ValueType = ValueNodeType.Object)]
public partial class glTFPerspective_extensions : ExtensionsBase<glTFPerspective_extensions> { }
[Serializable]
public partial class glTFPerspective_extras : ExtraBase<glTFPerspective_extras> { }
[Serializable]
[ItemJsonSchema(ValueType = ValueNodeType.Object)]
public partial class glTFCamera_extensions : ExtensionsBase<glTFCamera_extensions> { }
[Serializable]
public partial class glTFCamera_extras : ExtraBase<glTFCamera_extras> { }
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 38f59c64e05855b41be64595c570e366
timeCreated: 1533605499
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,31 +0,0 @@
using System;
using System.Linq;
using System.Reflection;
using UniJSON;
namespace UniGLTF
{
#region Base
public class PartialExtensionBase<T>
{
}
[ItemJsonSchema(ValueType = ValueNodeType.Object)]
//[JsonSchema(MinProperties = 1)]
public partial class ExtensionsBase<T> : PartialExtensionBase<T>
{
}
//[JsonSchema(MinProperties = 1)]
public partial class ExtraBase<T> : PartialExtensionBase<T>
{
}
#endregion
[Serializable]
public partial class glTF_extensions : ExtensionsBase<glTF_extensions> { }
[Serializable]
public partial class gltf_extras : ExtraBase<gltf_extras> { }
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 356f989283db8c848b851b82c34086d1
timeCreated: 1532101527
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using UniJSON;
namespace UniGLTF
{
/// <summary>
/// https://github.com/KhronosGroup/glTF/issues/1036
/// </summary>
[Serializable]
public partial class glTFPrimitives_extras : ExtraBase<glTFPrimitives_extras>
{
[JsonSchema(Required = true, MinItems = 1)]
public List<string> targetNames = new List<string>();
}
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: e95762d0b18d11243b32a56f21cef862
timeCreated: 1533605545
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using UniJSON;
namespace UniGLTF
{
/// <summary>
/// https://github.com/KhronosGroup/glTF/issues/1036
/// </summary>
[Serializable]
public partial class glTFMesh_extras : ExtraBase<glTFMesh_extras>
{
[JsonSchema(Required = true, MinItems = 1)]
public List<string> targetNames = new List<string>();
}
}

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 97b77d4c1c0d44b594e9187e41b3152d
timeCreated: 1582269878

View File

@ -1,11 +0,0 @@
using System;
namespace UniGLTF
{
[Serializable]
public partial class glTFNode_extensions : ExtensionsBase<glTFNode_extensions> { }
[Serializable]
public partial class glTFNode_extra : ExtraBase<glTFNode_extra> { }
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: eef0405c0c9670947ab6fa2034f0343f
timeCreated: 1533605847
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -298,8 +298,8 @@ namespace UniGLTF
[JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)]
public List<string> extensionsRequired = new List<string>();
public glTF_extensions extensions = new glTF_extensions();
public gltf_extras extras = new gltf_extras();
public object extensions;
public object extras;
public override string ToString()
{

View File

@ -22,9 +22,9 @@ namespace UniGLTF
public float znear;
[JsonSchema(MinProperties = 1)]
public glTFOrthographic_extensions extensions;
public object extensions;
[JsonSchema(MinProperties = 1)]
public glTFOrthographic_extras extras;
public object extras;
}
[Serializable]
@ -39,8 +39,8 @@ namespace UniGLTF
[JsonSchema(Required = true, Minimum = 0.0f, ExclusiveMinimum = true)]
public float znear;
public glTFPerspective_extensions extensions;
public glTFPerspective_extras extras;
public object extensions;
public object extras;
}
[Serializable]
@ -54,7 +54,7 @@ namespace UniGLTF
public string name;
public glTFCamera_extensions extensions;
public glTFCamera_extras extras;
public object extensions;
public object extras;
}
}

View File

@ -28,7 +28,7 @@ namespace UniGLTF
public int texCoord;
// empty schemas
public glTFTextureInfo_extensions extensions;
public object extensions;
public object extras;
public abstract glTFTextureTypes TextureType { get; }
@ -134,7 +134,7 @@ namespace UniGLTF
public bool doubleSided;
[JsonSchema(SkipSchemaComparison = true)]
public glTFMaterial_extensions extensions;
public object extensions;
public object extras;
public glTFTextureInfo[] GetTextures()

View File

@ -99,10 +99,10 @@ namespace UniGLTF
[ItemJsonSchema(SkipSchemaComparison = true)]
public List<gltfMorphTarget> targets = new List<gltfMorphTarget>();
public glTFPrimitives_extras extras = new glTFPrimitives_extras();
public object extras;
[JsonSchema(SkipSchemaComparison = true)]
public glTFPrimitives_extensions extensions = null;
public object extensions;
}
[Serializable]
@ -117,7 +117,7 @@ namespace UniGLTF
public float[] weights;
[JsonSchema(SkipSchemaComparison = true)]
public glTFMesh_extras extras = null;
public object extras;
// empty schemas
public object extensions;

View File

@ -40,8 +40,8 @@ namespace UniGLTF
public int camera = -1;
// empty schemas
public glTFNode_extensions extensions;
public object extensions;
public glTFNode_extra extras = new glTFNode_extra();
public object extras;
}
}

View File

@ -269,18 +269,19 @@ namespace UniGLTF
var targets = primitive.targets;
List<string> targetNames;
if(primitive != null && primitive.extras != null && primitive.extras.targetNames != null && primitive.extras.targetNames.Count > 0)
{
targetNames = primitive.extras.targetNames;
}
else if(mesh.extras != null && mesh.extras.targetNames != null && mesh.extras.targetNames.Count > 0)
{
targetNames = mesh.extras.targetNames;
}
else
{
throw new Exception("glTF BlendShape Animation. targetNames invalid.");
}
throw new NotImplementedException();
// if(primitive != null && primitive.extras != null && primitive.extras.targetNames != null && primitive.extras.targetNames.Count > 0)
// {
// targetNames = primitive.extras.targetNames;
// }
// else if(mesh.extras != null && mesh.extras.targetNames != null && mesh.extras.targetNames.Count > 0)
// {
// targetNames = mesh.extras.targetNames;
// }
// else
// {
// throw new Exception("glTF BlendShape Animation. targetNames invalid.");
// }
var keyNames = targetNames
.Where(x => !string.IsNullOrEmpty(x))

View File

@ -642,14 +642,14 @@ namespace UniGLTF {
}
/// gltf/materials[]/pbrMetallicRoughness/baseColorTexture/extensions
public static void GenSerialize(this IFormatter f, glTFTextureInfo_extensions value)
public static void GenSerialize(this IFormatter f, object value)
{
f.BeginMap(0); // dummy
if(value.KHR_texture_transform!=null)
{
f.Key("KHR_texture_transform"); f.GenSerialize(value.KHR_texture_transform);
}
// if(value.KHR_texture_transform!=null)
// {
// f.Key("KHR_texture_transform"); f.GenSerialize(value.KHR_texture_transform);
// }
f.EndMap();
}
@ -784,19 +784,6 @@ namespace UniGLTF {
f.EndMap();
}
/// gltf/materials[]/extensions
public static void GenSerialize(this IFormatter f, glTFMaterial_extensions value)
{
f.BeginMap(0); // dummy
if(value.KHR_materials_unlit!=null)
{
f.Key("KHR_materials_unlit"); f.GenSerialize(value.KHR_materials_unlit);
}
f.EndMap();
}
/// gltf/materials[]/extensions/KHR_materials_unlit
public static void GenSerialize(this IFormatter f, glTF_KHR_materials_unlit value)
{
@ -885,10 +872,10 @@ namespace UniGLTF {
f.Key("targets"); f.GenSerialize(value.targets);
}
if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0)
{
f.Key("extras"); f.GenSerialize(value.extras);
}
// if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0)
// {
// f.Key("extras"); f.GenSerialize(value.extras);
// }
f.EndMap();
}
@ -971,17 +958,17 @@ namespace UniGLTF {
}
/// gltf/meshes[]/primitives[]/extras
public static void GenSerialize(this IFormatter f, glTFPrimitives_extras value)
{
f.BeginMap(0); // dummy
// public static void GenSerialize(this IFormatter f, glTFPrimitives_extras value)
// {
// f.BeginMap(0); // dummy
if(value.targetNames!=null)
{
f.Key("targetNames"); f.GenSerialize(value.targetNames);
}
// if(value.targetNames!=null)
// {
// f.Key("targetNames"); f.GenSerialize(value.targetNames);
// }
f.EndMap();
}
// f.EndMap();
// }
/// gltf/meshes[]/primitives[]/extras/targetNames
public static void GenSerialize(this IFormatter f, List<String> value)
@ -994,27 +981,6 @@ namespace UniGLTF {
f.EndList();
}
/// gltf/meshes[]/primitives[]/extensions
public static void GenSerialize(this IFormatter f, glTFPrimitives_extensions value)
{
f.BeginMap(0); // dummy
f.EndMap();
}
/// gltf/meshes[]/extras
public static void GenSerialize(this IFormatter f, glTFMesh_extras value)
{
f.BeginMap(0); // dummy
if(value.targetNames!=null)
{
f.Key("targetNames"); f.GenSerialize(value.targetNames);
}
f.EndMap();
}
/// gltf/nodes
public static void GenSerialize(this IFormatter f, List<glTFNode> value)
{
@ -1095,21 +1061,21 @@ namespace UniGLTF {
f.EndList();
}
/// gltf/nodes[]/extensions
public static void GenSerialize(this IFormatter f, glTFNode_extensions value)
{
f.BeginMap(0); // dummy
// /// gltf/nodes[]/extensions
// public static void GenSerialize(this IFormatter f, glTFNode_extensions value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
/// gltf/nodes[]/extras
public static void GenSerialize(this IFormatter f, glTFNode_extra value)
{
f.BeginMap(0); // dummy
// /// gltf/nodes[]/extras
// public static void GenSerialize(this IFormatter f, glTFNode_extra value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
/// gltf/skins
public static void GenSerialize(this IFormatter f, List<glTFSkin> value)
@ -1361,21 +1327,21 @@ namespace UniGLTF {
f.EndMap();
}
/// gltf/cameras[]/orthographic/extensions
public static void GenSerialize(this IFormatter f, glTFOrthographic_extensions value)
{
f.BeginMap(0); // dummy
// /// gltf/cameras[]/orthographic/extensions
// public static void GenSerialize(this IFormatter f, glTFOrthographic_extensions value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
/// gltf/cameras[]/orthographic/extras
public static void GenSerialize(this IFormatter f, glTFOrthographic_extras value)
{
f.BeginMap(0); // dummy
// /// gltf/cameras[]/orthographic/extras
// public static void GenSerialize(this IFormatter f, glTFOrthographic_extras value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
/// gltf/cameras[]/perspective
public static void GenSerialize(this IFormatter f, glTFPerspective value)
@ -1405,55 +1371,55 @@ namespace UniGLTF {
f.EndMap();
}
/// gltf/cameras[]/perspective/extensions
public static void GenSerialize(this IFormatter f, glTFPerspective_extensions value)
{
f.BeginMap(0); // dummy
// /// gltf/cameras[]/perspective/extensions
// public static void GenSerialize(this IFormatter f, glTFPerspective_extensions value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
/// gltf/cameras[]/perspective/extras
public static void GenSerialize(this IFormatter f, glTFPerspective_extras value)
{
f.BeginMap(0); // dummy
// /// gltf/cameras[]/perspective/extras
// public static void GenSerialize(this IFormatter f, glTFPerspective_extras value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
public static void GenSerialize(this IFormatter f, ProjectionType value)
{
f.Value((int)value);
}
/// gltf/cameras[]/extensions
public static void GenSerialize(this IFormatter f, glTFCamera_extensions value)
{
f.BeginMap(0); // dummy
// /// gltf/cameras[]/extensions
// public static void GenSerialize(this IFormatter f, glTFCamera_extensions value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
/// gltf/cameras[]/extras
public static void GenSerialize(this IFormatter f, glTFCamera_extras value)
{
f.BeginMap(0); // dummy
// /// gltf/cameras[]/extras
// public static void GenSerialize(this IFormatter f, glTFCamera_extras value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
/// gltf/extensions
public static void GenSerialize(this IFormatter f, glTF_extensions value)
{
f.BeginMap(0); // dummy
// /// gltf/extensions
// public static void GenSerialize(this IFormatter f, glTF_extensions value)
// {
// f.BeginMap(0); // dummy
if(value.VRM!=null)
{
f.Key("VRM"); f.GenSerialize(value.VRM);
}
// if(value.VRM!=null)
// {
// f.Key("VRM"); f.GenSerialize(value.VRM);
// }
f.EndMap();
}
// f.EndMap();
// }
/// gltf/extensions/VRM
public static void GenSerialize(this IFormatter f, glTF_VRM_extensions value)
@ -2195,13 +2161,13 @@ namespace UniGLTF {
}
/// gltf/extras
public static void GenSerialize(this IFormatter f, gltf_extras value)
{
f.BeginMap(0); // dummy
// /// gltf/extras
// public static void GenSerialize(this IFormatter f, gltf_extras value)
// {
// f.BeginMap(0); // dummy
f.EndMap();
}
// f.EndMap();
// }
} // class
} // namespace

View File

@ -105,12 +105,12 @@ public static glTF Deserialize(ListTreeNode<JsonValue> parsed)
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
if(key=="extras"){
value.extras = Deserialize_gltf_extras(kv.Value);
value.extras = kv.Value;
continue;
}
@ -592,7 +592,7 @@ public static glTFMaterial Deserialize_gltf_materials_LIST(ListTreeNode<JsonValu
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_materials__extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
@ -656,7 +656,7 @@ public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMe
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
@ -664,22 +664,22 @@ public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMe
return value;
}
public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFTextureInfo_extensions();
// public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFTextureInfo_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="KHR_texture_transform"){
value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform(kv.Value);
continue;
}
// if(key=="KHR_texture_transform"){
// value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static glTF_KHR_texture_transform Deserialize_gltf_materials__pbrMetallicRoughness_baseColorTexture_extensions_KHR_texture_transform(ListTreeNode<JsonValue> parsed)
{
@ -765,7 +765,7 @@ public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_material
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
@ -773,22 +773,22 @@ public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_material
return value;
}
public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFTextureInfo_extensions();
// public static glTFTextureInfo_extensions Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFTextureInfo_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="KHR_texture_transform"){
value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform(kv.Value);
continue;
}
// if(key=="KHR_texture_transform"){
// value.KHR_texture_transform = Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static glTF_KHR_texture_transform Deserialize_gltf_materials__pbrMetallicRoughness_metallicRoughnessTexture_extensions_KHR_texture_transform(ListTreeNode<JsonValue> parsed)
{
@ -868,7 +868,7 @@ public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTe
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_materials__normalTexture_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
@ -876,22 +876,22 @@ public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTe
return value;
}
public static glTFTextureInfo_extensions Deserialize_gltf_materials__normalTexture_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFTextureInfo_extensions();
// public static glTFTextureInfo_extensions Deserialize_gltf_materials__normalTexture_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFTextureInfo_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="KHR_texture_transform"){
value.KHR_texture_transform = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform(kv.Value);
continue;
}
// if(key=="KHR_texture_transform"){
// value.KHR_texture_transform = Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static glTF_KHR_texture_transform Deserialize_gltf_materials__normalTexture_extensions_KHR_texture_transform(ListTreeNode<JsonValue> parsed)
{
@ -971,7 +971,7 @@ public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlu
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_materials__occlusionTexture_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
@ -979,22 +979,22 @@ public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlu
return value;
}
public static glTFTextureInfo_extensions Deserialize_gltf_materials__occlusionTexture_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFTextureInfo_extensions();
// public static glTFTextureInfo_extensions Deserialize_gltf_materials__occlusionTexture_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFTextureInfo_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="KHR_texture_transform"){
value.KHR_texture_transform = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform(kv.Value);
continue;
}
// if(key=="KHR_texture_transform"){
// value.KHR_texture_transform = Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static glTF_KHR_texture_transform Deserialize_gltf_materials__occlusionTexture_extensions_KHR_texture_transform(ListTreeNode<JsonValue> parsed)
{
@ -1069,7 +1069,7 @@ public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissi
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_materials__emissiveTexture_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
@ -1077,22 +1077,22 @@ public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissi
return value;
}
public static glTFTextureInfo_extensions Deserialize_gltf_materials__emissiveTexture_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFTextureInfo_extensions();
// public static glTFTextureInfo_extensions Deserialize_gltf_materials__emissiveTexture_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFTextureInfo_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="KHR_texture_transform"){
value.KHR_texture_transform = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform(kv.Value);
continue;
}
// if(key=="KHR_texture_transform"){
// value.KHR_texture_transform = Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static glTF_KHR_texture_transform Deserialize_gltf_materials__emissiveTexture_extensions_KHR_texture_transform(ListTreeNode<JsonValue> parsed)
{
@ -1159,22 +1159,22 @@ public static Single[] Deserialize_gltf_materials__emissiveFactor(ListTreeNode<J
return value;
}
public static glTFMaterial_extensions Deserialize_gltf_materials__extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFMaterial_extensions();
// public static glTFMaterial_extensions Deserialize_gltf_materials__extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFMaterial_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="KHR_materials_unlit"){
value.KHR_materials_unlit = Deserialize_gltf_materials__extensions_KHR_materials_unlit(kv.Value);
continue;
}
// if(key=="KHR_materials_unlit"){
// value.KHR_materials_unlit = Deserialize_gltf_materials__extensions_KHR_materials_unlit(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static glTF_KHR_materials_unlit Deserialize_gltf_materials__extensions_KHR_materials_unlit(ListTreeNode<JsonValue> parsed)
{
@ -1221,7 +1221,7 @@ public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode<JsonValue> pars
}
if(key=="extras"){
value.extras = Deserialize_gltf_meshes__extras(kv.Value);
value.extras = kv.Value;
continue;
}
@ -1272,12 +1272,12 @@ public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(ListTreeNo
}
if(key=="extras"){
value.extras = Deserialize_gltf_meshes__primitives__extras(kv.Value);
value.extras = kv.Value;
continue;
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_meshes__primitives__extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
@ -1368,22 +1368,22 @@ public static gltfMorphTarget Deserialize_gltf_meshes__primitives__targets_LIST(
return value;
}
public static glTFPrimitives_extras Deserialize_gltf_meshes__primitives__extras(ListTreeNode<JsonValue> parsed)
{
var value = new glTFPrimitives_extras();
// public static glTFPrimitives_extras Deserialize_gltf_meshes__primitives__extras(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFPrimitives_extras();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="targetNames"){
value.targetNames = Deserialize_gltf_meshes__primitives__extras_targetNames(kv.Value);
continue;
}
// if(key=="targetNames"){
// value.targetNames = Deserialize_gltf_meshes__primitives__extras_targetNames(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static List<System.String> Deserialize_gltf_meshes__primitives__extras_targetNames(ListTreeNode<JsonValue> parsed)
{
@ -1394,17 +1394,17 @@ public static List<System.String> Deserialize_gltf_meshes__primitives__extras_ta
}
return value;
}
public static glTFPrimitives_extensions Deserialize_gltf_meshes__primitives__extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFPrimitives_extensions();
// public static glTFPrimitives_extensions Deserialize_gltf_meshes__primitives__extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFPrimitives_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static Single[] Deserialize_gltf_meshes__weights(ListTreeNode<JsonValue> parsed)
{
@ -1417,22 +1417,22 @@ public static Single[] Deserialize_gltf_meshes__weights(ListTreeNode<JsonValue>
return value;
}
public static glTFMesh_extras Deserialize_gltf_meshes__extras(ListTreeNode<JsonValue> parsed)
{
var value = new glTFMesh_extras();
// public static glTFMesh_extras Deserialize_gltf_meshes__extras(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFMesh_extras();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="targetNames"){
value.targetNames = Deserialize_gltf_meshes__extras_targetNames(kv.Value);
continue;
}
// if(key=="targetNames"){
// value.targetNames = Deserialize_gltf_meshes__extras_targetNames(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static List<System.String> Deserialize_gltf_meshes__extras_targetNames(ListTreeNode<JsonValue> parsed)
{
@ -1511,12 +1511,12 @@ public static glTFNode Deserialize_gltf_nodes_LIST(ListTreeNode<JsonValue> parse
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_nodes__extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
if(key=="extras"){
value.extras = Deserialize_gltf_nodes__extras(kv.Value);
value.extras = kv.Value;
continue;
}
@ -1590,29 +1590,29 @@ public static Single[] Deserialize_gltf_nodes__weights(ListTreeNode<JsonValue> p
return value;
}
public static glTFNode_extensions Deserialize_gltf_nodes__extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFNode_extensions();
// public static glTFNode_extensions Deserialize_gltf_nodes__extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFNode_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static glTFNode_extra Deserialize_gltf_nodes__extras(ListTreeNode<JsonValue> parsed)
{
var value = new glTFNode_extra();
// public static glTFNode_extra Deserialize_gltf_nodes__extras(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFNode_extra();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static List<UniGLTF.glTFSkin> Deserialize_gltf_skins(ListTreeNode<JsonValue> parsed)
{
@ -1871,12 +1871,12 @@ public static glTFCamera Deserialize_gltf_cameras_LIST(ListTreeNode<JsonValue> p
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_cameras__extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
if(key=="extras"){
value.extras = Deserialize_gltf_cameras__extras(kv.Value);
value.extras = kv.Value;
continue;
}
@ -1913,12 +1913,12 @@ public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNo
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_cameras__orthographic_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
if(key=="extras"){
value.extras = Deserialize_gltf_cameras__orthographic_extras(kv.Value);
value.extras = kv.Value;
continue;
}
@ -1926,29 +1926,29 @@ public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNo
return value;
}
public static glTFOrthographic_extensions Deserialize_gltf_cameras__orthographic_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFOrthographic_extensions();
// public static glTFOrthographic_extensions Deserialize_gltf_cameras__orthographic_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFOrthographic_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static glTFOrthographic_extras Deserialize_gltf_cameras__orthographic_extras(ListTreeNode<JsonValue> parsed)
{
var value = new glTFOrthographic_extras();
// public static glTFOrthographic_extras Deserialize_gltf_cameras__orthographic_extras(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFOrthographic_extras();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode<JsonValue> parsed)
{
@ -1979,12 +1979,12 @@ public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode
}
if(key=="extensions"){
value.extensions = Deserialize_gltf_cameras__perspective_extensions(kv.Value);
value.extensions = kv.Value;
continue;
}
if(key=="extras"){
value.extras = Deserialize_gltf_cameras__perspective_extras(kv.Value);
value.extras = kv.Value;
continue;
}
@ -1992,53 +1992,53 @@ public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode
return value;
}
public static glTFPerspective_extensions Deserialize_gltf_cameras__perspective_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFPerspective_extensions();
// public static glTFPerspective_extensions Deserialize_gltf_cameras__perspective_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFPerspective_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static glTFPerspective_extras Deserialize_gltf_cameras__perspective_extras(ListTreeNode<JsonValue> parsed)
{
var value = new glTFPerspective_extras();
// public static glTFPerspective_extras Deserialize_gltf_cameras__perspective_extras(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFPerspective_extras();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static glTFCamera_extensions Deserialize_gltf_cameras__extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTFCamera_extensions();
// public static glTFCamera_extensions Deserialize_gltf_cameras__extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFCamera_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static glTFCamera_extras Deserialize_gltf_cameras__extras(ListTreeNode<JsonValue> parsed)
{
var value = new glTFCamera_extras();
// public static glTFCamera_extras Deserialize_gltf_cameras__extras(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTFCamera_extras();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
public static List<System.String> Deserialize_gltf_extensionsUsed(ListTreeNode<JsonValue> parsed)
{
@ -2058,22 +2058,22 @@ public static List<System.String> Deserialize_gltf_extensionsRequired(ListTreeNo
}
return value;
}
public static glTF_extensions Deserialize_gltf_extensions(ListTreeNode<JsonValue> parsed)
{
var value = new glTF_extensions();
// public static glTF_extensions Deserialize_gltf_extensions(ListTreeNode<JsonValue> parsed)
// {
// var value = new glTF_extensions();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
if(key=="VRM"){
value.VRM = Deserialize_gltf_extensions_VRM(kv.Value);
continue;
}
// if(key=="VRM"){
// value.VRM = Deserialize_gltf_extensions_VRM(kv.Value);
// continue;
// }
}
return value;
}
// }
// return value;
// }
public static glTF_VRM_extensions Deserialize_gltf_extensions_VRM(ListTreeNode<JsonValue> parsed)
{
@ -3159,17 +3159,17 @@ public static Dictionary<String, String> Deserialize_gltf_extensions_VRM_materia
return value;
}
public static gltf_extras Deserialize_gltf_extras(ListTreeNode<JsonValue> parsed)
{
var value = new gltf_extras();
// public static gltf_extras Deserialize_gltf_extras(ListTreeNode<JsonValue> parsed)
// {
// var value = new gltf_extras();
foreach(var kv in parsed.ObjectItems())
{
var key = kv.Key.GetString();
// foreach(var kv in parsed.ObjectItems())
// {
// var key = kv.Key.GetString();
}
return value;
}
// }
// return value;
// }
} // GltfDeserializer
} // UniGLTF

View File

@ -356,7 +356,8 @@ namespace UniGLTF
{
var extraName = parsed["meshes"][i]["primitives"][j]["targets"][k]["extra"]["name"].Value.GetString();
//Debug.LogFormat("restore morphName: {0}", extraName);
primitive.extras.targetNames.Add(extraName);
throw new NotImplementedException();
// primitive.extras.targetNames.Add(extraName);
}
}
}

View File

@ -1,4 +1,5 @@
using UniGLTF.UniUnlit;
using System.Collections.Generic;
using UniGLTF.UniUnlit;
using UnityEngine;
@ -188,13 +189,13 @@ namespace UniGLTF
var scale = m.GetTextureScale(propertyName);
offset.y = (offset.y + scale.y - 1) * -1.0f;
textureInfo.extensions = new glTFTextureInfo_extensions
textureInfo.extensions = new KeyValuePair<string, object>[]
{
KHR_texture_transform = new glTF_KHR_texture_transform()
new KeyValuePair<string, object>("KHR_texture_transform", new glTF_KHR_texture_transform()
{
offset = new float[] { offset.x, offset.y },
scale = new float[] { scale.x, scale.y },
}
})
};
}
}

View File

@ -82,67 +82,68 @@ namespace UniGLTF
}
// unlit material
if (x.extensions != null && x.extensions.KHR_materials_unlit != null)
{
// texture
if (x.pbrMetallicRoughness.baseColorTexture != null)
{
var texture = GetTextureFunc(x.pbrMetallicRoughness.baseColorTexture.index);
if (texture != null)
{
material.mainTexture = texture.Texture;
}
throw new NotImplementedException();
// if (x.extensions != null && x.extensions.KHR_materials_unlit != null)
// {
// // texture
// if (x.pbrMetallicRoughness.baseColorTexture != null)
// {
// var texture = GetTextureFunc(x.pbrMetallicRoughness.baseColorTexture.index);
// if (texture != null)
// {
// material.mainTexture = texture.Texture;
// }
// Texture Offset and Scale
SetTextureOffsetAndScale(material, x.pbrMetallicRoughness.baseColorTexture, "_MainTex");
}
// // Texture Offset and Scale
// SetTextureOffsetAndScale(material, x.pbrMetallicRoughness.baseColorTexture, "_MainTex");
// }
// color
if (x.pbrMetallicRoughness.baseColorFactor != null && x.pbrMetallicRoughness.baseColorFactor.Length == 4)
{
var color = x.pbrMetallicRoughness.baseColorFactor;
material.color = (new Color(color[0], color[1], color[2], color[3])).gamma;
}
// // color
// if (x.pbrMetallicRoughness.baseColorFactor != null && x.pbrMetallicRoughness.baseColorFactor.Length == 4)
// {
// var color = x.pbrMetallicRoughness.baseColorFactor;
// material.color = (new Color(color[0], color[1], color[2], color[3])).gamma;
// }
//renderMode
if (x.alphaMode == "OPAQUE")
{
UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Opaque);
}
else if (x.alphaMode == "BLEND")
{
UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Transparent);
}
else if(x.alphaMode == "MASK")
{
UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Cutout);
}
else
{
// default OPAQUE
UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Opaque);
}
// //renderMode
// if (x.alphaMode == "OPAQUE")
// {
// UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Opaque);
// }
// else if (x.alphaMode == "BLEND")
// {
// UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Transparent);
// }
// else if(x.alphaMode == "MASK")
// {
// UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Cutout);
// }
// else
// {
// // default OPAQUE
// UniUnlit.Utils.SetRenderMode(material, UniUnlit.UniUnlitRenderMode.Opaque);
// }
// culling
if (x.doubleSided)
{
UniUnlit.Utils.SetCullMode(material, UniUnlit.UniUnlitCullMode.Off);
}
else
{
UniUnlit.Utils.SetCullMode(material, UniUnlit.UniUnlitCullMode.Back);
}
// // culling
// if (x.doubleSided)
// {
// UniUnlit.Utils.SetCullMode(material, UniUnlit.UniUnlitCullMode.Off);
// }
// else
// {
// UniUnlit.Utils.SetCullMode(material, UniUnlit.UniUnlitCullMode.Back);
// }
// VColor
if (hasVertexColor)
{
UniUnlit.Utils.SetVColBlendMode(material, UniUnlit.UniUnlitVertexColorBlendOp.Multiply);
}
// // VColor
// if (hasVertexColor)
// {
// UniUnlit.Utils.SetVColBlendMode(material, UniUnlit.UniUnlitVertexColorBlendOp.Multiply);
// }
UniUnlit.Utils.ValidateProperties(material, true);
// UniUnlit.Utils.ValidateProperties(material, true);
return material;
}
// return material;
// }
// PBR material
if (x.pbrMetallicRoughness != null)
@ -292,25 +293,26 @@ namespace UniGLTF
private static void SetTextureOffsetAndScale(Material material, glTFTextureInfo textureInfo, string propertyName)
{
if (textureInfo.extensions != null && textureInfo.extensions.KHR_texture_transform != null)
{
var textureTransform = textureInfo.extensions.KHR_texture_transform;
Vector2 offset = new Vector2(0, 0);
Vector2 scale = new Vector2(1, 1);
if (textureTransform.offset != null && textureTransform.offset.Length == 2)
{
offset = new Vector2(textureTransform.offset[0], textureTransform.offset[1]);
}
if (textureTransform.scale != null && textureTransform.scale.Length == 2)
{
scale = new Vector2(textureTransform.scale[0], textureTransform.scale[1]);
}
throw new NotImplementedException();
// if (textureInfo.extensions != null && textureInfo.extensions.KHR_texture_transform != null)
// {
// var textureTransform = textureInfo.extensions.KHR_texture_transform;
// Vector2 offset = new Vector2(0, 0);
// Vector2 scale = new Vector2(1, 1);
// if (textureTransform.offset != null && textureTransform.offset.Length == 2)
// {
// offset = new Vector2(textureTransform.offset[0], textureTransform.offset[1]);
// }
// if (textureTransform.scale != null && textureTransform.scale.Length == 2)
// {
// scale = new Vector2(textureTransform.scale[0], textureTransform.scale[1]);
// }
offset.y = (offset.y + scale.y - 1.0f) * -1.0f;
// offset.y = (offset.y + scale.y - 1.0f) * -1.0f;
material.SetTextureOffset(propertyName, offset);
material.SetTextureScale(propertyName, scale);
}
// material.SetTextureOffset(propertyName, offset);
// material.SetTextureScale(propertyName, scale);
// }
}
}
}

View File

@ -263,9 +263,14 @@ namespace UniGLTF
var gltfMesh = ExportPrimitives(gltf, bufferIndex,
x.Renderer.name,
mesh, materials, unityMaterials);
var targetNames = new List<string>();
if (gltfMesh.extras == null)
{
gltfMesh.extras = new glTFMesh_extras();
gltfMesh.extras = new KeyValuePair<string, object>[]{
new KeyValuePair<string, object>("targetNames", targetNames),
};
}
var blendShapeIndexMap = new Dictionary<int, int>();
@ -284,7 +289,7 @@ namespace UniGLTF
// maybe skip
var blendShapeName = mesh.GetBlendShapeName(j);
blendShapeIndexMap.Add(j, exportBlendShapes++);
gltfMesh.extras.targetNames.Add(blendShapeName);
targetNames.Add(blendShapeName);
//
// all primitive has same blendShape
@ -292,7 +297,13 @@ namespace UniGLTF
for (int k = 0; k < gltfMesh.primitives.Count; ++k)
{
gltfMesh.primitives[k].targets.Add(morphTarget);
gltfMesh.primitives[k].extras.targetNames.Add(blendShapeName);
if (gltfMesh.primitives[k].extras == null)
{
gltfMesh.primitives[k].extras = new KeyValuePair<string, object>[]
{
new KeyValuePair<string, object>("targetNames", targetNames),
};
}
}
}

View File

@ -382,40 +382,41 @@ namespace UniGLTF
public void RenameBlendShape(glTFMesh gltfMesh)
{
if (gltfMesh.extras != null && gltfMesh.extras.targetNames != null)
{
var targetNames = gltfMesh.extras.targetNames;
for (int i = 1; i < gltfMesh.primitives.Count; ++i)
{
if (gltfMesh.primitives[i].targets.Count != targetNames.Count)
{
throw new FormatException(string.Format("different targets length: {0} with targetNames length.",
gltfMesh.primitives[i]));
}
}
for (var i = 0; i < targetNames.Count; i++)
{
BlendShapes[i].Name = targetNames[i];
}
return;
}
throw new NotImplementedException();
// if (gltfMesh.extras != null && gltfMesh.extras.targetNames != null)
// {
// var targetNames = gltfMesh.extras.targetNames;
// for (int i = 1; i < gltfMesh.primitives.Count; ++i)
// {
// if (gltfMesh.primitives[i].targets.Count != targetNames.Count)
// {
// throw new FormatException(string.Format("different targets length: {0} with targetNames length.",
// gltfMesh.primitives[i]));
// }
// }
// for (var i = 0; i < targetNames.Count; i++)
// {
// BlendShapes[i].Name = targetNames[i];
// }
// return;
// }
var prim = gltfMesh.primitives[0];
{
if (prim.extras != null && prim.extras.targetNames != null)
{
var targetNames = prim.extras.targetNames;
for (var i = 0; i < BlendShapes.Count; i++)
{
if (i >= targetNames.Count)
{
Debug.LogWarning($"invalid primitive.extras.targetNames length");
break;
}
BlendShapes[i].Name = targetNames[i];
}
}
}
// var prim = gltfMesh.primitives[0];
// {
// if (prim.extras != null && prim.extras.targetNames != null)
// {
// var targetNames = prim.extras.targetNames;
// for (var i = 0; i < BlendShapes.Count; i++)
// {
// if (i >= targetNames.Count)
// {
// Debug.LogWarning($"invalid primitive.extras.targetNames length");
// break;
// }
// BlendShapes[i].Name = targetNames[i];
// }
// }
// }
}
static void Truncate<T>(List<T> list, int maxIndex)

View File

@ -111,10 +111,11 @@ namespace UniGLTF
return Default;
}
if (material.extensions != null && material.extensions.KHR_materials_unlit != null)
{
return UniUnlit;
}
throw new System.NotImplementedException();
// if (material.extensions != null && material.extensions.KHR_materials_unlit != null)
// {
// return UniUnlit;
// }
// standard
return Default;

View File

@ -720,19 +720,19 @@ JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFMaterial>.Deserial
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFMaterial>.DeserializeField<System.Boolean>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFMaterial>.DeserializeField<UniGLTF.glTFMaterial_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFMaterial>.DeserializeField<UniGLTF.glTFMaterial_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFMaterial_extensions
f.Serialize(default(UniGLTF.glTFMaterial_extensions));
{
var value = default(UniGLTF.glTFMaterial_extensions);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFMaterial_extensions>.DeserializeField<UniGLTF.glTF_KHR_materials_unlit>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// f.Serialize(default(UniGLTF.glTFMaterial_extensions));
// {
// var value = default(UniGLTF.glTFMaterial_extensions);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFMaterial_extensions>.DeserializeField<UniGLTF.glTF_KHR_materials_unlit>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTF_KHR_materials_unlit
f.Serialize(default(UniGLTF.glTF_KHR_materials_unlit));
@ -849,19 +849,19 @@ JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.gltfMorphTarget>.Deser
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.gltfMorphTarget>.DeserializeField<System.Int32>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPrimitives>.DeserializeField<UniGLTF.glTFPrimitives_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPrimitives>.DeserializeField<UniGLTF.glTFPrimitives_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFPrimitives_extras
f.Serialize(default(UniGLTF.glTFPrimitives_extras));
{
var value = default(UniGLTF.glTFPrimitives_extras);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPrimitives_extras>.DeserializeField<System.Collections.Generic.List<String>>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// f.Serialize(default(UniGLTF.glTFPrimitives_extras));
// {
// var value = default(UniGLTF.glTFPrimitives_extras);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPrimitives_extras>.DeserializeField<System.Collections.Generic.List<String>>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// List`1
f.Serialize(default(List<System.String>));
@ -870,16 +870,16 @@ var value = default(List<System.String>);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
GenericDeserializer<JsonValue, List<System.String>>.GenericListDeserializer<System.String>(default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPrimitives>.DeserializeField<UniGLTF.glTFPrimitives_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPrimitives>.DeserializeField<UniGLTF.glTFPrimitives_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFPrimitives_extensions
f.Serialize(default(UniGLTF.glTFPrimitives_extensions));
{
var value = default(UniGLTF.glTFPrimitives_extensions);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
// // glTFPrimitives_extensions
// f.Serialize(default(UniGLTF.glTFPrimitives_extensions));
// {
// var value = default(UniGLTF.glTFPrimitives_extensions);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFMesh>.DeserializeField<System.Single[]>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
@ -945,26 +945,26 @@ JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFNode>.DeserializeF
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFNode>.DeserializeField<System.Int32>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFNode>.DeserializeField<UniGLTF.glTFNode_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFNode>.DeserializeField<UniGLTF.glTFNode_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFNode_extensions
f.Serialize(default(UniGLTF.glTFNode_extensions));
{
var value = default(UniGLTF.glTFNode_extensions);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFNode>.DeserializeField<UniGLTF.glTFNode_extra>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// // glTFNode_extensions
// f.Serialize(default(UniGLTF.glTFNode_extensions));
// {
// var value = default(UniGLTF.glTFNode_extensions);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFNode>.DeserializeField<UniGLTF.glTFNode_extra>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFNode_extra
f.Serialize(default(UniGLTF.glTFNode_extra));
{
var value = default(UniGLTF.glTFNode_extra);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
// // glTFNode_extra
// f.Serialize(default(UniGLTF.glTFNode_extra));
// {
// var value = default(UniGLTF.glTFNode_extra);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF>.DeserializeField<System.Collections.Generic.List<glTFSkin>>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
@ -1183,26 +1183,26 @@ JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFOrthographic>.Dese
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFOrthographic>.DeserializeField<System.Single>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFOrthographic>.DeserializeField<UniGLTF.glTFOrthographic_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFOrthographic>.DeserializeField<UniGLTF.glTFOrthographic_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFOrthographic_extensions
f.Serialize(default(UniGLTF.glTFOrthographic_extensions));
{
var value = default(UniGLTF.glTFOrthographic_extensions);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFOrthographic>.DeserializeField<UniGLTF.glTFOrthographic_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// // glTFOrthographic_extensions
// f.Serialize(default(UniGLTF.glTFOrthographic_extensions));
// {
// var value = default(UniGLTF.glTFOrthographic_extensions);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFOrthographic>.DeserializeField<UniGLTF.glTFOrthographic_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFOrthographic_extras
f.Serialize(default(UniGLTF.glTFOrthographic_extras));
{
var value = default(UniGLTF.glTFOrthographic_extras);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
// f.Serialize(default(UniGLTF.glTFOrthographic_extras));
// {
// var value = default(UniGLTF.glTFOrthographic_extras);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFCamera>.DeserializeField<UniGLTF.glTFPerspective>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
@ -1225,26 +1225,26 @@ JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPerspective>.Deser
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPerspective>.DeserializeField<System.Single>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPerspective>.DeserializeField<UniGLTF.glTFPerspective_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPerspective>.DeserializeField<UniGLTF.glTFPerspective_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFPerspective_extensions
f.Serialize(default(UniGLTF.glTFPerspective_extensions));
{
var value = default(UniGLTF.glTFPerspective_extensions);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPerspective>.DeserializeField<UniGLTF.glTFPerspective_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// // glTFPerspective_extensions
// f.Serialize(default(UniGLTF.glTFPerspective_extensions));
// {
// var value = default(UniGLTF.glTFPerspective_extensions);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFPerspective>.DeserializeField<UniGLTF.glTFPerspective_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFPerspective_extras
f.Serialize(default(UniGLTF.glTFPerspective_extras));
{
var value = default(UniGLTF.glTFPerspective_extras);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
// // glTFPerspective_extras
// f.Serialize(default(UniGLTF.glTFPerspective_extras));
// {
// var value = default(UniGLTF.glTFPerspective_extras);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFCamera>.DeserializeField<UniGLTF.ProjectionType>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
@ -1261,45 +1261,45 @@ JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.ProjectionType>.Deseri
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFCamera>.DeserializeField<System.String>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFCamera>.DeserializeField<UniGLTF.glTFCamera_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFCamera>.DeserializeField<UniGLTF.glTFCamera_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFCamera_extensions
f.Serialize(default(UniGLTF.glTFCamera_extensions));
{
var value = default(UniGLTF.glTFCamera_extensions);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFCamera>.DeserializeField<UniGLTF.glTFCamera_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// // glTFCamera_extensions
// f.Serialize(default(UniGLTF.glTFCamera_extensions));
// {
// var value = default(UniGLTF.glTFCamera_extensions);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTFCamera>.DeserializeField<UniGLTF.glTFCamera_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTFCamera_extras
f.Serialize(default(UniGLTF.glTFCamera_extras));
{
var value = default(UniGLTF.glTFCamera_extras);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
// // glTFCamera_extras
// f.Serialize(default(UniGLTF.glTFCamera_extras));
// {
// var value = default(UniGLTF.glTFCamera_extras);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF>.DeserializeField<System.Collections.Generic.List<String>>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF>.DeserializeField<System.Collections.Generic.List<String>>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF>.DeserializeField<UniGLTF.glTF_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF>.DeserializeField<UniGLTF.glTF_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTF_extensions
f.Serialize(default(UniGLTF.glTF_extensions));
{
var value = default(UniGLTF.glTF_extensions);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF_extensions>.DeserializeField<VRM.glTF_VRM_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// // glTF_extensions
// f.Serialize(default(UniGLTF.glTF_extensions));
// {
// var value = default(UniGLTF.glTF_extensions);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF_extensions>.DeserializeField<VRM.glTF_VRM_extensions>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// glTF_VRM_extensions
f.Serialize(default(VRM.glTF_VRM_extensions));
@ -1779,16 +1779,16 @@ var value = default(Dictionary<string, System.String>);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
GenericDeserializer<JsonValue, Dictionary<string, System.String>>.DictionaryDeserializer<System.String>(default(ListTreeNode<JsonValue>));
}
{
JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF>.DeserializeField<UniGLTF.gltf_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
}
// {
// JsonObjectValidator.GenericDeserializer<JsonValue,UniGLTF.glTF>.DeserializeField<UniGLTF.gltf_extras>(default(JsonSchema), default(ListTreeNode<JsonValue>));
// }
// gltf_extras
f.Serialize(default(UniGLTF.gltf_extras));
{
var value = default(UniGLTF.gltf_extras);
default(ListTreeNode<JsonValue>).Deserialize(ref value);
}
// // gltf_extras
// f.Serialize(default(UniGLTF.gltf_extras));
// {
// var value = default(UniGLTF.gltf_extras);
// default(ListTreeNode<JsonValue>).Deserialize(ref value);
// }
}
{

View File

@ -114,7 +114,7 @@ namespace VRM
return FirstPersonFlag.Auto;
}
foreach (var x in context.GLTF.extensions.VRM.firstPerson.meshAnnotations)
foreach (var x in context.VRM.firstPerson.meshAnnotations)
{
if (x.mesh == index)
{

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
using UnityEngine;
@ -23,11 +24,15 @@ namespace VRM
}
return gltf;
}
public readonly VRM.glTF_VRM_extensions VRM = new glTF_VRM_extensions();
public VRMExporter(glTF gltf) : base(gltf)
{
gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName);
gltf.extensions.VRM = new glTF_VRM_extensions();
gltf.extensions = new KeyValuePair<string, object>[]{
new KeyValuePair<string, object>("VRM", VRM)
};
}
public override void Export(MeshExportSettings configuration)
@ -51,7 +56,7 @@ namespace VRM
if (description != null)
{
// use description
glTF.extensions.VRM.humanoid.Apply(description, nodes);
VRM.humanoid.Apply(description, nodes);
}
if (isCreated)
@ -73,7 +78,7 @@ namespace VRM
var transform = animator.GetBoneTransform(key);
if (transform != null)
{
glTF.extensions.VRM.humanoid.SetNodeIndex(key, nodes.IndexOf(transform));
VRM.humanoid.SetNodeIndex(key, nodes.IndexOf(transform));
}
}
}
@ -88,15 +93,15 @@ namespace VRM
{
foreach (var x in avatar.Clips)
{
glTF.extensions.VRM.blendShapeMaster.Add(x, this);
VRM.blendShapeMaster.Add(x, this);
}
}
}
// secondary
VRMSpringUtility.ExportSecondary(Copy.transform, Nodes,
x => glTF.extensions.VRM.secondaryAnimation.colliderGroups.Add(x),
x => glTF.extensions.VRM.secondaryAnimation.boneGroups.Add(x)
x => VRM.secondaryAnimation.colliderGroups.Add(x),
x => VRM.secondaryAnimation.boneGroups.Add(x)
);
#pragma warning disable 0618
@ -105,17 +110,17 @@ namespace VRM
var meta = Copy.GetComponent<VRMMetaInformation>();
if (meta != null)
{
glTF.extensions.VRM.meta.author = meta.Author;
glTF.extensions.VRM.meta.contactInformation = meta.ContactInformation;
glTF.extensions.VRM.meta.title = meta.Title;
VRM.meta.author = meta.Author;
VRM.meta.contactInformation = meta.ContactInformation;
VRM.meta.title = meta.Title;
if (meta.Thumbnail != null)
{
glTF.extensions.VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown);
VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown);
}
glTF.extensions.VRM.meta.licenseType = meta.LicenseType;
glTF.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
glTF.extensions.VRM.meta.reference = meta.Reference;
VRM.meta.licenseType = meta.LicenseType;
VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
VRM.meta.reference = meta.Reference;
}
}
#pragma warning restore 0618
@ -128,28 +133,28 @@ namespace VRM
var meta = _meta.Meta;
// info
glTF.extensions.VRM.meta.version = meta.Version;
glTF.extensions.VRM.meta.author = meta.Author;
glTF.extensions.VRM.meta.contactInformation = meta.ContactInformation;
glTF.extensions.VRM.meta.reference = meta.Reference;
glTF.extensions.VRM.meta.title = meta.Title;
VRM.meta.version = meta.Version;
VRM.meta.author = meta.Author;
VRM.meta.contactInformation = meta.ContactInformation;
VRM.meta.reference = meta.Reference;
VRM.meta.title = meta.Title;
if (meta.Thumbnail != null)
{
glTF.extensions.VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown);
VRM.meta.texture = TextureIO.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail, glTFTextureTypes.Unknown);
}
// ussage permission
glTF.extensions.VRM.meta.allowedUser = meta.AllowedUser;
glTF.extensions.VRM.meta.violentUssage = meta.ViolentUssage;
glTF.extensions.VRM.meta.sexualUssage = meta.SexualUssage;
glTF.extensions.VRM.meta.commercialUssage = meta.CommercialUssage;
glTF.extensions.VRM.meta.otherPermissionUrl = meta.OtherPermissionUrl;
VRM.meta.allowedUser = meta.AllowedUser;
VRM.meta.violentUssage = meta.ViolentUssage;
VRM.meta.sexualUssage = meta.SexualUssage;
VRM.meta.commercialUssage = meta.CommercialUssage;
VRM.meta.otherPermissionUrl = meta.OtherPermissionUrl;
// distribution license
glTF.extensions.VRM.meta.licenseType = meta.LicenseType;
VRM.meta.licenseType = meta.LicenseType;
if (meta.LicenseType == LicenseType.Other)
{
glTF.extensions.VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl;
}
}
}
@ -160,9 +165,9 @@ namespace VRM
{
if (firstPerson.FirstPersonBone != null)
{
glTF.extensions.VRM.firstPerson.firstPersonBone = Nodes.IndexOf(firstPerson.FirstPersonBone);
glTF.extensions.VRM.firstPerson.firstPersonBoneOffset = firstPerson.FirstPersonOffset;
glTF.extensions.VRM.firstPerson.meshAnnotations = firstPerson.Renderers.Select(x => new glTF_VRM_MeshAnnotation
VRM.firstPerson.firstPersonBone = Nodes.IndexOf(firstPerson.FirstPersonBone);
VRM.firstPerson.firstPersonBoneOffset = firstPerson.FirstPersonOffset;
VRM.firstPerson.meshAnnotations = firstPerson.Renderers.Select(x => new glTF_VRM_MeshAnnotation
{
mesh = Meshes.IndexOf(x.SharedMesh),
firstPersonFlag = x.FirstPersonFlag.ToString(),
@ -178,18 +183,18 @@ namespace VRM
var blendShapeApplyer = Copy.GetComponent<VRMLookAtBlendShapeApplyer>();
if (boneApplyer != null)
{
glTF.extensions.VRM.firstPerson.lookAtType = LookAtType.Bone;
glTF.extensions.VRM.firstPerson.lookAtHorizontalInner.Apply(boneApplyer.HorizontalInner);
glTF.extensions.VRM.firstPerson.lookAtHorizontalOuter.Apply(boneApplyer.HorizontalOuter);
glTF.extensions.VRM.firstPerson.lookAtVerticalDown.Apply(boneApplyer.VerticalDown);
glTF.extensions.VRM.firstPerson.lookAtVerticalUp.Apply(boneApplyer.VerticalUp);
VRM.firstPerson.lookAtType = LookAtType.Bone;
VRM.firstPerson.lookAtHorizontalInner.Apply(boneApplyer.HorizontalInner);
VRM.firstPerson.lookAtHorizontalOuter.Apply(boneApplyer.HorizontalOuter);
VRM.firstPerson.lookAtVerticalDown.Apply(boneApplyer.VerticalDown);
VRM.firstPerson.lookAtVerticalUp.Apply(boneApplyer.VerticalUp);
}
else if (blendShapeApplyer != null)
{
glTF.extensions.VRM.firstPerson.lookAtType = LookAtType.BlendShape;
glTF.extensions.VRM.firstPerson.lookAtHorizontalOuter.Apply(blendShapeApplyer.Horizontal);
glTF.extensions.VRM.firstPerson.lookAtVerticalDown.Apply(blendShapeApplyer.VerticalDown);
glTF.extensions.VRM.firstPerson.lookAtVerticalUp.Apply(blendShapeApplyer.VerticalUp);
VRM.firstPerson.lookAtType = LookAtType.BlendShape;
VRM.firstPerson.lookAtHorizontalOuter.Apply(blendShapeApplyer.Horizontal);
VRM.firstPerson.lookAtVerticalDown.Apply(blendShapeApplyer.VerticalDown);
VRM.firstPerson.lookAtVerticalUp.Apply(blendShapeApplyer.VerticalUp);
}
}
}
@ -198,7 +203,7 @@ namespace VRM
// materials
foreach (var m in Materials)
{
glTF.extensions.VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager.Textures));
VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager.Textures));
}
}
}

View File

@ -1,16 +1,7 @@
using System;
using System.Collections.Generic;
using UniGLTF;
using UniJSON;
namespace UniGLTF
{
public partial class glTF_extensions : ExtensionsBase<glTF_extensions>
{
public VRM.glTF_VRM_extensions VRM;
}
}
namespace VRM
{

View File

@ -13,6 +13,14 @@ namespace VRM
const string HUMANOID_KEY = "humanoid";
const string MATERIAL_KEY = "materialProperties";
public VRM.glTF_VRM_extensions VRM
{
get
{
throw new NotImplementedException();
}
}
public VRMImporterContext()
{
}
@ -64,7 +72,7 @@ namespace VRM
using (MeasureTime("VRM LoadSecondary"))
{
VRMSpringUtility.LoadSecondary(Root.transform, Nodes,
GLTF.extensions.VRM.secondaryAnimation);
VRM.secondaryAnimation);
}
yield return null;
@ -97,7 +105,7 @@ namespace VRM
{
var firstPerson = Root.AddComponent<VRMFirstPerson>();
var gltfFirstPerson = GLTF.extensions.VRM.firstPerson;
var gltfFirstPerson = VRM.firstPerson;
if (gltfFirstPerson.firstPersonBone != -1)
{
firstPerson.FirstPersonBone = Nodes[gltfFirstPerson.firstPersonBone];
@ -130,7 +138,7 @@ namespace VRM
}
}
var blendShapeList = GLTF.extensions.VRM.blendShapeMaster.blendShapeGroups;
var blendShapeList = VRM.blendShapeMaster.blendShapeGroups;
if (blendShapeList != null && blendShapeList.Count > 0)
{
foreach (var x in blendShapeList)
@ -255,7 +263,7 @@ namespace VRM
private void LoadHumanoid()
{
AvatarDescription = GLTF.extensions.VRM.humanoid.ToDescription(Nodes);
AvatarDescription = VRM.humanoid.ToDescription(Nodes);
AvatarDescription.name = "AvatarDescription";
HumanoidAvatar = AvatarDescription.CreateAvatar(Root.transform);
if (!HumanoidAvatar.isValid || !HumanoidAvatar.isHuman)
@ -295,9 +303,9 @@ namespace VRM
{
var meta = ScriptableObject.CreateInstance<VRMMetaObject>();
meta.name = "Meta";
meta.ExporterVersion = GLTF.extensions.VRM.exporterVersion;
meta.ExporterVersion = VRM.exporterVersion;
var gltfMeta = GLTF.extensions.VRM.meta;
var gltfMeta = VRM.meta;
meta.Version = gltfMeta.version; // model version
meta.Author = gltfMeta.author;
meta.ContactInformation = gltfMeta.contactInformation;

View File

@ -35,7 +35,7 @@ namespace VRM
public void OnImported(VRMImporterContext context)
{
var gltfFirstPerson = context.GLTF.extensions.VRM.firstPerson;
var gltfFirstPerson = context.VRM.firstPerson;
Horizontal.Apply(gltfFirstPerson.lookAtHorizontalOuter);
VerticalDown.Apply(gltfFirstPerson.lookAtVerticalDown);
VerticalUp.Apply(gltfFirstPerson.lookAtVerticalUp);

View File

@ -36,7 +36,7 @@ namespace VRM
RightEye = OffsetOnTransform.Create(animator.GetBoneTransform(HumanBodyBones.RightEye));
}
var gltfFirstPerson = context.GLTF.extensions.VRM.firstPerson;
var gltfFirstPerson = context.VRM.firstPerson;
HorizontalInner.Apply(gltfFirstPerson.lookAtHorizontalInner);
HorizontalOuter.Apply(gltfFirstPerson.lookAtHorizontalOuter);
VerticalDown.Apply(gltfFirstPerson.lookAtVerticalDown);

View File

@ -99,7 +99,7 @@ namespace VRM
public void OnImported(VRMImporterContext context)
{
var gltfFirstPerson = context.GLTF.extensions.VRM.firstPerson;
var gltfFirstPerson = context.VRM.firstPerson;
switch (gltfFirstPerson.lookAtType)
{
case LookAtType.Bone: