예제 #1
0
        virtual protected void make_materials()
        {
            float fAlpha = 0.5f;

            srcMaterial      = MaterialUtil.CreateTransparentMaterial(ColorUtil.CgRed, fAlpha);
            srcHoverMaterial = MaterialUtil.CreateStandardMaterial(ColorUtil.CgRed);
        }
예제 #2
0
        override protected void BuildGizmo()
        {
            gizmo.SetName("SnapDragGizmo");

            float fAlpha = 0.5f;

            srcMaterial      = MaterialUtil.CreateTransparentMaterial(ColorUtil.SelectionGold, fAlpha);
            srcHoverMaterial = MaterialUtil.CreateStandardMaterial(ColorUtil.SelectionGold);

            // generate snap target set
            Snaps = SnapSet.CreateStandard(Scene);
            Snaps.IgnoreSet.AddRange(this.targets);
            Snaps.PreRender(parentScene.ActiveCamera.GetPosition());

            // [TODO] this should iterate through targets...

            Debug.Assert(this.targets.Count == 1);
            // [TODO] should maybe be using GetBoundingBox now??
            Bounds b = this.targets[0].GetLocalBoundingBox();
            float  h = b.extents[1];

            // object origin
            add_snap_source(Vector3.zero, "obj_origin", Snaps);
            add_snap_source(Vector3.zero + h * Vector3.up, "obj_top", Snaps);
            add_snap_source(Vector3.zero - h * Vector3.up, "obj_base", Snaps);

            gizmo.Hide();
        }
예제 #3
0
        protected override void BuildGizmo()
        {
            gizmo.SetName("EditPrimitiveGizmo");

            float fAlpha = 0.5f;

            stdMaterial      = MaterialUtil.CreateTransparentMaterial(Color.yellow, fAlpha);
            stdHoverMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow);

            // [TODO] this should iterate through targets... ??

            Debug.Assert(this.targets.Count == 1);

            PolyCurveSO target = this.targets[0] as PolyCurveSO;

            target.OnCurveModified += on_curve_modified;

            add_curve_widget(target, true,
                             () => { return((Vector3)target.Curve.Start); });
            add_curve_widget(target, false,
                             () => { return((Vector3)target.Curve.End); });


            gizmo.Hide();
        }
예제 #4
0
        override protected void BuildGizmo()
        {
            gizmo.SetName("EditPrimitiveGizmo");

            float fAlpha = 0.5f;

            stdMaterial      = MaterialUtil.CreateTransparentMaterial(Color.yellow, fAlpha);
            stdHoverMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow);

            // [TODO] this should iterate through targets... ??

            Debug.Assert(this.targets.Count == 1);

            // object origin
            foreach (var so in Targets)
            {
                if ((so is PrimitiveSO) == false)
                {
                    continue;
                }
                PrimitiveSO pso = so as PrimitiveSO;

                pso.Parameters.OnParameterModified += on_parameter_modified;

                float fVertMult = 1.0f;
                float fHorzMult = 1.0f;
                if (pso.Center == CenterModes.Base)
                {
                    fHorzMult = 2.0f;
                }

                if (pso is CylinderSO)
                {
                    add_axis_widget(pso, Vector3.up, fVertMult, "scaled_height",
                                    () => { return(pso.Parameters.GetValueFloat("scaled_height") * 0.5f * Vector3.up); });
                    add_axis_widget(pso, Vector3.right, 1.0f, "scaled_radius",
                                    () => { return(pso.Parameters.GetValueFloat("scaled_radius") * Vector3.right); });
                }
                else if (pso is SphereSO)
                {
                    add_axis_widget(pso, Vector3.up, 1.0f, "scaled_diameter",
                                    () => { return(pso.Parameters.GetValueFloat("scaled_diameter") * 0.5f * Vector3.up); });
                }
                else if (pso is BoxSO)
                {
                    add_axis_widget(pso, Vector3.up, fVertMult, "scaled_height",
                                    () => { return(pso.Parameters.GetValueFloat("scaled_height") * 0.5f * Vector3.up); });
                    add_axis_widget(pso, Vector3.right, fHorzMult, "scaled_width",
                                    () => { return(pso.Parameters.GetValueFloat("scaled_width") * 0.5f * Vector3.right); });
                    add_axis_widget(pso, Vector3.forward, fHorzMult, "scaled_depth",
                                    () => { return(pso.Parameters.GetValueFloat("scaled_depth") * 0.5f * Vector3.forward); });
                }
            }

            gizmo.Hide();
        }
예제 #5
0
        protected override fGameObject create_pivot_shape()
        {
            mesh_height = CC.Settings.LayerHeightMM;
            TrivialBox3Generator boxgen = new TrivialBox3Generator()
            {
                NoSharedVertices = true,
                Box = new Box3d(Vector3d.Zero, new Vector3d(2.5, CC.Settings.LayerHeightMM, 2.5))
            };
            DMesh3          mesh   = boxgen.Generate().MakeDMesh();
            fMeshGameObject meshGO = GameObjectFactory.CreateMeshGO("pivotMesh",
                                                                    new fMesh(mesh), true, true);

            meshGO.SetMaterial(MaterialUtil.CreateStandardMaterial(Colorf.Orange));
            return(meshGO);
        }
