コード例 #1
0
        public FScene(FContext context)
        {
            this.context = context;

            history      = new ChangeHistory();
            TypeRegistry = new SORegistry();

            vObjects       = new List <SceneObject> ();
            vSelected      = new List <SceneObject> ();
            vUIElements    = new List <SceneUIElement> ();
            vBoundsObjects = new List <GameObject> ();
            ObjectAnimator = new GenericAnimator();

            sceneRoot = new GameObject("Scene");
            // for animation playbacks
            sceneRoot.AddComponent <SceneAnimator>().Scene = this;
            sceneRoot.AddComponent <UnityPerFrameAnimationBehavior>().Animator = ObjectAnimator;

            scene_objects = new GameObject("scene_objects");
            UnityUtil.AddChild(sceneRoot, scene_objects, false);

            deleted_objects = new GameObject("deleted_objects");
            UnityUtil.AddChild(sceneRoot, deleted_objects, false);
            vDeleted = new List <SceneObject>();

            // initialize materials
            DefaultSOMaterial = new SOMaterial()
            {
                Name = "DefaultSO",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = ColorUtil.StandardBeige
            };
            DefaultCurveSOMaterial = new SOMaterial()
            {
                Name = "DefaultCurveSO",
                Type = SOMaterial.MaterialType.UnlitRGBColor, RGBColor = Colorf.DarkSlateGrey
            };
            DefaultMeshSOMaterial = new SOMaterial()
            {
                Name = "DefaultMeshSO",
                Type = SOMaterial.MaterialType.PerVertexColor, RGBColor = Colorf.White
            };
            NewSOMaterial = new SOMaterial()
            {
                Name = "NewSO",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = Colorf.CornflowerBlue
            };
            TransparentNewSOMaterial = new SOMaterial()
            {
                Name = "NewSO",
                Type = SOMaterial.MaterialType.TransparentRGBColor, RGBColor = new Colorf(Colorf.CornflowerBlue, 0.5f)
            };
            PivotSOMaterial = new SOMaterial()
            {
                Name = "PivotSO",
                Type = SOMaterial.MaterialType.TransparentRGBColor, RGBColor = ColorUtil.PivotYellow.SetAlpha(0.75f)
            };
            FrameSOMaterial = new SOMaterial()
            {
                Name = "PivotFrame",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = ColorUtil.DarkGrey
            };

            SelectedMaterial = MaterialUtil.CreateStandardMaterial(ColorUtil.SelectionGold);
            FrameMaterial    = MaterialUtil.CreateStandardMaterial(ColorUtil.DarkGrey);
            PivotMaterial    = MaterialUtil.ToUnityMaterial(PivotSOMaterial);

            defaultPrimitiveType = SOTypes.Cylinder;
        }
