public virtual void Setup() { // do this here ?? behaviors = new InputBehaviorSet(); SpatialDeviceGrabBehavior behavior = new SpatialDeviceGrabBehavior(Scene.Context, (so) => { return(so == this.Target); }) { Priority = 1, RotationSpeed = 0.25f, TranslationSpeed = 0.25f }; behaviors.Add(behavior); indicators = new ToolIndicatorSet(this, Scene); float h = 300.0f; Frame3f f1 = Frame3f.Identity.Rotated(Quaternionf.AxisAngleD(Vector3f.AxisZ, 90.0f)).Translated(h * 0.5f * Vector3f.AxisY); var plane1 = new SectionPlaneIndicator() { Width = fDimension.Scene(h), // in mm SceneFrameF = () => { return(f1); } }; indicators.AddIndicator(plane1); Frame3f f2 = Frame3f.Identity.Rotated(Quaternionf.AxisAngleD(Vector3f.AxisX, 90.0f)).Translated(h * 0.5f * Vector3f.AxisY); var plane2 = new SectionPlaneIndicator() { Width = fDimension.Scene(h), // in mm SceneFrameF = () => { return(f2); } }; indicators.AddIndicator(plane2); }
public void Initialize(Cockpit cockpit) { cockpit.Name = "photoCockpit"; // Configure how the cockpit moves cockpit.PositionMode = Cockpit.MovementMode.TrackPosition; // [RMS] use orientation mode to make cockpit follow view orientation. // (however default widgets below are off-screen!) //cockpit.PositionMode = Cockpit.MovementMode.TrackOrientation; // Add some UI elements to the cockpit // - cylinder & box buttons - double-click or drag/drop into scene // - button to start and cancel draw-primitives tool float fHUDRadius = 1.0f; Color bgColor = new Color(0.7f, 0.7f, 1.0f, 0.7f); Material bgMaterial = (bgColor.a == 1.0f) ? MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor); Material primMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow); float fButtonsY = -50.0f; // degrees float fButtonsSpacing = 15.0f; float fPrimitivesX = -35.0f; DropPrimitiveButton cylinderButton = add_primitive_button(cockpit, "create_cylinder", fHUDRadius, fPrimitivesX, fButtonsY, PrimitiveType.Cylinder, SOTypes.Cylinder, 0.7f, bgMaterial, primMaterial, () => { return(new CylinderSO().Create(cockpit.Scene.DefaultSOMaterial)); }); cockpit.AddUIElement(cylinderButton); DropPrimitiveButton boxButton = add_primitive_button(cockpit, "create_box", fHUDRadius, fPrimitivesX + fButtonsSpacing, fButtonsY, PrimitiveType.Cube, SOTypes.Box, 0.8f, bgMaterial, primMaterial, () => { return(new BoxSO().Create(cockpit.Scene.DefaultSOMaterial)); }); cockpit.AddUIElement(boxButton); float fToolsX = 35.0f; float fToolButtonRadius = 0.08f; // buttons for draw-primitive tool and cancel-tool button ActivateToolButton drawPrimButton = add_tool_button(cockpit, DrawSurfaceCurveTool.Identifier, fHUDRadius, fToolsX - fButtonsSpacing, fButtonsY, fToolButtonRadius, bgMaterial, primMaterial, new toolInfo() { identifier = DrawSurfaceCurveTool.Identifier, sMeshPath = "draw_primitive", fMeshScaleFudge = 1.2f }); cockpit.AddUIElement(drawPrimButton); ActivateToolButton cancelButton = add_tool_button(cockpit, "cancel", fHUDRadius, fToolsX, fButtonsY, fToolButtonRadius, bgMaterial, primMaterial, new toolInfo() { identifier = "cancel", sMeshPath = "cancel", fMeshScaleFudge = 1.2f }); cockpit.AddUIElement(cancelButton); // Configure interaction behaviors // - below we add behaviors for mouse, gamepad, and spatial devices (oculus touch, etc) // - keep in mind that Tool objects will register their own behaviors when active // setup key handlers (need to move to behavior...) cockpit.AddKeyHandler(new SampleKeyHandler(cockpit.Context)); // these behaviors let us interact with UIElements (ie left-click/trigger, or either triggers for Touch) cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRGamepadUIBehavior(cockpit.Context) { Priority = 0 }); cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context) { Priority = 0 }); // spatial device does camera manipulation via Behavior // (mouse/gamepad currently do not, but will in future!) cockpit.InputBehaviors.Add(new SpatialDeviceViewManipBehavior(cockpit) { Priority = 2 }); SpatialDeviceGrabBehavior grab = new SpatialDeviceGrabBehavior(cockpit) { StickMoveSpeed = 0.03f, Priority = 3 }; grab.OnBeginGrab += (sender, target) => { cockpit.Scene.Select(target, true); }; grab.OnEndGrab += (sender, target) => { cockpit.Scene.ClearSelection(); }; cockpit.InputBehaviors.Add(grab); // selection / multi-selection behaviors cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context) { Priority = 10 }); cockpit.InputBehaviors.Add(new GamepadMultiSelectBehavior(cockpit.Context) { Priority = 10 }); cockpit.InputBehaviors.Add(new SpatialDeviceMultiSelectBehavior(cockpit.Context) { Priority = 10 }); // de-selection behaviors cockpit.InputBehaviors.Add(new MouseDeselectBehavior(cockpit.Context) { Priority = 999 }); cockpit.InputBehaviors.Add(new GamepadDeselectBehavior(cockpit.Context) { Priority = 999 }); cockpit.InputBehaviors.Add(new SpatialDeviceDeselectBehavior(cockpit.Context) { Priority = 999 }); cockpit.InputBehaviors.Add(new UndoShortcutBehavior(cockpit.Context) { Priority = 999 }); // screencap to your dropbox cockpit.OverrideBehaviors.Add(new ScreenCaptureBehavior() { Priority = 0, ScreenshotPath = Environment.GetEnvironmentVariable("homepath") + "\\DropBox\\ScreenShots\\" }); }