示例#1
0
 public VtVec2fArray(VtVec2fArray other) : this(UsdCsPINVOKE.new_VtVec2fArray__SWIG_3(VtVec2fArray.getCPtr(other)), true)
 {
     if (UsdCsPINVOKE.SWIGPendingException.Pending)
     {
         throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#2
0
 public VtValue(VtVec2fArray obj) : this(UsdCsPINVOKE.new_VtValue__SWIG_44(VtVec2fArray.getCPtr(obj)), true)
 {
     if (UsdCsPINVOKE.SWIGPendingException.Pending)
     {
         throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#3
0
 public void swap(VtVec2fArray other)
 {
     UsdCsPINVOKE.VtVec2fArray_swap(swigCPtr, VtVec2fArray.getCPtr(other));
     if (UsdCsPINVOKE.SWIGPendingException.Pending)
     {
         throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#4
0
        public static bool Equals(VtVec2fArray lhs, VtVec2fArray rhs)
        {
            bool ret = UsdCsPINVOKE.VtVec2fArray_Equals(VtVec2fArray.getCPtr(lhs), VtVec2fArray.getCPtr(rhs));

            if (UsdCsPINVOKE.SWIGPendingException.Pending)
            {
                throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#5
0
        public bool IsIdentical(VtVec2fArray other)
        {
            bool ret = UsdCsPINVOKE.VtVec2fArray_IsIdentical(swigCPtr, VtVec2fArray.getCPtr(other));

            if (UsdCsPINVOKE.SWIGPendingException.Pending)
            {
                throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        static public List <UnityEngine.Vector2> ListFromVtArray(VtVec2fArray input)
        {
            var output = UsdIo.ArrayAllocator.Malloc <UnityEngine.Vector2>(input.size());

            unsafe
            {
                fixed(UnityEngine.Vector2 *p = output)
                {
                    input.CopyToArray((IntPtr)p);
                }
            }
            return(output.ToList());
        }
        // ----------------------------------------------------------------------------------------- //
        // Vector2 / Vec2f
        // ----------------------------------------------------------------------------------------- //
        static public VtVec2fArray ToVtArray(UnityEngine.Vector2[] input)
        {
            var output = new VtVec2fArray((uint)input.Length);

            unsafe
            {
                fixed(UnityEngine.Vector2 *p = input)
                {
                    output.CopyFromArray((IntPtr)p);
                }
            }
            return(output);
        }
示例#8
0
        static void LoadPrimvars(Scene scene,
                                 Mesh unityMesh,
                                 string usdMeshPath,
                                 List <string> primvars,
                                 int[] faceVertexCounts,
                                 int[] faceVertexIndices)
        {
            if (primvars == null || primvars.Count == 0)
            {
                return;
            }
            var prim = scene.GetPrimAtPath(usdMeshPath);

            for (int i = 0; i < primvars.Count; i++)
            {
                var attr = prim.GetAttribute(new TfToken("primvars:" + primvars[i]));
                if (!attr)
                {
                    continue;
                }

                // Read the raw values.
                VtValue val = attr.Get(0.0);
                if (val.IsEmpty())
                {
                    continue;
                }
                VtVec2fArray vec2fArray = UsdCs.VtValueToVtVec2fArray(val);
                Vector2[]    values     = UnityTypeConverter.FromVtArray(vec2fArray);

                // Unroll indexed primvars.
                var        pv        = new UsdGeomPrimvar(attr);
                VtIntArray vtIndices = new VtIntArray();
                if (pv.GetIndices(vtIndices, 0.0))
                {
                    int[] indices = UnityTypeConverter.FromVtArray(vtIndices);
                    values = indices.Select(idx => values[idx]).ToArray();
                }

                // Handle primvar interpolation modes.
                TfToken interp = pv.GetInterpolation();
                if (interp == UsdGeomTokens.constant)
                {
                    Debug.Assert(values.Length == 1);
                    var newValues = new Vector2[unityMesh.vertexCount];
                    for (int idx = 0; idx < values.Length; idx++)
                    {
                        newValues[idx] = values[0];
                    }
                    values = newValues;
                }
                else if (interp == UsdGeomTokens.uniform)
                {
                    Debug.Assert(values.Length == faceVertexCounts.Length);
                    for (int faceIndex = 0; faceIndex < values.Length; faceIndex++)
                    {
                        var faceColor = values[faceIndex];
                        int idx       = 0;
                        var newValues = new Vector2[unityMesh.vertexCount];
                        for (int f = 0; f < faceVertexCounts[faceIndex]; f++)
                        {
                            int vertexInFaceIdx = faceVertexIndices[idx++];
                            newValues[vertexInFaceIdx] = faceColor;
                        }
                        values = newValues;
                    }
                }
                else if (interp == UsdGeomTokens.faceVarying)
                {
                    values = UnrollFaceVarying(unityMesh.vertexCount, values, faceVertexCounts, faceVertexIndices);
                }

                // Send them to Unity.
                unityMesh.SetUVs(i, values.ToList());
            }
        }
示例#9
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VtVec2fArray obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }