diff --git forkSrcPrefix/com.unity.formats.alembic/Runtime/Scripts/Importer/Behaviours/AlembicCurvesRenderer.cs forkDstPrefix/com.unity.formats.alembic/Runtime/Scripts/Importer/Behaviours/AlembicCurvesRenderer.cs index 9b0be07f2aa46c113eabb8af8d2e1f74eb194e5f..4650e8fccb0c9aaa0d0ae4e5865268c5eeff7e19 100644 --- forkSrcPrefix/com.unity.formats.alembic/Runtime/Scripts/Importer/Behaviours/AlembicCurvesRenderer.cs +++ forkDstPrefix/com.unity.formats.alembic/Runtime/Scripts/Importer/Behaviours/AlembicCurvesRenderer.cs @@ -168,6 +168,7 @@ namespace UnityEngine.Formats.Alembic.Importer using (var particleTangent = new NativeArray(positionsM.Length, Allocator.TempJob)) using (var particleUV = new NativeArray(positionsM.Length, Allocator.TempJob)) using (var indices = new NativeArray(indexArraySize, Allocator.TempJob)) + using (var color = new NativeArray(positionsM.Length, Allocator.TempJob)) { vertices.CopyFrom(positionsM); strideArray.CopyFrom(curveOffsetM); @@ -198,7 +199,8 @@ namespace UnityEngine.Formats.Alembic.Importer strideArray = strideArray, particleTangent = particleTangent, vertices = vertices, - particleUV = particleUV + particleUV = particleUV, + color = color }; job.Schedule(curveCount, 1).Complete(); @@ -216,6 +218,24 @@ namespace UnityEngine.Formats.Alembic.Importer theMesh.SetUVs(5, curves.Velocities); } + if (curves.attributes.Length > 0) + { + unsafe + { + // if (split.attributes[0].type1 == aiPropertyType.Float2) accordingly + List colors = new List(); + for(int i=0 ; i<2 ; ++i) + { + if (curves.attributes[0].data==null) break; + colors.Add(*(((Color*)(curves.attributes[0].data))+i)); + } + if (colors.Count==2) + theMesh.SetColors(colors); + } + } + + + theMesh.RecalculateBounds(); theMesh.Optimize(); } @@ -230,6 +250,7 @@ namespace UnityEngine.Formats.Alembic.Importer [WriteOnly] public NativeArray indices; [WriteOnly] public NativeArray particleTangent; [WriteOnly] public NativeArray particleUV; + [WriteOnly] public NativeArray color; [Unity.Collections.ReadOnly] public NativeArray curveCounts, strideArray; [Unity.Collections.ReadOnly] public NativeArray vertices; @@ -240,6 +261,7 @@ namespace UnityEngine.Formats.Alembic.Importer var indicesPtr = (int*)indices.GetUnsafePtr(); var particleTangentPtr = (Vector3*)particleTangent.GetUnsafePtr(); var particleUVPtr = (Vector2*)particleUV.GetUnsafePtr(); + var colorPTR= (Color*)color.GetUnsafePtr(); var curvePointCount = curveCounts[curveIdx]; var strandParticleBegin = strideArray[curveIdx];