index フォーマット uint8 に対応

This commit is contained in:
ousttrue
2022-05-12 16:43:41 +09:00
parent bf872c962f
commit 0be79c4dbc
2 changed files with 22 additions and 8 deletions

View File

@@ -157,6 +157,9 @@ namespace UniGLTF
}
switch (ComponentType)
{
case AccessorValueType.UNSIGNED_BYTE:
return ArrayManager.Convert(Bytes, (byte x) => (int)x);
case AccessorValueType.UNSIGNED_SHORT:
return ArrayManager.Convert(Bytes.Reinterpret<ushort>(1), (ushort x) => (int)x);

View File

@@ -65,16 +65,27 @@ namespace UniVRM10
// Indexを更新
switch (src.IndexBuffer.ComponentType)
{
case AccessorValueType.UNSIGNED_BYTE:
{
var intIndices = src.IndexBuffer.GetAsIntArray();
mesh.SetIndexBufferParams(intIndices.Length, IndexFormat.UInt32);
mesh.SetIndexBufferData(intIndices, 0, 0, intIndices.Length);
break;
}
case AccessorValueType.UNSIGNED_SHORT:
var shortIndices = src.IndexBuffer.Bytes.Reinterpret<ushort>(1);
mesh.SetIndexBufferParams(shortIndices.Length, IndexFormat.UInt16);
mesh.SetIndexBufferData(shortIndices, 0, 0, shortIndices.Length);
break;
{
var shortIndices = src.IndexBuffer.Bytes.Reinterpret<ushort>(1);
mesh.SetIndexBufferParams(shortIndices.Length, IndexFormat.UInt16);
mesh.SetIndexBufferData(shortIndices, 0, 0, shortIndices.Length);
break;
}
case AccessorValueType.UNSIGNED_INT:
var intIndices = src.IndexBuffer.Bytes.Reinterpret<uint>(1);
mesh.SetIndexBufferParams(intIndices.Length, IndexFormat.UInt32);
mesh.SetIndexBufferData(intIndices, 0, 0, intIndices.Length);
break;
{
var intIndices = src.IndexBuffer.Bytes.Reinterpret<uint>(1);
mesh.SetIndexBufferParams(intIndices.Length, IndexFormat.UInt32);
mesh.SetIndexBufferData(intIndices, 0, 0, intIndices.Length);
break;
}
default:
throw new NotImplementedException();
}