예제 #1
0
 public EngineModel()
 {
     this.InitializeComponent();
     _compositor  = Window.Current.Compositor;
     _hostVisual  = _compositor.CreateContainerVisual();
     _sceneVisual = SceneVisual.Create(_compositor);
 }
예제 #2
0
        public HubblePage()
        {
            InitializeComponent();

            _compositor  = Window.Current.Compositor;
            _hostVisual  = _compositor.CreateContainerVisual();
            _sceneVisual = SceneVisual.Create(_compositor);
        }
예제 #3
0
        public ModelViewer()
        {
            this.InitializeComponent();

            // Create a camera and a ContainerVisual
            _compositor = Window.Current.Compositor;
            var root = _compositor.CreateContainerVisual();

            root.Size = new Vector2(1000, 1000);
            ElementCompositionPreview.SetElementChildVisual(this, root);

            // create a SceneVisual and insert it into the visual tree
            _sceneVisual = SceneVisual.Create(_compositor);
            root.Children.InsertAtTop(_sceneVisual);

            // instantiate viewport and assign it "good" default values
            _viewport = new Viewport(_compositor);
            _viewport.AttachToVisual(_sceneVisual);
            _viewport.Size   = Target.ActualSize;
            _viewport.Offset = new Vector3(_viewport.Size / 2f, 0f);

            // instantiate camera and assign it "good" default values
            _camera        = new OrbitalCamera(_compositor);
            _camera.Target = new Vector3(0f, 0f, 0f);
            _camera.Radius = 600f;
            _camera.Theta  = 0f;
            _camera.Phi    = MathF.PI / 4;

            // instantiate projection and assign it "good" default values
            PerspectiveProjection projection = new PerspectiveProjection(_compositor);

            projection.Fov = MathF.PI / 2;

            _camera.Projection = projection;
            _viewport.Camera   = _camera;

            // add event handler for chaning target size
            Target.SizeChanged += Target_SizeChanged;

            // event handlers for pointer events
            Target.PointerWheelChanged += Target_PointerWheelChanged;
            Target.PointerPressed      += Target_PointerPressed;
            Target.PointerReleased     += Target_PointerReleased;
            Target.PointerMoved        += Target_PointerMoved;

            Window.Current.CoreWindow.PointerReleased += CoreWindow_PointerReleased;
        }
예제 #4
0
        public async Task CrossThread4(UIElement mc)
        {
            try
            {
                Uri         uri         = new Uri("ms-appx:///assets/Telescope.gltf");
                StorageFile storageFile = await StorageFile.GetFileFromApplicationUriAsync(uri);


                compositor = Window.Current.Compositor;

                IBuffer buffer = await FileIO.ReadBufferAsync(storageFile);

                loader = new SceneLoaderComponent.SceneLoader();
                var sceneNode = loader.Load(buffer, compositor);


                hostVisual = compositor.CreateContainerVisual();
                hostVisual.RelativeSizeAdjustment = Vector2.One;
                hostVisual.Offset = new Vector3(0, 50, 0);
                ElementCompositionPreview.SetElementChildVisual(mc, hostVisual);

                sceneVisual      = SceneVisual.Create(compositor);
                sceneVisual.Root = SceneNode.Create(compositor);

                sceneVisual.Root.Children.Add(sceneNode);


                var rotationAnimation = compositor.CreateScalarKeyFrameAnimation();
                rotationAnimation.InsertKeyFrame(1.0f, 360.0f, compositor.CreateLinearEasingFunction());
                rotationAnimation.Duration          = TimeSpan.FromSeconds(16);
                rotationAnimation.IterationBehavior = AnimationIterationBehavior.Forever;

                sceneVisual.Root.Transform.RotationAxis = new Vector3(0.0f, 1.0f, 0.2f);
                sceneVisual.Root.Transform.StartAnimation("RotationAngleInDegrees", rotationAnimation);

                hostVisual.Children.InsertAtTop(sceneVisual);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
            }
        }