Esempio n. 1
0
        private void Scene_SelectionChangedEvent(object sender, EventArgs e)
        {
            FScene             scene     = Context.Scene;
            List <SceneObject> vSelected = new List <SceneObject>();

            foreach (SceneObject tso in scene.Selected)
            {
                if (tso != null)
                {
                    if (SelectionFilterF == null || SelectionFilterF(tso))
                    {
                        vSelected.Add(tso);
                    }
                }
            }

            if (vSelected.Count == 0 && activeGizmo != null)
            {
                // object de-selected, dismiss gizmo
                DismissActiveGizmo();
                return;
            }
            if (activeGizmo != null && unordered_lists_equal(vSelected, activeGizmo.Targets) == false)
            {
                DismissActiveGizmo();
            }

            if (vSelected.Count > 0)
            {
                Context.RegisterNextFrameAction(add_gizmo_next_frame);
            }
            //AddGizmo(vSelected);
        }
Esempio n. 2
0
        public SurfaceBrushTool(FScene scene, DMeshSO target)
        {
            this.scene  = scene;
            this.target = target;

            behaviors = new InputBehaviorSet();

            // TODO is this where we should be doing this??
            behaviors.Add(
                new SurfaceBrushTool_2DInputBehavior(this, scene.Context)
            {
                Priority = 5
            });
            if (FPlatform.IsUsingVR())
            {
                behaviors.Add(
                    new SurfaceBrushTool_SpatialBehavior(this, scene.Context)
                {
                    Priority = 5
                });
            }

            // shut off transform gizmo
            scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType);

            Indicators = new ToolIndicatorSet(this, scene);
        }
Esempio n. 3
0
        public void ResetScenePosition(FScene scene)
        {
            scene.RootGameObject.transform.position = Vector3.zero;
            Vector3 targetPos = Vector3.zero;

            getCamera().SetTarget(targetPos);
        }
Esempio n. 4
0
        public void DoCameraControl(FScene scene, fCamera mainCamera, InputState input)
        {
            Vector2f mouseDelta = InputExtension.Get.Mouse.PositionDelta;
            Vector2f stick1     = InputExtension.Get.GamepadLeftStick.Position;
            Vector2f stick2     = InputExtension.Get.GamepadRightStick.Position;
            float    dx         = mouseDelta.x + stick1.x;
            float    dy         = mouseDelta.y + stick1.y;
            float    dx2        = stick2.x;
            float    dy2        = stick2.y;

            if (Input.GetMouseButton(0))
            {
                mainCamera.Manipulator().SceneOrbit(scene, mainCamera, MouseOrbitSpeed * dx, MouseOrbitSpeed * dy);
            }
            else if (Input.GetMouseButton(1))
            {
                mainCamera.Manipulator().SceneZoom(scene, mainCamera, -MouseZoomSpeed * dy);
                //mainCamera.Manipulator().ScenePan(scene, mainCamera, 0.05f * dx, 0);
            }
            else if (Input.GetMouseButton(2))
            {
                mainCamera.Manipulator().ScenePan(scene, mainCamera, MousePanSpeed * dx, MousePanSpeed * dy);
            }
            else if (InputExtension.Get.GamepadRightShoulder.Down)
            {
                mainCamera.Manipulator().SceneZoom(scene, mainCamera, GamepadZoomSpeed * dy);
                mainCamera.Manipulator().ScenePan(scene, mainCamera, (-0.5f * GamepadPanSpeed * dx) + (-GamepadPanSpeed * dx2), -GamepadPanSpeed * dy2);
            }
            else if (InputExtension.Get.GamepadLeftShoulder.Down)
            {
                mainCamera.Manipulator().SceneOrbit(scene, mainCamera, GamepadOrbitSpeed * dx, GamepadOrbitSpeed * dy);
                mainCamera.Manipulator().ScenePan(scene, mainCamera, -GamepadPanSpeed * dx2, -GamepadPanSpeed * dy2);
            }
        }
        public ITransformGizmo Build(FScene scene, List <TransformableSO> targets)
        {
            var g = new AxisTransformGizmo();

            g.Create(scene, targets);
            return(g);
        }
