public static void ImportModel(string path) { path = Path.Combine(App.MediaLibraryPath(), "Models", path); var model = new Model(Model.Location.File(path)); model.LoadModel(); var tr = new TrTransform(); tr.translation = ApiManager.Instance.BrushPosition; tr.rotation = ApiManager.Instance.BrushRotation; CreateWidgetCommand createCommand = new CreateWidgetCommand( WidgetManager.m_Instance.ModelWidgetPrefab, tr); SketchMemoryScript.m_Instance.PerformAndRecordCommand(createCommand); ModelWidget modelWidget = createCommand.Widget as ModelWidget; modelWidget.Model = model; modelWidget.Show(true); createCommand.SetWidgetCost(modelWidget.GetTiltMeterCost()); WidgetManager.m_Instance.WidgetsDormant = false; SketchControlsScript.m_Instance.EatGazeObjectInput(); SelectionManager.m_Instance.RemoveFromSelection(false); }
/// Spawn a model. /// Precondition: Model must have m_Valid == true. protected void SpawnValidModel(Model model) { if (!model.m_Valid) { throw new InvalidOperationException("model must be valid"); } // Button forward is into the panel, not out of the panel; so flip it around TrTransform xfSpawn = Coords.AsGlobal[transform] * TrTransform.R(Quaternion.AngleAxis(180, Vector3.up)); CreateWidgetCommand createCommand = new CreateWidgetCommand( WidgetManager.m_Instance.ModelWidgetPrefab, xfSpawn, m_PreviewBaseRotation); SketchMemoryScript.m_Instance.PerformAndRecordCommand(createCommand); ModelWidget modelWidget = createCommand.Widget as ModelWidget; modelWidget.Model = model; modelWidget.Show(true); createCommand.SetWidgetCost(modelWidget.GetTiltMeterCost()); WidgetManager.m_Instance.WidgetsDormant = false; SketchControlsScript.m_Instance.EatGazeObjectInput(); SelectionManager.m_Instance.RemoveFromSelection(false); }
public static void ImportImage(string path) { path = Path.Combine(App.MediaLibraryPath(), "Images", path); var image = new ReferenceImage(path); image.RequestLoad(allowMainThread: true); var tr = new TrTransform(); tr.translation = ApiManager.Instance.BrushPosition; tr.rotation = ApiManager.Instance.BrushRotation; CreateWidgetCommand createCommand = new CreateWidgetCommand( WidgetManager.m_Instance.ImageWidgetPrefab, tr); SketchMemoryScript.m_Instance.PerformAndRecordCommand(createCommand); ImageWidget imageWidget = createCommand.Widget as ImageWidget; imageWidget.ReferenceImage = image; imageWidget.Show(true); createCommand.SetWidgetCost(imageWidget.GetTiltMeterCost()); WidgetManager.m_Instance.WidgetsDormant = false; SketchControlsScript.m_Instance.EatGazeObjectInput(); SelectionManager.m_Instance.RemoveFromSelection(false); }