コード例 #1
0
    /// <summary>
    /// Rotates a point based on orientation correction received from VPS service.
    /// </summary>
    /// <returns>The point.</returns>
    /// <param name="pos">Position.</param>
    private static Vector3 RotatePoint(Vector3 pos)
    {
        Vector3 rotatedPos = new Vector3();

        //Create a parent object to rotate pos around this object
        GameObject parent = new GameObject();

        GameObject posToRotate = new GameObject();

        posToRotate.transform.parent = parent.transform;

        //Before rotation
        posToRotate.transform.position = pos;

        //GetOrientationCorrection() is identity before Localization
        Quaternion rotInWorld = XRSessionManager.GetSession().GetOrientationCorrection() * OrientationUtils.UnityToWorld(parent.transform.rotation);

        //Rotate parent object which will rotate its child(posToRotate) around it
        parent.transform.rotation = OrientationUtils.WorldToUnity(rotInWorld);

        rotatedPos = posToRotate.transform.position;    // Unity WorldPos of pos

        Destroy(posToRotate);
        Destroy(parent);

        return(rotatedPos);
    }
コード例 #2
0
    private void Log(bool isLocalizationRequest)
    {
        Data data = new Data();

        data.XrCamPos              = XRSessionManager.GetSession().GetXRCameraPosition();
        data.XrCamOrient           = XRSessionManager.GetSession().GetXRCameraOrientation();
        data.GpsPos                = XRSessionManager.GetSession().GetXRCameraLocation();
        data.GpsOrient             = OrientationUtils.UnityToWorld(XRSessionManager.GetSession().GetXRCameraOrientation());
        data.ProjectionMatrix      = XRSessionManager.GetSession().VideoProvider.GetProjectionMatrix();
        data.TimeStamp             = DateTime.Now.ToString("O");
        data.IsLocalizationRequest = isLocalizationRequest;

        _datas.Add(data);

        string jsonData = JsonHelper.ToJson <Data>(_datas.ToArray());

        File.WriteAllText(_path, jsonData);

        //Debug.Log("XR Cam Position: " + XRSessionManager.GetSession().GetXRCameraPosition());
        //Debug.Log("XR Cam Orientation: " + XRSessionManager.GetSession().GetXRCameraOrientation());
        //Debug.Log("GPS Position: " + XRSessionManager.GetSession().GetXRCameraLocation());
        //Debug.Log("GPS Orientation" + OrientationUtils.UnityToWorld(XRSessionManager.GetSession().GetXRCameraOrientation()));
        //Debug.Log("XR Cam Projection Matrix: " + XRSessionManager.GetSession().GetXRCameraPosition());
        //Debug.Log("Localization Request: " + isLocalizationRequest);
        //Debug.Log("Time Stamp: " + DateTime.Now.ToString("O"));
    }
コード例 #3
0
    /// <summary>
    /// Rotates a point based on orientation correction received from VPS service.
    /// </summary>
    /// <returns>The point.</returns>
    /// <param name="point">Position.</param>
    private static Vector3 RotatePoint(Vector3 point, bool useCompass = true)
    {
        // Ar orgin where all values recieved rom Arcore/Arkit will be under this origin
        GameObject arOrigin = new GameObject("ArOrigin");

        // Create a child Gameobject and set its localPosition to the point we get from ArCore/ArKit
        GameObject pointGO = new GameObject("Point");

        pointGO.transform.parent        = arOrigin.transform;
        pointGO.transform.localPosition = point;
        pointGO.transform.localRotation = Quaternion.identity;

        if (useCompass)
        {
            // First rotate this origin to align with trueHeading received from sensor
            arOrigin.transform.rotation = Quaternion.Euler(0, ArWorldTracking.TrueHeading, 0);
        }

        // Then rotate this again based on offset received from VPS Service
        Quaternion rotInWorld = XRSessionManager.GetSession().GetYawOrientationCorrection() * OrientationUtils.UnityToWorld(arOrigin.transform.rotation) * XRSessionManager.GetSession().GetPitchOrientationCorrection();

        arOrigin.transform.rotation = OrientationUtils.WorldToUnity(rotInWorld);

        var rotatedPos = pointGO.transform.position;    // Unity WorldPos of pos

        Destroy(arOrigin);
        Destroy(pointGO);

        return(rotatedPos);
    }
