Skip to content

Commit

Permalink
Merge pull request #641 from hiroj/add_animationImporter_interface
Browse files Browse the repository at this point in the history
gltfのAnimationImporterをインターフェース化
  • Loading branch information
hiroj authored Dec 24, 2020
2 parents 1be9853 + bc56184 commit 2c72e00
Show file tree
Hide file tree
Showing 10 changed files with 461 additions and 338 deletions.
29 changes: 29 additions & 0 deletions Assets/UniGLTF/Runtime/Extensions/glTFExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,35 @@ public static T[] GetArrayFromAccessor<T>(this glTF self, int accessorIndex) whe
return result;
}

public static float[] GetFloatArrayFromAccessor(this glTF self, int accessorIndex)
{
var vertexAccessor = self.accessors[accessorIndex];

if (vertexAccessor.count <= 0) return new float[] { };

var bufferCount = vertexAccessor.count * vertexAccessor.TypeCount;
var result = (vertexAccessor.bufferView != -1)
? self.GetAttrib<float>(bufferCount, vertexAccessor.byteOffset, self.bufferViews[vertexAccessor.bufferView])
: new float[bufferCount]
;

var sparse = vertexAccessor.sparse;
if (sparse != null && sparse.count > 0)
{
// override sparse values
var indices = self._GetIndices(self.bufferViews[sparse.indices.bufferView], sparse.count, sparse.indices.byteOffset, sparse.indices.componentType);
var values = self.GetAttrib<float>(sparse.count * vertexAccessor.TypeCount, sparse.values.byteOffset, self.bufferViews[sparse.values.bufferView]);

var it = indices.GetEnumerator();
for (int i = 0; i < sparse.count; ++i)
{
it.MoveNext();
result[it.Current] = values[i];
}
}
return result;
}

public static ArraySegment<Byte> GetImageBytes(this glTF self, IStorage storage, int imageIndex, out string textureName)
{
var image = self.images[imageIndex];
Expand Down
334 changes: 0 additions & 334 deletions Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationImporter.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Assets/UniGLTF/Runtime/UniGLTF/IO/AnimationImporter.cs.meta

This file was deleted.

Loading

0 comments on commit 2c72e00

Please sign in to comment.