コード例 #2
0
ファイル: InputState.cs プロジェクト: xiaodelea/frame3Sharp
        public void Initialize_MouseGamepad(FContext s)
        {
            // [RMS] cannot differentiate these right now...
            eDevice = InputDevice.Mouse | InputDevice.Gamepad;

            bShiftKeyDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
            bCtrlKeyDown  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
            bCmdKeyDown   = Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand);
            bAltKeyDown   = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.LeftAlt);

            bLeftMousePressed  = Input.GetMouseButtonDown(0);
            bLeftMouseDown     = Input.GetMouseButton(0);
            bLeftMouseReleased = Input.GetMouseButtonUp(0);

            bMiddleMousePressed  = Input.GetMouseButtonDown(2);
            bMiddleMouseDown     = Input.GetMouseButton(2);
            bMiddleMouseReleased = Input.GetMouseButtonUp(2);

            bRightMousePressed  = Input.GetMouseButtonDown(1);
            bRightMouseDown     = Input.GetMouseButton(1);
            bRightMouseReleased = Input.GetMouseButtonUp(1);

            fMouseWheel = InputExtension.Get.Mouse.WheelDelta;

            vMouseDelta2D    = InputExtension.Get.Mouse.PositionDelta;
            vMousePosition2D = InputExtension.Get.Mouse.Position;
            vMouseWorldRay   = s.MouseController.CurrentCursorWorldRay();
            if (s.Use2DCockpit)
            {
                vMouseOrthoWorldRay = s.MouseController.CurrentCursorOrthoRay();
            }



            bLeftTriggerPressed  = InputExtension.Get.GamepadLeft.Pressed;
            bLeftTriggerDown     = InputExtension.Get.GamepadLeft.Down;
            bLeftTriggerReleased = InputExtension.Get.GamepadLeft.Released;

            bRightTriggerPressed  = InputExtension.Get.GamepadRight.Pressed;
            bRightTriggerDown     = InputExtension.Get.GamepadRight.Down;
            bRightTriggerReleased = InputExtension.Get.GamepadRight.Released;

            bAButtonPressed  = InputExtension.Get.GamepadA.Pressed;
            bAButtonDown     = InputExtension.Get.GamepadA.Down;
            bAButtonReleased = InputExtension.Get.GamepadA.Released;

            bBButtonPressed  = InputExtension.Get.GamepadB.Pressed;
            bBButtonDown     = InputExtension.Get.GamepadB.Down;
            bBButtonReleased = InputExtension.Get.GamepadB.Released;

            bXButtonPressed  = InputExtension.Get.GamepadX.Pressed;
            bXButtonDown     = InputExtension.Get.GamepadX.Down;
            bXButtonReleased = InputExtension.Get.GamepadX.Released;

            bYButtonPressed  = InputExtension.Get.GamepadY.Pressed;
            bYButtonDown     = InputExtension.Get.GamepadY.Down;
            bYButtonReleased = InputExtension.Get.GamepadY.Released;

            vLeftStickDelta2D  = InputExtension.Get.GamepadLeftStick.Position;
            vRightStickDelta2D = InputExtension.Get.GamepadRightStick.Position;

            // [RMS] assuming that left joystick/mouse are the same cursor pos...
            vGamepadWorldRay = vMouseWorldRay;
        }
コード例 #3
0
 public Touch2DCockpitUIBehavior(FContext scene)
 {
     this.scene = scene;
     pCapturing = null;
     Priority   = 0;
 }
コード例 #4
0
 public UndoShortcutBehavior(FContext context)
 {
     this.context = context;
     Priority     = 10;
 }