예제 #6
0
            public override fMaterial MakeMaterial(AxisGizmoFlags widget)
            {
                switch (widget)
                {
                case AxisGizmoFlags.AxisTranslateY:
                    if (MyYMaterial == null)
                    {
                        MyYMaterial = MaterialUtil.CreateStandardMaterial(Colorf.VideoGreen);
                    }
                    return(MyYMaterial);

                default:
                    return(null);
                }
            }
    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\\"
        });
    }
예제 #8
0
    public void Initialize(Cockpit cockpit)
    {
        cockpit.Name = "sampleCockpit";

        // Configure how the cockpit moves
        cockpit.PositionMode = Cockpit.MovementMode.TrackPosition;


        // initialize layout
        BoxContainer screenContainer           = new BoxContainer(new Cockpit2DContainerProvider(cockpit));
        PinnedBoxes2DLayoutSolver screenLayout = new PinnedBoxes2DLayoutSolver(screenContainer);
        PinnedBoxesLayout         layout       = new PinnedBoxesLayout(cockpit, screenLayout)
        {
            StandardDepth = 1.0f
        };

        cockpit.AddLayout(layout, "2D", true);



        float pixelScale = cockpit.GetPixelScale();
        float buttonDiam = 150 * pixelScale;

        HUDElementList primitives_list = new HUDElementList()
        {
            Width     = 5 * buttonDiam,
            Height    = buttonDiam,
            Spacing   = 25 * pixelScale,
            Direction = HUDElementList.ListDirection.Horizontal
        };


        // 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

        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);

        DropPrimitiveButton cylinderButton =
            create_primitive_button(cockpit, "create_cylinder", buttonDiam / 2,
                                    PrimitiveType.Cylinder, SOTypes.Cylinder, 0.7f, bgMaterial, primMaterial,
                                    () => { return(new CylinderSO().Create(cockpit.Scene.DefaultSOMaterial)); });

        primitives_list.AddListItem(cylinderButton);

        DropPrimitiveButton boxButton =
            create_primitive_button(cockpit, "create_box", buttonDiam / 2,
                                    PrimitiveType.Cube, SOTypes.Box, 0.8f, bgMaterial, primMaterial,
                                    () => { return(new BoxSO().Create(cockpit.Scene.DefaultSOMaterial)); });

        primitives_list.AddListItem(boxButton);


        primitives_list.Create();
        primitives_list.Name = "button_bar";

        // align primitives_list to bottom-left
        layout.Add(primitives_list, new LayoutOptions()
        {
            Flags            = LayoutFlags.None,
            PinSourcePoint2D = LayoutUtil.BoxPointF(primitives_list, BoxPosition.BottomLeft),
            PinTargetPoint2D = LayoutUtil.BoxPointF(screenContainer, BoxPosition.BottomLeft, 25 * pixelScale * Vector2f.One)
        });


        //float fToolsX = 35.0f;
        //float fToolButtonRadius = 0.08f;

        // buttons for draw-primitive tool and cancel-tool button

        //ActivateToolButton drawPrimButton = add_tool_button(cockpit, DrawPrimitivesTool.Identifier, fHUDRadius,
        //    fToolsX - fButtonsSpacing, fButtonsY, fToolButtonRadius, bgMaterial, primMaterial,
        //    new toolInfo() { identifier = DrawPrimitivesTool.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 BasicShapesDemo_KeyHandler(cockpit.Context));

        // these behaviors let us interact with UIElements (ie left-click/trigger, or either triggers for Touch)
        cockpit.InputBehaviors.Add(new Mouse2DCockpitUIBehavior(cockpit.Context)
        {
            Priority = 0
        });
        cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context)
        {
            Priority = 1
        });

        // selection / multi-selection behaviors
        cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context)
        {
            Priority = 10
        });
        cockpit.InputBehaviors.Add(new GamepadMultiSelectBehavior(cockpit.Context)
        {
            Priority = 10
        });

        // left click-drag to tumble, and left click-release to de-select
        cockpit.InputBehaviors.Add(new MouseClickDragSuperBehavior()
        {
            Priority     = 100,
            DragBehavior = new MouseViewRotateBehavior(cockpit.Context)
            {
                Priority = 100, RotateSpeed = 3.0f
            },
            ClickBehavior = new MouseDeselectBehavior(cockpit.Context)
            {
                Priority = 999
            }
        });

        // also right-click-drag to tumble
        cockpit.InputBehaviors.Add(new MouseViewRotateBehavior(cockpit.Context)
        {
            Priority  = 100, RotateSpeed = 3.0f,
            ActivateF = MouseBehaviors.RightButtonPressedF, ContinueF = MouseBehaviors.RightButtonDownF
        });

        // middle-click-drag to pan
        cockpit.InputBehaviors.Add(new MouseViewPanBehavior(cockpit.Context)
        {
            Priority  = 100, PanSpeed = 1.0f,
            ActivateF = MouseBehaviors.MiddleButtonPressedF, ContinueF = MouseBehaviors.MiddleButtonDownF
        });

        cockpit.OverrideBehaviors.Add(new MouseWheelZoomBehavior(cockpit)
        {
            Priority = 100, ZoomScale = 10.0f
        });

        // touch input
        cockpit.InputBehaviors.Add(new TouchUIBehavior(cockpit.Context)
        {
            Priority = 1
        });
        cockpit.InputBehaviors.Add(new Touch2DCockpitUIBehavior(cockpit.Context)
        {
            Priority = 0
        });
        cockpit.InputBehaviors.Add(new TouchViewManipBehavior(cockpit.Context)
        {
            Priority = 999, TouchZoomSpeed = 0.1f, TouchPanSpeed = 0.03f
        });
    }