This project is read-only.

Landscape support

Oct 16, 2011 at 8:44 PM

Any way to view ARDisplay on Landscape?

Oct 19, 2011 at 10:19 PM

I'm about to bring on a fellow Microsoftie to help with the project and he thinks he's got landscape working. Hopefully we'll have this added soon. Mainly it deals with rotating the Up vector of the XNA matrix when projecting.

Oct 20, 2011 at 8:45 AM

Hi, the problem of vector rotating is that also you have to change the way you show the POIs. If you need help with the project, I can try it.

Oct 20, 2011 at 4:06 PM

It would be awesome if you could post some suggested changes. The best way to do it would be to open an issue in the issue tracker and then attach your modified files. If there are only a few changes in one file you could alternatively paste them in here.

If you're interested in becoming a contributor to the project, we're looking for help. There's an official process to sign up to be a contributor on a Microsoft sponsored project, but it's not a long one. Let me know if you're interested via e-mail (on the home page) and we can look at doing that.

Thank you!

Jan 5, 2012 at 4:40 PM

To rotate the VideoBrush add in MainPage_OrientationChanged something like: (but this will not solve to projection of ARItems, as they have to be projected differently, only VideoBrush feed will be ok)

if ((e.Orientation & PageOrientation.Landscape) != 0)
{
  int landscapeRightRotation = 180;
  // Rotate video brush from camera.
  if (e.Orientation == PageOrientation.LandscapeRight)
  {
    // Rotate for LandscapeRight orientation.
    ARDisplay.Video.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = landscapeRightRotation };
  }
  else
  {
    // Rotate for standard landscape orientation.
    ARDisplay.Video.RelativeTransform = new CompositeTransform() { CenterX = 0.5, CenterY = 0.5, Rotation = 0 };
   }
 }
else // portrait
{
 ARDisplay.Video.RelativeTransform = new CompositeTransform { CenterX = 0.5, CenterY = 0.5, Rotation = cam.Orientation;
}

Mar 7, 2012 at 10:05 AM

Any progress in this issue?

I'm really interested in using GART in landscape mode.

Apr 24, 2012 at 11:33 PM

My app, Pinbucket is showing items in any angle. The code could be easily adopted to work in rigid landscape orientation.
For sourcecode example go here: http://wpcounter.com/index.php?option=com_content&view=article&id=60:getting-gart-working-for-all-angles-and-orientations&catid=37:wp7dev&Itemid=57 

Nov 18, 2012 at 10:27 AM

To support all device orientation modes, you could use something as follows
(Note I added PreviousOrientation and CurrentOrientation properties to the WorldView class). 

        public PageOrientation CurrentPageOrientation { get; set; }
        private PageOrientation PreviousOrientation { get; set; }        
        

        private void EnsureViewport()
        {
            if (viewport.Width == 0 || PreviousOrientation != CurrentPageOrientation)
            {
                PreviousOrientation = CurrentPageOrientation;

                // Initialize the viewport and matrixes for 3d projection.
                // Create the ViewPort based on the size of ourselves (the view) and not the screen. That's
                // becase the View should be sized to the camera preview, which is not the same size as
                // the Page or Window.
                viewport = new Viewport(0, 0, (int)this.ActualWidth, (int)this.ActualHeight);

                float aspect = viewport.AspectRatio;
                projection = Matrix.CreatePerspectiveFieldOfView(1, aspect, NearClippingPlane, FarClippingPlane);
               
                Vector3 cameraUpVector = Vector3.Up;
                switch (CurrentPageOrientation)
                {
                    case PageOrientation.PortraitUp:
                        cameraUpVector = Vector3.Up;
                        break;

                    case PageOrientation.PortraitDown:
                        cameraUpVector = Vector3.Down;
                        break;

                    case PageOrientation.LandscapeLeft:
                        cameraUpVector = Vector3.Left;
                        break;

                    case PageOrientation.LandscapeRight:
                        cameraUpVector = Vector3.Right;
                        break;
                }

                view = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, cameraUpVector);

            }
        }

This code will only rotate 2D items, so you have to combine it with VideoBrush rotation to get the right effect

 

Nov 21, 2012 at 4:20 PM

Hey piotrw, I'm so happy to welcome you to the project. Thank you for looking into this ability, and now you should have rights to commit the code to source control. :)

Do you need help with the VideoBrush rotation? I'm pretty sure you've done that too, but if you need me to jump in on that I can.

Nov 25, 2012 at 11:42 AM

Hi there,

Change set 71078 adds device orientation support for GART toolkit. The BingAR demo by default will adopt to current orientation (tested by my HTC Mozart 7)

Current implementation requires the following changes in your code:

1. Add PortraitOrLandscape orientations

    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" >

2. Override OnOrientationChange() method for your page containing ARDisplay:

        protected override void OnOrientationChanged(OrientationChangedEventArgs e)
        {
            ARDisplay.HandleOrientationChange(e.Orientation);

            base.OnOrientationChanged(e);
        }

 

 

May 21, 2013 at 10:06 PM
Maybe worth to note that in the current version (and since commit 72294) the ARDisplay.HandleOrientationChange method only needs the OrientationChangedEventArgs itself as parameter. So now the method call looks like this:

ARDisplay.HandleOrientationChange(e);