Ejemplo n.º 1
0
        public virtual UsdStage Manufacture()
        {
            global::System.IntPtr cPtr = UsdCsPINVOKE.UsdStageCacheRequest_Manufacture(swigCPtr);
            UsdStage ret = (cPtr == global::System.IntPtr.Zero) ? null : new UsdStage(cPtr, true);

            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs a new scene in memory, not backed by a file.
        /// </summary>
        ///
        /// <remarks>
        /// Note that SaveAs can be used to write memory to disk.
        /// </remarks>
        public static Scene Create()
        {
            var scene = new Scene(UsdStage.CreateInMemory());

            scene.UpAxis = UpAxes.Y;
            return(scene);
        }
Ejemplo n.º 3
0
 public UsdStageWeakPtr(UsdStage stage) : this(UsdCsPINVOKE.new_UsdStageWeakPtr(UsdStage.getCPtr(stage)), true)
 {
     if (UsdCsPINVOKE.SWIGPendingException.Pending)
     {
         throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Ejemplo n.º 4
0
        public UsdStage __deref__()
        {
            global::System.IntPtr cPtr = UsdCsPINVOKE.UsdStageWeakPtr___deref__(swigCPtr);
            UsdStage ret = (cPtr == global::System.IntPtr.Zero) ? null : new UsdStage(cPtr, true);

            return(ret);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructs a scene from an existing stage.
 /// </summary>
 public static Scene Open(UsdStage stage)
 {
     if (stage == null)
     {
         throw new NullReferenceException("Null stage");
     }
     return(new Scene(stage));
 }
Ejemplo n.º 6
0
 public UsdStageCache.Id Insert(UsdStage stage)
 {
     UsdStageCache.Id ret = new UsdStageCache.Id(UsdCsPINVOKE.UsdStageCache_Insert(swigCPtr, UsdStage.getCPtr(stage)), true);
     if (UsdCsPINVOKE.SWIGPendingException.Pending)
     {
         throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
     }
     return(ret);
 }
Ejemplo n.º 7
0
        public static void BadPrimTest()
        {
            var stage = UsdStage.CreateInMemory();
            var prim  = stage.GetPrimAtPath(new SdfPath("/Foo"));

            AssertTrue(prim != null);
            AssertTrue(prim.IsValid() == false);
            stage.Dispose();
        }
Ejemplo n.º 8
0
        public virtual bool IsSatisfiedBy(UsdStage stage)
        {
            bool ret = UsdCsPINVOKE.UsdStageCacheRequest_IsSatisfiedBy__SWIG_0(swigCPtr, UsdStage.getCPtr(stage));

            if (UsdCsPINVOKE.SWIGPendingException.Pending)
            {
                throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 9
0
        public bool Erase(UsdStage stage)
        {
            bool ret = UsdCsPINVOKE.UsdStageCache_Erase__SWIG_1(swigCPtr, UsdStage.getCPtr(stage));

            if (UsdCsPINVOKE.SWIGPendingException.Pending)
            {
                throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 10
0
        public SWIGTYPE_p_UsdStageCache__Id GetId(UsdStage stage)
        {
            SWIGTYPE_p_UsdStageCache__Id ret = new SWIGTYPE_p_UsdStageCache__Id(UsdCsPINVOKE.UsdStageCache_GetId(swigCPtr, UsdStage.getCPtr(stage)), true);

            if (UsdCsPINVOKE.SWIGPendingException.Pending)
            {
                throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Opens an existing USD file for reading.
        /// An exception is thrown if the filePath cannot be opened.
        /// </summary>
        public static Scene Open(string filePath)
        {
            var stage = UsdStage.Open(filePath);

            if (stage == null)
            {
                throw new ApplicationException("Failed to open: " + filePath);
            }
            return(new Scene(stage));
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor declared private to force access through the static factories.
 /// </summary>
 private Scene(UsdStage stage)
 {
     if (stage == null)
     {
         throw new System.NullReferenceException("Scene was constructed with a null UsdStage");
     }
     m_stage = stage;
     m_usdIo = new UsdIo(m_stageLock);
     // Initialize Time / TimeCode to UsdTimeCode.Default();
     Time = null;
 }
Ejemplo n.º 13
0
        public UsdStage FindOneMatching(SdfLayerHandle rootLayer, SdfLayerHandle sessionLayer, ArResolverContext pathResolverContext)
        {
            global::System.IntPtr cPtr = UsdCsPINVOKE.UsdStageCache_FindOneMatching__SWIG_3(swigCPtr, SdfLayerHandle.getCPtr(rootLayer), SdfLayerHandle.getCPtr(sessionLayer), ArResolverContext.getCPtr(pathResolverContext));
            UsdStage ret = (cPtr == global::System.IntPtr.Zero) ? null : new UsdStage(cPtr, true);

            if (UsdCsPINVOKE.SWIGPendingException.Pending)
            {
                throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 14
0
        public UsdStage Find(UsdStageCache.Id id)
        {
            global::System.IntPtr cPtr = UsdCsPINVOKE.UsdStageCache_Find(swigCPtr, UsdStageCache.Id.getCPtr(id));
            UsdStage ret = (cPtr == global::System.IntPtr.Zero) ? null : new UsdStage(cPtr, true);

            if (UsdCsPINVOKE.SWIGPendingException.Pending)
            {
                throw UsdCsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Constructs a new scene at the given file path. If the file exists, it is erased, if
        /// the file is in use or cannot be created, an exception is thrown.
        /// </summary>
        public static Scene Create(string filePath)
        {
            var stage = UsdStage.CreateNew(filePath);

            if (stage == null)
            {
                throw new ApplicationException("Failed to create: " + filePath);
            }
            var scene = new Scene(stage);

            scene.UpAxis = UpAxes.Y;
            return(scene);
        }
Ejemplo n.º 16
0
        public static void MemoryTest()
        {
            const int kCount = 100;

            for (int i = 0; i < kCount; i++)
            {
                UsdStage s = UsdStage.CreateInMemory();
                if (s == null)
                {
                    throw new Exception("Init Stage failed");
                }
                s.Dispose();

                string   tmpName = GetTempFile();
                UsdStage ss      = UsdStage.CreateNew(tmpName);
                if (ss == null)
                {
                    throw new Exception("Init Stage failed");
                }
                ss.Dispose();
                System.IO.File.Delete(tmpName);
            }
        }
Ejemplo n.º 17
0
 public UsdStageCacheResultPair(UsdStage t, bool u) : this(UsdCsPINVOKE.new_UsdStageCacheResultPair__SWIG_1(UsdStage.getCPtr(t), u), true)
 {
 }
Ejemplo n.º 18
0
        public static void TraverseTest()
        {
            //
            // Setup a stage with parents and children.
            // TODO: Add tests with classes and instancing.
            //
            UsdStage s   = UsdStage.CreateInMemory();
            var      foo = s.DefinePrim(new SdfPath("/Foo"));

            s.DefinePrim(new SdfPath("/Foo/P1"));
            s.DefinePrim(new SdfPath("/Foo/P2"));
            s.DefinePrim(new SdfPath("/Foo/P3"));
            s.DefinePrim(new SdfPath("/Foo/P4"));
            s.DefinePrim(new SdfPath("/Foo/P5"));
            var bar = s.DefinePrim(new SdfPath("/Bar"));

            s.DefinePrim(new SdfPath("/Bar/B1"));
            s.DefinePrim(new SdfPath("/Bar/B2"));
            s.DefinePrim(new SdfPath("/Bar/B3"));
            s.DefinePrim(new SdfPath("/Bar/B3/C1"));
            s.DefinePrim(new SdfPath("/Bar/B3/C2"));
            s.DefinePrim(new SdfPath("/Bar/B3/C3"));
            s.DefinePrim(new SdfPath("/Bar/B4"));

            // Prim children
            Console.WriteLine("");
            Console.WriteLine("Foo children:");
            foreach (UsdPrim curPrim in foo.GetChildren())
            {
                Console.WriteLine(curPrim.GetPath());
            }

            Console.WriteLine("");
            Console.WriteLine("Bar children:");
            foreach (UsdPrim curPrim in bar.GetChildren())
            {
                Console.WriteLine(curPrim.GetPath());
            }

            // Prim Descendants
            Console.WriteLine("");
            Console.WriteLine("Bar descendants:");
            foreach (UsdPrim curPrim in bar.GetDescendants())
            {
                Console.WriteLine(curPrim.GetPath());
            }

            // Basic Stage traversal.
            Console.WriteLine("");
            Console.WriteLine("All Prims:");
            List <UsdPrim> primList = s.Traverse().ToList();
            int            i        = 0;

            foreach (UsdPrim curPrim in s.Traverse())
            {
                Console.WriteLine(curPrim.GetPath());
                AssertEqual(primList[i++], curPrim);
            }

            // Traversal with child pruning.
            Console.WriteLine("");
            Console.WriteLine("/Bar children pruned:");
            var range = new USD.NET.RangeIterator(s.Traverse());

            foreach (UsdPrim curPrim in range)
            {
                Console.WriteLine(curPrim.GetPath());
                if (curPrim.GetPath() == "/Bar/B3")
                {
                    range.PruneChildren();
                    Console.WriteLine("pruned.");
                }
            }

            // Fully general pre/post traversal.
            Console.WriteLine("");
            Console.WriteLine("Pre/Post Traversal with all children pruned:");
            var prePostRange = new USD.NET.RangeIterator(UsdPrimRange.PreAndPostVisit(s.GetPseudoRoot()));

            bool[] expected = { false, false, true, false, true, true };
            bool[] actual   = new bool[6];
            i = 0;
            foreach (UsdPrim curPrim in prePostRange)
            {
                Console.WriteLine("IsPostVisit: " + prePostRange.IsPostVisit().ToString()
                                  + ", " + curPrim.GetPath());
                if (!prePostRange.IsPostVisit() && i > 0)
                {
                    // It's only valid to prune on the pre-traversal.
                    prePostRange.PruneChildren();
                }

                actual[i++] = prePostRange.IsPostVisit();
            }
            AssertEqual(expected, actual);
        }
Ejemplo n.º 19
0
 public static void PointerTest()
 {
     UsdStage s = UsdStage.CreateInMemory();
 }
Ejemplo n.º 20
0
        public static void ApiTest()
        {
            UsdStage s    = UsdStage.CreateInMemory();
            var      prim = s.DefinePrim(new SdfPath("/Foo"));

            s.SetStartTimeCode(1.0);
            s.SetEndTimeCode(10.0);
            AssertEqual(1.0, s.GetStartTimeCode());
            AssertEqual(10.0, s.GetEndTimeCode());

            var defultPrimToken = new TfToken("defaultPrim");
            var value           = new VtValue();

            // Verify initial default prim / built-in metadata states.
            {
                AssertFalse(s.HasDefaultPrim());
                AssertFalse(s.GetDefaultPrim().IsValid());

                // defaultPrim is always valid metadata, it's built-in.
                AssertTrue(s.HasMetadata(defultPrimToken));
                // But it should not yet have an *authored* value.
                AssertFalse(s.HasAuthoredMetadata(defultPrimToken));
                // Even though it's not authored, reading it should succeed.
                AssertTrue(s.GetMetadata(defultPrimToken, value));
                AssertEqual(((TfToken)value).ToString(), "");
            }

            // Set the default prim, which should set the defaultPrim metadata.
            s.SetDefaultPrim(prim);
            {
                // Verify via the Stage API
                AssertTrue(s.HasDefaultPrim());
                AssertTrue(s.GetDefaultPrim().IsValid());
                AssertEqual(s.GetDefaultPrim().GetPath(), new SdfPath("/Foo"));

                // Verify via the metadata API
                AssertTrue(s.HasMetadata(defultPrimToken));
                AssertTrue(s.HasAuthoredMetadata(defultPrimToken));
                AssertTrue(s.GetMetadata(defultPrimToken, value));
                AssertEqual(((TfToken)value).ToString(), "Foo");
            }

            string str = s.GetRootLayer().ExportToString();

            s.ClearDefaultPrim();
            {
                AssertFalse(s.HasDefaultPrim());
                AssertFalse(s.GetDefaultPrim().IsValid());
                AssertFalse(s.HasAuthoredMetadata(defultPrimToken));
                AssertTrue(s.GetMetadata(defultPrimToken, value));
                AssertEqual(((TfToken)value).ToString(), "");
            }

            var classPrim = s.CreateClassPrim(new SdfPath("/Foo_class_"));

            {
                AssertTrue(classPrim.IsValid());
                AssertEqual(classPrim.GetPath(), new SdfPath("/Foo_class_"));
            }

            AssertEqual(s.GetFramesPerSecond(), 24.0);
            s.SetFramesPerSecond(90.0);
            AssertEqual(s.GetFramesPerSecond(), 90.0);
        }
Ejemplo n.º 21
0
        public static void CurvesTest()
        {
            UsdStage stage       = UsdStage.CreateInMemory();
            var      path        = new SdfPath("/Parent/Curves");
            var      curvesGprim = UsdGeomBasisCurves.Define(new UsdStageWeakPtr(stage), path);
            var      vertCounts  = USD.NET.IntrinsicTypeConverter.ToVtArray(new int[] { 4 });
            var      basisAttr   = curvesGprim.CreateBasisAttr(UsdGeomTokens.bezier);

            curvesGprim.CreateCurveVertexCountsAttr(vertCounts);

            var basisCurves = new BasisCurvesSample();

            basisCurves.basis             = BasisCurvesSample.Basis.Bspline;
            basisCurves.type              = BasisCurvesSample.CurveType.Cubic;
            basisCurves.wrap              = BasisCurvesSample.WrapMode.Nonperiodic;
            basisCurves.colors            = new UnityEngine.Color[4];
            basisCurves.colors[0]         = new UnityEngine.Color(1, 2, 3, 4);
            basisCurves.colors[3]         = new UnityEngine.Color(6, 7, 8, 9);
            basisCurves.curveVertexCounts = new int[1] {
                4
            };
            basisCurves.doubleSided = true;
            basisCurves.normals     = new UnityEngine.Vector3[4];
            basisCurves.normals[0]  = new UnityEngine.Vector3(1, 0, 0);
            basisCurves.normals[3]  = new UnityEngine.Vector3(0, 0, 1);

            basisCurves.widths    = new float[4];
            basisCurves.widths[0] = .5f;
            basisCurves.widths[1] = 1f;
            basisCurves.widths[2] = .2f;
            basisCurves.widths[3] = 2f;

            basisCurves.orientation = USD.NET.Orientation.RightHanded;
            basisCurves.points      = new UnityEngine.Vector3[4];
            basisCurves.points[0]   = new UnityEngine.Vector3(1, 2, 3);
            basisCurves.points[3]   = new UnityEngine.Vector3(7, 8, 9);

            basisCurves.velocities    = new UnityEngine.Vector3[4];
            basisCurves.velocities[0] = new UnityEngine.Vector3(11, 22, 33);
            basisCurves.velocities[3] = new UnityEngine.Vector3(77, 88, 99);

            basisCurves.wrap      = BasisCurvesSample.WrapMode.Periodic;
            basisCurves.transform = UnityEngine.Matrix4x4.identity;

            var basisCurves2 = new BasisCurvesSample();

            WriteAndRead(ref basisCurves, ref basisCurves2, true);

            AssertEqual(basisCurves.basis, basisCurves2.basis);
            AssertEqual(basisCurves.colors, basisCurves2.colors);
            AssertEqual(basisCurves.curveVertexCounts, basisCurves2.curveVertexCounts);
            AssertEqual(basisCurves.doubleSided, basisCurves2.doubleSided);
            AssertEqual(basisCurves.normals, basisCurves2.normals);
            AssertEqual(basisCurves.orientation, basisCurves2.orientation);
            AssertEqual(basisCurves.points, basisCurves2.points);
            AssertEqual(basisCurves.type, basisCurves2.type);
            AssertEqual(basisCurves.velocities, basisCurves2.velocities);
            AssertEqual(basisCurves.widths, basisCurves2.widths);
            AssertEqual(basisCurves.wrap, basisCurves2.wrap);
            AssertEqual(basisCurves.transform, basisCurves2.transform);
            AssertEqual(basisCurves.xformOpOrder, basisCurves2.xformOpOrder);
        }