예제 #1
0
        public async Task <bool> Register(StereoApplication app, SpatialCoordinateSystem coordinateSystem, System.Numerics.Vector3 extents, int trianglesPerCubicMeter = 1000, bool onlyAdd = false, bool convertToLeftHanded = true)
        {
            this.currentHoloApp          = app;
            this.trianglesPerCubicMeter  = trianglesPerCubicMeter;
            this.currentCoordinateSystem = coordinateSystem;
            ConvertToLeftHanded          = convertToLeftHanded;
            OnlyAdd = onlyAdd;

            var result = await SpatialSurfaceObserver.RequestAccessAsync();

            if (result != SpatialPerceptionAccessStatus.Allowed)
            {
                return(false);
            }

            observer = new SpatialSurfaceObserver();
            observer.SetBoundingVolume(SpatialBoundingVolume.FromBox(coordinateSystem, new SpatialBoundingBox {
                Extents = extents
            }));

            foreach (var item in observer.GetObservedSurfaces())
            {
                lock (UpdateCache)
                {
                    UpdateCache[item.Key] = item.Value.UpdateTime.ToUniversalTime();
                }
                ProcessSurface(item.Value);
            }
            observer.ObservedSurfacesChanged += Observer_ObservedSurfacesChanged;

            return(true);
        }
        //########################################################################################################
        /// <summary>
        /// Method to call for build a new disc
        /// </summary>
        /// <param name="app"> the current running application that display the scene </param>
        /// <param name="color"> Urhosharp color </param>
        /// <param name="pos"> position x y z in the world scene (not relative to user position). The unit is the meter </param>
        /// <param name="r"> radius of the cylinder </param>
        /// <returns> UrhoSharp Text3D component </returns>
        public static Cylinder Disc(StereoApplication app, Color color, Vector3 pos, float r)
        {
            // create a new node in the scene and bind a new component to it
            var Node      = app.Scene.CreateChild();
            var Component = Node.CreateComponent <Cylinder>();

            // visual settings
            Component.Node.Scale    = new Vector3(r, 0.02f, r);
            Component.Node.Position = pos;
            Component.Color         = color;

            return(Component);
        }
예제 #3
0
        //TODO: handle Navigation/Rails (SpatialGestureSettings)

        public GesturesManager(StereoApplication app, SpatialStationaryFrameOfReference referenceFrame)
        {
            this.app            = app;
            this.referenceFrame = referenceFrame;

            tap.Tapped += Tap_Tapped;

            hold.HoldCanceled  += Hold_HoldCanceled;
            hold.HoldCompleted += Hold_HoldCompleted;
            hold.HoldStarted   += Hold_HoldStarted;

            manipulationTranslate.ManipulationCanceled  += ManipulationTranslate_ManipulationCanceled;
            manipulationTranslate.ManipulationCompleted += ManipulationTranslate_ManipulationCompleted;
            manipulationTranslate.ManipulationStarted   += ManipulationTranslate_ManipulationStarted;
            manipulationTranslate.ManipulationUpdated   += ManipulationTranslate_ManipulationUpdated;
        }
        //########################################################################################################
        /// <summary>
        /// Method to call for build a new Text3D
        /// </summary>
        /// <param name="app"> the current running application that display the scene </param>
        /// <param name="text"> text to display </param>
        /// <param name="pos"> position x y z in the world scene (not relative to user position). The unit is the meter </param>
        /// <returns> UrhoSharp Text3D component </returns>
        public static Text3D Text(StereoApplication app, string text, Vector3 pos)
        {
            // create a new node in the scene and bind a new component to it
            var textNode      = app.Scene.CreateChild();
            var textComponent = textNode.CreateComponent <Text3D>();

            textComponent.Node.SetScale(0.1f); // reduce the font size as its too large by default
            textComponent.Node.Position = pos;

            // text alignment
            textComponent.HorizontalAlignment = HorizontalAlignment.Center;
            textComponent.VerticalAlignment   = VerticalAlignment.Top;

            textComponent.ViewMask = 0x80000000;                      //hide from raycasts

            textComponent.SetFont(CoreAssets.Fonts.AnonymousPro, 26); // set font style
            textComponent.Text = text;

            return(textComponent); // component
        }
 //########################################################################################################
 /// <summary>
 /// Constructor of the generic list and set as attribute the current scene.
 /// </summary>
 /// <param name="app"> the current running application that display the scene </param>
 public Text3DAnnotationList(StereoApplication app)
 {
     _app = app;
 }