public bool MoveNext() { m_i++; bool valid = m_i < m_paths.Length; if (valid) { m_currentSample.path = m_paths[m_i]; m_currentSample.sample = new T(); m_scene.Read(m_currentSample.path, m_currentSample.sample); } return(valid); }
/// Plays back a named transform onto the current transform from a usd path. /// The transform can optionally be smoothed using exponential smoothing. /// Smoothing will be clamped between 0 - 1. public void StartPlayback(string sketchName = "/Sketch", string xformName = "/VideoCamera", float smoothing = 0) { m_xformName = xformName; m_Smoothing = Mathf.Clamp01(smoothing); m_IsRecording = false; // Older versions of Tilt Brush exported usda camera paths in decimeters. We now // export in meters to match USD geometry export. Older versions also didn't export any sketch // data so we check here for the presence of sketch data to decide how to treat the camera // path units. bool hasSketchRoot = m_Scene.Stage.GetPrimAtPath(new pxr.SdfPath(sketchName)); m_xformName = hasSketchRoot ? sketchName + xformName : xformName; float scale = hasSketchRoot ? App.UNITS_TO_METERS : 1; m_UnitsInMeters = hasSketchRoot; m_Scene.Time = null; m_UsdCameraInfo = new UsdCameraSample(); m_UsdCameraInfo.shutter = new USD.NET.Unity.CameraSample.Shutter(); m_Scene.Read(m_xformName, m_UsdCameraInfo); m_UsdCamera = new UsdCameraXformSample(); m_Scene.Time = 0; m_Scene.Read(m_xformName, m_UsdCamera); var basisMat = AxisConvention.GetFromUnity(AxisConvention.kUsd) * Matrix4x4.Scale(Vector3.one * scale); m_UsdCamera.transform = ExportUtils.ChangeBasis(m_UsdCamera.transform, basisMat, basisMat.inverse); TrTransform xf_WS = UsdXformToWorldSpaceXform(m_UsdCamera); xf_WS.ToTransform(transform); m_PlaybackCameras = FindObjectsOfType <Camera>(); }