コード例 #5
0
        // Use this for initialization
        public void Initialize(FContext controller)
        {
            this.controller = controller;

            // find main camera
            GameObject[] mainCameras = GameObject.FindGameObjectsWithTag("MainCamera");
            if (mainCameras.Length == 0)
            {
                throw new MissingComponentException("CameraTracking.Initialize: could not find camera with tag MainCamera");
            }
            var mainCameraObj = mainCameras[0];

            if (mainCameras.Length > 1)
            {
                DebugUtil.Log(2, "CameraTracking.Initialize: there are multiple objects with tag MainCamera. Using the one named " + mainCameraObj.GetName());
            }
            mainCamera = new fCamera(mainCameraObj.GetComponent <Camera> () as Camera);

            // on Vive the MainCamera will have some child cameras that are a problem,
            // so get rid of them
            if (gs.VRPlatform.CurrentVRDevice == gs.VRPlatform.Device.HTCVive)
            {
                List <GameObject> children = new List <GameObject>(mainCameraObj.Children());
                foreach (var child in children)
                {
                    mainCameraObj.RemoveChild(child);
                    child.Destroy();
                }
            }

            is_orthographic_view = mainCamera.IsOrthographic;

            List <Camera> newCameras = new List <Camera>();

            Vector3f    mainPos = mainCamera.GetPosition();
            Quaternionf mainRot = mainCamera.GetRotation();

            // create camera for 3D widgets layer
            widgetCamera = new fCamera(Camera.Instantiate((Camera)mainCamera, mainPos, mainRot));
            widgetCamera.SetName("WidgetCamera");
            newCameras.Add(widgetCamera);

            // create camera for HUD layer
            hudCamera = new fCamera(Camera.Instantiate((Camera)mainCamera, mainPos, mainRot));
            hudCamera.SetName("HUDCamera");
            newCameras.Add(hudCamera);

            // create camera for UI
            uiCamera = new fCamera(Camera.Instantiate((Camera)mainCamera, mainPos, mainRot));
            uiCamera.SetName("UICamera");
            ((Camera)uiCamera).orthographic     = true;
            ((Camera)uiCamera).orthographicSize = 0.5f;
            newCameras.Add(uiCamera);

            // create camera for cursor
            cursorCamera = new fCamera(Camera.Instantiate((Camera)mainCamera, mainPos, mainRot));
            cursorCamera.SetName("CursorCamera");
            newCameras.Add(cursorCamera);

            // configure these cameras
            //   - must disable audio listener if it exists
            //   - do depth clear so we can draw on top of other layers
            foreach (Camera cam in newCameras)
            {
                AudioListener listener = cam.GetComponent <AudioListener>();
                if (listener != null)
                {
                    listener.enabled = false;
                }

                cam.clearFlags = CameraClearFlags.Depth;

                cam.tag = "Untagged";
            }


            // set up camera masks

            // this camera only renders 3DWidgetOverlay layer, and mainCam does not!
            int nWidgetLayer = FPlatform.WidgetOverlayLayer;
            int nHUDLayer    = FPlatform.HUDLayer;
            int nUILayer     = FPlatform.UILayer;
            int nCursorLayer = FPlatform.CursorLayer;

            ((Camera)widgetCamera).cullingMask = (1 << nWidgetLayer);
            ((Camera)hudCamera).cullingMask    = (1 << nHUDLayer);
            ((Camera)uiCamera).cullingMask     = (1 << nUILayer);
            ((Camera)cursorCamera).cullingMask = (1 << nCursorLayer);

            ((Camera)mainCamera).cullingMask &= ~(1 << nWidgetLayer);
            ((Camera)mainCamera).cullingMask &= ~(1 << nHUDLayer);
            ((Camera)mainCamera).cullingMask &= ~(1 << nUILayer);
            ((Camera)mainCamera).cullingMask &= ~(1 << nCursorLayer);

            // attach camera animation object to main camera
            CameraAnimator anim = mainCamera.AddComponent <CameraAnimator>();

            anim.UseCamera = mainCamera;
            anim.UseScene  = this.controller.Scene;

            // add target point to camera
            CameraTarget target = mainCamera.AddComponent <CameraTarget>();

            target.TargetPoint = new Vector3f(0.0f, mainCamera.GetPosition().y, 0.0f);
            target.context     = this.controller;

            // add camera manipulator to camera
            // TODO: this does not need to be a monobehavior...
            var manipulator = mainCamera.AddComponent <CameraManipulator>();

            manipulator.Camera = mainCamera;


            // initialize FPlatform
            FPlatform.MainCamera    = mainCamera;
            FPlatform.WidgetCamera  = widgetCamera;
            FPlatform.HUDCamera     = hudCamera;
            FPlatform.OrthoUICamera = uiCamera;
            FPlatform.CursorCamera  = cursorCamera;
        }
コード例 #6
0
 public MouseViewRotateBehavior(FContext context)
 {
     this.Context = context;
 }
コード例 #7
0
 public FileBrowserTextFieldKeyHandler(FContext c, HUDTextEntry entry)
 {
     controller = c;
     entryField = entry;
 }
コード例 #8
0
 public MouseMultiSelectBehavior(FContext scene)
 {
     this.scene = scene;
     Priority   = 10;
 }
コード例 #9
0
 public DrawPrimitivesTool_MouseBehavior(FContext s)
 {
     context = s;
 }
コード例 #10
0
 public BaseSurfacePointTool_2DBehavior(FContext s, Func <SceneObject, bool> filterF)
 {
     context       = s;
     ObjectFilterF = filterF;
 }
コード例 #11
0
 public DrawPrimitivesTool_SpatialDeviceBehavior(FContext s)
 {
     context = s;
 }
コード例 #12
0
ファイル: ToolManager.cs プロジェクト: ZeroLu/frame3Sharp
 public void Initialize(FContext manager)
 {
     SceneManager = manager;
     //SceneManager.Scene.SelectionChangedEvent += Scene_SelectionChangedEvent;
 }
コード例 #13
0
 public GamepadDeselectBehavior(FContext scene)
 {
     this.scene = scene;
     Priority   = 1000;
 }