Esempio n. 6
0
        void update_geometry(FScene s)
        {
            if (bUpdatePending == false && curve_timestamp == curve.Timestamp)
            {
                return;
            }
            if (curve.VertexCount < 2)
            {
                return;
            }

            update_vertices(s);

            int N = (curve.Closed) ? curve.VertexCount + 1 : curve.VertexCount;

            Vector3f[] vertices = new Vector3f[N];
            for (int i = 0; i < N; ++i)
            {
                vertices[i] = (Vector3f)curve[i % curve.VertexCount];
            }
            curveObject.SetVertices(vertices);

            float fWidth = VRUtil.EstimateStableCurveWidth(s, Frame3f.Identity, curve,
                                                           SceneGraphConfig.DefaultSceneCurveVisualDegrees);

            if (fWidth > 0)
            {
                curveObject.SetLineWidth(fWidth);
            }

            bUpdatePending  = false;
            curve_timestamp = curve.Timestamp;
        }
        private void Scene_SelectionChangedEvent(object sender, EventArgs e)
        {
            FScene scene = SceneManager.Scene;
            List <TransformableSO> vSelected = new List <TransformableSO>();

            foreach (SceneObject so in scene.Selected)
            {
                TransformableSO tso = so as TransformableSO;
                if (tso != null)
                {
                    vSelected.Add(tso);
                }
            }

            if (vSelected.Count == 0 && activeGizmo != null)
            {
                // object de-selected, dismiss gizmo
                DismissActiveGizmo();
                return;
            }
            if (activeGizmo != null && unordered_lists_equal(vSelected, activeGizmo.Targets) == false)
            {
                DismissActiveGizmo();
            }

            if (vSelected.Count > 0)
            {
                AddGizmo(vSelected);
            }
        }
        public DrawSpaceCurveTool(FScene scene, SceneObject target)
        {
            this.Scene  = scene;
            this.target = target;

            behaviors = new InputBehaviorSet();

            // TODO is this where we should be doing this??
            if (FPlatform.IsUsingVR())
            {
                behaviors.Add(
                    new DrawSpaceCurveTool_SpatialDeviceBehavior(this, scene.Context)
                {
                    Priority = 5
                });
            }

            // shut off transform gizmo
            scene.Context.TransformManager.PushOverrideGizmoType(TransformManager.NoGizmoType);

            scene.SelectionChangedEvent += Scene_SelectionChangedEvent;

            // restore radius
            //if (SavedSettings.Restore("DrawSpaceCurveTool_width") != null)
            //    width = (float)SavedSettings.Restore("DrawSpaceCurveTool_width");
        }
Esempio n. 9
0
        public virtual ITool Build(FScene scene, List <SceneObject> targets)
        {
            DMeshSO          target = targets[0] as DMeshSO;
            SurfaceBrushTool tool   = new_tool(scene, target);

            tool.Radius = InitialRadius.Clone();
            return(tool);
        }
Esempio n. 10
0
        public virtual SceneObject BuildPivot(FScene scene, TypedAttribSet attributes)
        {
            PivotSO so = new PivotSO();

            so.Create(scene.PivotSOMaterial, scene.FrameSOMaterial);
            RestorePivotSOType(scene, attributes, so);
            return(so);
        }
Esempio n. 11
0
        public void SceneOrbitAround(FScene scene, Vector3f position, float deltaAzimuth, float deltaAltitude)
        {
            Vector3f targetPos = Camera.GetTarget();

            Camera.SetTarget(position);
            SceneOrbit(scene, Camera, deltaAzimuth, deltaAltitude);
            Camera.SetTarget(targetPos);
        }
Esempio n. 12
0
 // restores scene values & cam target (but not cam position)
 public void SetCurrentSceneState(FScene scene, CameraState s)
 {
     scene.RootGameObject.SetPosition(s.scenePosition);
     scene.RootGameObject.SetRotation(s.sceneRotation);
     Camera.SetTarget(s.target);
     turntableAzimuthD  = s.turntableAzimuth;
     turntableAltitudeD = s.turntableAltitude;
 }
Esempio n. 13
0
        public void SceneTumbleAround(FScene scene, Vector3f position, float dx, float dy)
        {
            Vector3 targetPos = Camera.GetTarget();

            Camera.SetTarget(position);
            SceneTumble(scene, Camera, dx, dy);
            Camera.SetTarget(targetPos);
        }
Esempio n. 14
0
 // restores scene values & cam target (but not cam position)
 public void SetCurrentSceneState(FScene scene, CameraState s)
 {
     scene.RootGameObject.transform.position = s.scenePosition;
     scene.RootGameObject.transform.rotation = s.sceneRotation;
     getCamera().SetTarget(s.target);
     turntableAzimuth  = s.turntableAzimuth;
     turntableAltitude = s.turntableAltitude;
 }
