Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gltfのAnimationImporterをインターフェース化 #641

Merged
merged 2 commits into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[] GetArrayFromAccessorAsFloat(this glTF self, int accessorIndex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetFloatArrayFromAccessor のほうが命名として素直そう。
ArrayFloat に cast するように読める。

{
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