コード例 #14
0
ファイル: InputState.cs プロジェクト: xiaodelea/frame3Sharp
        public void Initialize_SpatialController(FContext s)
        {
            eDevice = (VRPlatform.CurrentVRDevice == VRPlatform.Device.HTCVive) ?
                      InputDevice.HTCViveWands : InputDevice.OculusTouch;

            // would we ever get this far if controller was not tracked?
            bLeftControllerActive  = VRPlatform.IsLeftControllerTracked;
            bRightControllerActive = VRPlatform.IsRightControllerTracked;

            bLeftTriggerPressed  = InputExtension.Get.SpatialLeftTrigger.Pressed;
            bLeftTriggerDown     = InputExtension.Get.SpatialLeftTrigger.Down;
            bLeftTriggerReleased = InputExtension.Get.SpatialLeftTrigger.Released;

            bRightTriggerPressed  = InputExtension.Get.SpatialRightTrigger.Pressed;
            bRightTriggerDown     = InputExtension.Get.SpatialRightTrigger.Down;
            bRightTriggerReleased = InputExtension.Get.SpatialRightTrigger.Released;

            bLeftShoulderPressed  = InputExtension.Get.SpatialLeftShoulder.Pressed;
            bLeftShoulderDown     = InputExtension.Get.SpatialLeftShoulder.Down;
            bLeftShoulderReleased = InputExtension.Get.SpatialLeftShoulder.Released;

            bRightShoulderPressed  = InputExtension.Get.SpatialRightShoulder.Pressed;
            bRightShoulderDown     = InputExtension.Get.SpatialRightShoulder.Down;
            bRightShoulderReleased = InputExtension.Get.SpatialRightShoulder.Released;

            bLeftStickPressed  = VRPlatform.LeftStickPressed;
            bLeftStickDown     = VRPlatform.LeftStickDown;
            bLeftStickReleased = VRPlatform.LeftStickReleased;
            bLeftStickTouching = VRPlatform.LeftStickTouching;

            bRightStickPressed  = VRPlatform.RightStickPressed;
            bRightStickDown     = VRPlatform.RightStickDown;
            bRightStickReleased = VRPlatform.RightStickReleased;
            bRightStickTouching = VRPlatform.RightStickTouching;

            // [TODO] emulate these buttons w/ vive touchpad locations?

            bAButtonPressed  = VRPlatform.AButtonPressed;
            bAButtonDown     = VRPlatform.AButtonDown;
            bAButtonReleased = VRPlatform.AButtonReleased;

            bBButtonPressed  = VRPlatform.BButtonPressed;
            bBButtonDown     = VRPlatform.BButtonDown;
            bBButtonReleased = VRPlatform.BButtonReleased;

            bXButtonPressed  = VRPlatform.XButtonPressed;
            bXButtonDown     = VRPlatform.XButtonDown;
            bXButtonReleased = VRPlatform.XButtonReleased;

            bYButtonPressed  = VRPlatform.YButtonPressed;
            bYButtonDown     = VRPlatform.YButtonDown;
            bYButtonReleased = VRPlatform.YButtonReleased;

            bLeftMenuButtonPressed  = VRPlatform.LeftMenuButtonPressed;
            bLeftMenuButtonDown     = VRPlatform.LeftMenuButtonDown;
            bLeftMenuButtonReleased = VRPlatform.LeftMenuButtonReleased;

            bRightMenuButtonPressed  = VRPlatform.RightMenuButtonPressed;
            bRightMenuButtonDown     = VRPlatform.RightMenuButtonDown;
            bRightMenuButtonReleased = VRPlatform.RightMenuButtonReleased;

            vLeftStickDelta2D  = VRPlatform.LeftStickPosition;
            vRightStickDelta2D = VRPlatform.RightStickPosition;

            // [RMS] bit of a hack here, if controller is not active then ray is 0/0, and
            //   that causes lots of exceptions elsewhere! So we return a default ray pointing
            //   straight up, but hopefully clients are checking active flag and will ignore it...
            vLeftSpatialWorldRay = (bLeftControllerActive) ?
                                   s.SpatialController.Left.CursorRay : new Ray(Vector3f.Zero, Vector3f.AxisY);
            vRightSpatialWorldRay = (bRightControllerActive) ?
                                    s.SpatialController.Right.CursorRay : new Ray(Vector3f.Zero, Vector3f.AxisY);

            LeftHandFrame  = s.SpatialController.Left.SmoothedHandFrame;
            RightHandFrame = s.SpatialController.Right.SmoothedHandFrame;
        }
コード例 #15
0
 public BaseSingleClickTool_2DBehavior(FContext s, Func <SceneObject, bool> filterF)
 {
     context       = s;
     ObjectFilterF = filterF;
 }