コード例 #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <GSYPlayerControlView> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement == null)
            {
                if (Control == null)
                {
                    player = new StandardGSYVideoPlayer(context);
                    var activity = (Activity)base.Context;

                    orientationUtils = new OrientationUtils(activity, player);
                    player.SetThumbPlay(true);

                    InitializePlayer(e.NewElement.Source, e.NewElement.AutoPlay, e.NewElement.Thumbnail, e.NewElement.Title);

                    SetNativeControl(player);

                    player.BackButton.Click += (sender, e) =>
                    {
                        try
                        {
                            player.SetUp("", true, "");
                            player.OnBackFullscreen();
                            activity.OnBackPressed();
                        }
                        catch (Exception ex)
                        {
                        }
                    };
                    player.FullscreenButton.Click += (sender, e) =>
                    {
                        try
                        {
                            if (!fullscreen)
                            {
                                fullscreen = true;
                                activity.Window.AddFlags(WindowManagerFlags.Fullscreen);

                                //var uiOptions = SystemUiFlags.HideNavigation | SystemUiFlags.ImmersiveSticky | SystemUiFlags.Fullscreen | SystemUiFlags.LayoutFullscreen | SystemUiFlags.LayoutHideNavigation;
                                // activity.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;
                            }
                            else
                            {
                                fullscreen = false;
                                activity.Window.ClearFlags(WindowManagerFlags.Fullscreen);
                                //activity.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.LayoutFullscreen | SystemUiFlags.LayoutHideNavigation);
                            }
                            orientationUtils.ResolveByClick();
                            player.StartWindowFullscreen(context, true, true);
                        }
                        catch (Exception ex)
                        {
                        }
                    };
                    mainpage = ((ViewGroup)player.Parent);
                }
            }
        }
コード例 #5
0
    public override Quaternion GetOrientation()
    {
        if (_providerStatus != ProviderStatus.Ready)
        {
            return(Quaternion.identity);
        }

        return(OrientationUtils.WorldToUnity(_sampleManager.GetDataAtCurrentIndex().quaternion));
    }
コード例 #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.activity_scrolling);

                appBarStateChangeListener = new IAppBarStateChangeListener();
                context = this;// this.BaseContext;
                initView();

                string url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";

                //增加封面
                ImageView imageView = new ImageView(this);
                imageView.SetScaleType(ImageView.ScaleType.CenterCrop);

                ResolveNormalVideoUI();

                //外部辅助的旋转,帮助全屏
                orientationUtils = new OrientationUtils(this, detailPlayer);
                //初始化不打开外部的旋转
                orientationUtils.Enable = false;//.setEnable(false);

                GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder();
                gsyVideoOption.SetThumbImageView(imageView)
                .SetIsTouchWiget(true)
                .SetRotateViewAuto(false)
                .SetLockLand(false)
                .SetShowFullAnimation(false)
                .SetNeedLockFull(true)
                .SetSeekRatio(1)
                .SetUrl(url)
                .SetCacheWithPlay(false)
                .SetVideoTitle("测试视频")
                .SetVideoAllCallBack(new IGSYSampleCallBack())
                .SetLockClickListener(this)
                .SetGSYVideoProgressListener(this)
                .Build(detailPlayer);

                detailPlayer.FullscreenButton.Click += (sender, e) =>
                {
                    //直接横屏
                    orientationUtils.ResolveByClick();

                    //第一个true是否需要隐藏actionbar,第二个true是否需要隐藏statusbar
                    detailPlayer.StartWindowFullscreen(this, true, true);
                };
            }
            catch (Java.Lang.Exception ex)
            {
                Log.Error("", ex.ToString());
            }

            //detailPlayer..setLinkScroll(true);
        }
コード例 #7
0
        public static LocomotionManager <UnitModelComponent> CreateMovementJourney(GameCourseModel model, UnitModelComponent unit, MyHexPosition target)
        {
            Assert.IsFalse(unit.Model.Position.Equals(target), "Unit is arleady at target");

            // todo, now it supports movement by only one hex, should be more
            Orientation targetOrientation = Orientation.N;

            for (int i = 0; i < 6; i++)
            {
                if (target.Equals(unit.Model.Position.Neighbors[i]))
                {
                    targetOrientation = unit.Model.Position.NeighborDirections[i];
                }
            }

            List <Orientation> transitionalOrientations = OrientationUtils.GetOrientationsToTarget(unit.Model.Orientation, targetOrientation);
            var journeySteps = new Queue <IJourneyStep <UnitModelComponent> >();

            foreach (var orientation in transitionalOrientations)
            {
                journeySteps.Enqueue(new JourneyDirector()
                {
                    To = orientation
                });
            }
            journeySteps.Enqueue(new JourneyBattle(BattleCircumstances.Director));
            journeySteps.Enqueue(new JourneyMotion()
            {
                To = target
            });
            journeySteps.Enqueue(new JourneyBattle(BattleCircumstances.Step));

            var delta = target - unit.Model.Position;

            journeySteps.Enqueue(new JourneyStepRepeat()
            {
                Delta = delta,
                NextStepsGenerator = (to) => new List <IJourneyStep <UnitModelComponent> >()
                {
                    new JourneyMotion()
                    {
                        To = to
                    },
                    (new JourneyBattle(BattleCircumstances.Step))
                }
            });

            return(new LocomotionManager <UnitModelComponent>(unit, journeySteps));
        }
コード例 #8
0
 public IAppBarStateChangeListener(OrientationUtils Utils, StandardGSYVideoPlayer player, Context ct)
 {
     _orientationUtils = Utils;
     _detailPlayer     = player;
     _context          = ct;
 }
コード例 #9
0
 public IGSYSampleCallBack(OrientationUtils Utils, StandardGSYVideoPlayer player)
 {
     _orientationUtils = Utils;
     _detailPlayer     = player;
 }
コード例 #10
0
 public override Quaternion GetOrientation()
 {
     return(OrientationUtils.WorldToUnity(_sampleManager.GetOrientationAtCurrentIndex()));
 }