TextureTransformTest

This commit is contained in:
ousttrue 2020-11-20 19:53:25 +09:00
parent 07729d8f9c
commit 4ceafe62a4
5 changed files with 106 additions and 35 deletions

View File

@ -29,6 +29,7 @@ namespace UniGLTF
var materialExporter = new MaterialExporter();
var gltfMaterial = materialExporter.ExportMaterial(srcMaterial, textureManager);
gltfMaterial.pbrMetallicRoughness.baseColorTexture.extensions.Parse();
var shaderStore = new ShaderStore(null);
var materialImporter = new MaterialImporter(shaderStore, (int index) => { return null; });

View File

@ -28,7 +28,7 @@ namespace UniGLTF
#endregion
#region for Import
readonly ListTreeNode<JsonValue> m_json;
ListTreeNode<JsonValue> m_json;
public glTFExtension(ListTreeNode<JsonValue> json)
{
m_json = json;
@ -45,6 +45,27 @@ namespace UniGLTF
}
}
#endregion
/// <summary>
/// for unit test
///
/// parse exported value
/// </summary>
public void Parse()
{
var f = new JsonFormatter();
f.BeginMap();
foreach (var kv in Serialized)
{
f.Key(kv.Key);
f.Raw(kv.Value);
}
f.EndMap();
var b = f.GetStoreBytes();
var json = Encoding.UTF8.GetString(b.Array, b.Offset, b.Count);
m_json = json.ParseAsJson();
}
}
public static class GltfExtensionFormatterExtensions

View File

@ -33,17 +33,20 @@ namespace UniGLTF
public static bool TryGet(glTFMesh mesh, out List<string> targetNames)
{
foreach (var kv in mesh.extras.ObjectItems())
if (mesh.extras != null)
{
if (kv.Key.GetUtf8String() == ExtraNameUtf8)
foreach (var kv in mesh.extras.ObjectItems())
{
targetNames = Deserialize(kv.Value);
return true;
if (kv.Key.GetUtf8String() == ExtraNameUtf8)
{
targetNames = Deserialize(kv.Value);
return true;
}
}
}
// use first primitive
if (mesh.primitives.Count > 0)
if (mesh.primitives.Count > 0 && mesh.primitives[0].extras != null)
{
foreach (var kv in mesh.primitives[0].extras.ObjectItems())
{

View File

@ -268,20 +268,10 @@ namespace UniGLTF
var primitive = mesh.primitives.FirstOrDefault();
var targets = primitive.targets;
List<string> targetNames;
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.");
// }
if (!gltf_mesh_extras_targetNames.TryGet(mesh, out List<string> targetNames))
{
throw new Exception("glTF BlendShape Animation. targetNames invalid.");
}
var keyNames = targetNames
.Where(x => !string.IsNullOrEmpty(x))
@ -307,7 +297,7 @@ namespace UniGLTF
}
return values;
});
}
break;

View File

@ -59,35 +59,91 @@ namespace VRM
}
public static string ToJson(this glTF_VRM_MaterialValueBind self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_BlendShapeBind self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_BlendShapeGroup self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_DegreeMap self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_MeshAnnotation self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_Firstperson self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_HumanoidBone self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_Humanoid self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_Material self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_Meta self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_SecondaryAnimationCollider self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_SecondaryAnimationColliderGroup self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_SecondaryAnimationGroup self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
public static string ToJson(this glTF_VRM_SecondaryAnimation self)
{ return ""; }
{
var f = new JsonFormatter();
f.GenSerialize(self);
return f.ToString();
}
}
public class UniVRMSerializeTests