コード例 #16
0
ファイル: FContext.cs プロジェクト: Alan-Baylis/frame3Sharp
        // Use this for initialization
        public void Start(SceneOptions options)
        {
            this.options = options;

            DebugUtil.LogLevel = options.LogLevel;
            FPlatform.InitializeMainThreadID();

            // initialize VR platform if VR is active
            if (gs.VRPlatform.VREnabled)
            {
                if (options.Use2DCockpit)
                {
                    throw new Exception("FContext.Start: cannot use 2D Orthographic Cockpit with VR!");
                }
                if (options.SpatialCameraRig != null)
                {
                    gs.VRPlatform.Initialize(options.SpatialCameraRig);
                }
            }

            InputExtension.Get.Start();

            nextFrameActions = new ActionSet();

            // intialize camera stuff
            camTracker = new CameraTracking();
            camTracker.Initialize(this);

            GetScene();
            if (options.SceneInitializer != null)
            {
                options.SceneInitializer.Initialize(GetScene());
            }

            if (options.DefaultGizmoBuilder != null)
            {
                transformManager = new TransformManager(options.DefaultGizmoBuilder);
            }
            else
            {
                transformManager = new TransformManager(new AxisTransformGizmoBuilder());
            }
            if (options.EnableTransforms)
            {
                transformManager.Initialize(this);
            }

            toolManager = new ToolManager();
            toolManager.Initialize(this);
            toolManager.OnToolActivationChanged += OnToolActivationChanged;

            MouseController.Start();
            SpatialController.Start();

            // [RMS] hardcode starting cam target point to origin
            ActiveCamera.SetTarget(Vector3f.Zero);

            if (options.MouseCameraControls != null)
            {
                MouseCameraController = options.MouseCameraControls;
            }

            // apply initial transformation to scene
            ActiveCamera.Manipulator().SceneTranslate(Scene, SceneGraphConfig.InitialSceneTranslate, true);

            // create behavior sets
            inputBehaviors    = new InputBehaviorSet();
            overrideBehaviors = new InputBehaviorSet();

            // cockpit needs to go last because UI setup may depend on above
            cockpitStack = new Stack <Cockpit>();
            if (options.EnableCockpit)
            {
                PushCockpit(options.CockpitInitializer);
            }


            captureMouse     = null;
            captureTouch     = null;
            captureLeft      = captureRight = null;
            bInCameraControl = false;

            // [RMS] this locks cursor to game unless user presses escape or exits
            if (FPlatform.IsUsingVR() || options.UseSystemMouseCursor == false)
            {
                Cursor.lockState = CursorLockMode.Locked;
            }

            // set hacky hackenstein global
            ActiveContext_HACK = this;

            startup_checks();
        }
コード例 #17
0
 public void Initialize(FContext manager)
 {
     Context = manager;
     Context.Scene.SelectionChangedEvent += Scene_SelectionChangedEvent;
 }
コード例 #18
0
 public CurveSelectFacesTool_2DBehavior(CurveSelectFacesTool tool, FContext context)
 {
     Tool    = tool;
     Context = context;
 }
コード例 #19
0
 public SurfaceBrushTool_SpatialBehavior(SurfaceBrushTool tool, FContext s)
 {
     context   = s;
     this.tool = tool;
 }
コード例 #20
0
 public SpatialInputController(GameObject spatialCamRig, Camera viewCam, FContext context)
 {
     this.spatialCamRig = spatialCamRig;
     this.camera        = viewCam;
     this.context       = context;
 }
コード例 #21
0
 public SurfaceBrushTool_2DInputBehavior(SurfaceBrushTool tool, FContext s)
 {
     this.tool = tool;
     context   = s;
 }
コード例 #22
0
 public MouseViewPanBehavior(FContext context)
 {
     this.Context = context;
 }
コード例 #23
0
 //SceneController controller;
 public SplashScreenKeyHandler(FContext c)
 {
     //controller = c;
 }
コード例 #24
0
 public SpatialDeviceMultiSelectBehavior(FContext scene)
 {
     this.scene = scene;
     Priority   = 10;
 }
コード例 #25
0
 public MouseDeselectBehavior(FContext scene)
 {
     this.scene = scene;
     Priority   = 1000;
 }
コード例 #26
0
 public VRSpatialDeviceUIBehavior(FContext scene)
 {
     this.scene = scene;
     Priority   = 0;
 }
コード例 #27
0
 public TouchMouseCursorController(FContext context)
 {
     this.context = context;
 }