Exemplo n.º 1
0
        private void ScaleToPlane(ARPlaneAnchor planeAnchor)
        {
            // Determine if extent should be flipped (plane is 90 degrees rotated)
            var planeXAxis  = planeAnchor.Transform.Column0.Xyz;
            var axisFlipped = Math.Abs(SCNVector3.Dot(planeXAxis, this.WorldRight)) < 0.5f;

            // Flip dimensions if necessary
            var planeExtent = planeAnchor.Extent;

            if (axisFlipped)
            {
                planeExtent = new OpenTK.NVector3(planeExtent.Z, 0f, planeExtent.X);
            }

            // Scale board to the max extent that fits in the plane
            var width = Math.Min(planeExtent.X, GameBoard.MaximumScale);
            var depth = Math.Min(planeExtent.Z, width * this.AspectRatio);

            width      = depth / this.AspectRatio;
            this.Scale = new SCNVector3(width, width, width);

            // Adjust position of board within plane's bounds
            var planeLocalExtent = new SCNVector3(width, 0f, depth);

            if (axisFlipped)
            {
                planeLocalExtent = new SCNVector3(planeLocalExtent.Z, 0f, planeLocalExtent.X);
            }

            this.AdjustPosition(planeAnchor, planeLocalExtent);
        }
Exemplo n.º 2
0
 public static SCNVector3 ToSCNVector3(this OpenTK.NVector3 self)
 {
     return(new SCNVector3(self.X, self.Y, self.Z));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Converts an <see cref="OpenTK.NVector3"/> into a <see cref="Vector3"/>.
 /// </summary>
 /// <param name="glVector3">The vector to be converted</param>
 /// <param name="waveVector">The converted vector</param>
 internal static void ToWave(this OpenTK.NVector3 glVector3, out Vector3 waveVector)
 {
     waveVector.X = glVector3.X;
     waveVector.Y = glVector3.Y;
     waveVector.Z = glVector3.Z;
 }