Esempio n. 15
0
        public virtual SceneObject BuildPolyCurveSO(FScene scene, TypedAttribSet attributes)
        {
            PolyCurveSO so = new PolyCurveSO();

            so.Create(scene.DefaultSOMaterial);
            RestorePolyCurveSOType(scene, attributes, so);
            return(so);
        }
        public ITransformGizmo Build(FScene scene, List <SceneObject> targets)
        {
            SurfaceConstrainedGizmo gizmo = gizmo_factory();

            gizmo.WidgetScale = WidgetScale;
            gizmo.Create(scene, targets);
            return(gizmo);
        }
Esempio n. 17
0
 public FScene GetScene()
 {
     if (scene == null)
     {
         scene = new FScene(this);
     }
     return(scene);
 }
Esempio n. 18
0
        public void SceneOrbitAround(FScene scene, Vector3f position, float deltaAzimuth, float deltaAltitude)
        {
            Vector3 targetPos = getCamera().GetTarget();

            getCamera().SetTarget(position);
            SceneOrbit(scene, getCamera(), deltaAzimuth, deltaAltitude);
            getCamera().SetTarget(targetPos);
        }
Esempio n. 19
0
        protected virtual SceneObject BuildSOFromType(string typeIdentifier, FScene scene,
                                                      SceneSerializer serializer, TypedAttribSet attributes)
        {
            // restore custom type if client has registered a builder for it
            if (scene.TypeRegistry.ContainsType(typeIdentifier))
            {
                SOBuildFunc buildFunc = scene.TypeRegistry.FindBuilder(typeIdentifier);
                if (buildFunc != null)
                {
                    SceneObject so = buildFunc(this, scene, attributes);
                    if (so != null)
                    {
                        return(so);
                    }
                }
            }

            if (typeIdentifier == IOStrings.TypeCylinder)
            {
                return(BuildCylinder(scene, attributes));
            }
            else if (typeIdentifier == IOStrings.TypeBox)
            {
                return(BuildBox(scene, attributes));
            }
            else if (typeIdentifier == IOStrings.TypeSphere)
            {
                return(BuildSphere(scene, attributes));
            }
            else if (typeIdentifier == IOStrings.TypePivot)
            {
                return(BuildPivot(scene, attributes));
            }
            else if (typeIdentifier == IOStrings.TypeMeshReference)
            {
                return(BuildMeshReference(scene, serializer.TargetFilePath, attributes));
            }
            else if (typeIdentifier == IOStrings.TypePolyCurve)
            {
                return(BuildPolyCurveSO(scene, attributes));
            }
            else if (typeIdentifier == IOStrings.TypePolyTube)
            {
                return(BuildPolyTubeSO(scene, attributes));
            }
            else if (typeIdentifier == IOStrings.TypeMesh)
            {
                return(BuildMeshSO(scene, attributes));
            }
            else if (typeIdentifier == IOStrings.TypeDMesh)
            {
                return(BuildDMeshSO(scene, attributes));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 20
0
        // straight teleport:
        //   camera points at hit point, we back off and set target at hit point
        static public void TeleportTowards(Camera camera, FScene scene, Vector3 targetPoint, float fPullback)
        {
            fPullback *= scene.GetSceneScale();
            Vector3 vCurCamFW     = camera.transform.forward;
            Vector3 vNewCamPos    = targetPoint - fPullback * vCurCamFW;
            Vector3 vNewTargetPos = vNewCamPos + fPullback * vCurCamFW;

            camera.GetComponent <CameraAnimator>().Teleport(vNewCamPos, vNewTargetPos);
        }
Esempio n. 21
0
        public virtual void RestoreDMeshSO(FScene scene, TypedAttribSet attributes, DMeshSO so)
        {
            DMesh3 mesh = RestoreDMesh(attributes);

            so.Create(mesh, scene.DefaultSOMaterial);
            RestoreSOInfo(so, attributes);
            RestoreTransform(so, attributes);
            RestoreMaterial(so, attributes);
        }
Esempio n. 22
0
        public static float DefaultHeightInM = 1.6f;   // 1.6m ~= 5.5 feet


        // straight teleport:
        //   camera points at hit point, we back off and set target at hit point
        static public void TeleportTowards(fCamera camera, FScene scene, Vector3f targetPoint, float fPullback)
        {
            fPullback *= scene.GetSceneScale();
            Vector3f vCurCamFW     = camera.GetWorldFrame().Z;
            Vector3f vNewCamPos    = targetPoint - fPullback * vCurCamFW;
            Vector3f vNewTargetPos = vNewCamPos + fPullback * vCurCamFW;

            camera.Animator().Teleport(vNewCamPos, vNewTargetPos);
        }
Esempio n. 23
0
        public void SceneRotateAround(FScene scene, Quaternionf rotation, Vector3f position)
        {
            Frame3f curF = scene.RootGameObject.GetWorldFrame();

            curF.RotateAround(position, rotation);

            scene.RootGameObject.SetPosition(curF.Origin);
            scene.RootGameObject.SetRotation(curF.Rotation);
        }
Esempio n. 24
0
 public ITool Build(FScene scene, List <SceneObject> targets)
 {
     return(new SculptCurveTool(scene, targets)
     {
         Radius = InitialRadius.Clone(),
         SmoothAlpha = this.SmoothAlpha,
         SmoothIterations = this.SmoothIterations,
     });
 }
Esempio n. 25
0
        public IndicatorSet(FScene scene)
        {
            Scene = scene;

            preRender = new PreRenderHelper("indicators_helper")
            {
                PreRenderF = () => { this.PreRender(); }
            };
            scene.AddUIElement(preRender);
        }
Esempio n. 26
0
        public virtual SceneObject BuildPivot(FScene scene, TypedAttribSet attributes)
        {
            PivotSO so = new PivotSO();

            so.Create(scene.PivotSOMaterial, scene.FrameMaterial);
            safe_set_property_s(attributes, IOStrings.ASOName, (s) => { so.Name = s; });
            RestoreTransform(so, attributes);
            RestoreMaterial(so, attributes);
            return(so);
        }
Esempio n. 27
0
        public static void AnimatedDimiss_Scene(HUDStandardItem hudItem, FScene scene, bool bDestroy, float fDuration = 0.25f)
        {
            AnimatedDismissHUDItem anim = hudItem.RootGameObject.AddComponent <AnimatedDismissHUDItem>();

            anim.CompleteCallback += () => {
                anim.HUDItem.ClearGameObjects(false);
                scene.RemoveUIElement(anim.HUDItem, bDestroy);
            };
            anim.Play(hudItem, fDuration);
        }
        public ITool Build(FScene scene, List <SceneObject> targets)
        {
            CurveSelectFacesTool tool = build_tool(scene, targets[0] as DMeshSO);

            tool.OnStrokeCompletedF = this.OnStrokeCompletedF;
            tool.OnApplyF           = this.OnApplyF;
            tool.LineWidth          = DefaultLineWidth;
            tool.LineColor          = DefaultLineColor;
            return(tool);
        }
Esempio n. 29
0
        // level teleport:
        //   first we level the scene (ie scene up is y axis), then camera points
        //   at ray hit point, pulled back along cam direction projected into xz plane
        static public void TeleportTowards_Level(Camera camera, FScene scene, Vector3 targetPoint, float fPullback)
        {
            fPullback *= scene.GetSceneScale();
            Vector3 vCurCamFW     = camera.transform.forward;
            Vector3 vCurCamFWXZ   = new Vector3(vCurCamFW[0], 0.0f, vCurCamFW[2]).normalized;
            Vector3 vNewCamPos    = targetPoint - fPullback * vCurCamFWXZ;
            Vector3 vNewTargetPos = vNewCamPos + fPullback * vCurCamFWXZ;

            camera.GetComponent <CameraAnimator>().Teleport_Level(vNewCamPos, vNewTargetPos);
        }
Esempio n. 30
0
        // level teleport:
        //   first we level the scene (ie scene up is y axis), then camera points
        //   at ray hit point, pulled back along cam direction projected into xz plane
        static public void TeleportTowards_Level(fCamera camera, FScene scene, Vector3f targetPoint, float fPullback)
        {
            fPullback *= scene.GetSceneScale();
            Vector3f vCurCamFW     = camera.GetWorldFrame().Z;
            Vector3f vCurCamFWXZ   = new Vector3f(vCurCamFW[0], 0.0f, vCurCamFW[2]).Normalized;
            Vector3f vNewCamPos    = targetPoint - fPullback * vCurCamFWXZ;
            Vector3f vNewTargetPos = vNewCamPos + fPullback * vCurCamFWXZ;

            camera.Animator().Teleport_Level(vNewCamPos, vNewTargetPos);
        }