Ejemplo n.º 1
0
        public ShellViewModel(
            Func <AssetPanelViewModel> assetPanelViewModelFactory,
            Func <HierarchyPanelViewModel> hierarchyPanelViewModelFactory,
            Func <DrawOrderPanelViewModel> drawOrderPanelViewModelFactory,
            Func <PropertiesPanelViewModel> propertyPanelViewModelFactory,
            Func <DopesheetPanelViewModel> dopesheetPanelViewModelFactory,
            Func <HistoryPanelViewModel> historyPanelViewModelFactory,
            Func <ModeSwitchPanelViewModel> modeSwitchPanelViewModelFactory,
            Func <AnimationsPanelViewModel> animationsPanelViewModelFactory,
            Func <ExportSpritesheetViewModel> exportSpritesheetViewModelFactory,
            SceneEditorViewModel sceneEditorViewModel,
            Editor editor)
        {
            _exportSpritesheetViewModelFactory = exportSpritesheetViewModelFactory;
            _editor = editor;

            Title  = $"Pose {Assembly.GetEntryAssembly().GetName().Version}";
            Width  = 1600;
            Height = 900;

            AssetPanel      = assetPanelViewModelFactory.Invoke();
            HierarchyPanel  = hierarchyPanelViewModelFactory.Invoke();
            DrawOrderPanel  = drawOrderPanelViewModelFactory.Invoke();
            PropertyPanel   = propertyPanelViewModelFactory.Invoke();
            DopesheetPanel  = dopesheetPanelViewModelFactory.Invoke();
            HistoryPanel    = historyPanelViewModelFactory.Invoke();
            ModeSwitchPanel = modeSwitchPanelViewModelFactory.Invoke();
            AnimationsPanel = animationsPanelViewModelFactory.Invoke();
            SceneEditor     = sceneEditorViewModel;

            AutoKeyVisibility = Visibility.Hidden;

            OnEditorModeChanged(new EditorModeChanged(_editor.Mode));
            ConfigureMessageHandlers();
        }
Ejemplo n.º 2
0
 public BoneGizmo(SceneEditorViewModel sceneEditor, BoneNodeEditorItem boneNodeEditorItem)
 {
     _sceneEditor        = sceneEditor;
     _boneNodeEditorItem = boneNodeEditorItem;
     _lastZoom           = float.MinValue;
     CreateGizmo();
 }
        public PartialViewResult GetObjectsInScene(int sceneId)
        {
            SceneEditorViewModel viewModel = new SceneEditorViewModel()
            {
                VRObjects       = _VRObjectService.GetVROBjectsWithSceneId(sceneId),
                VRHotspots      = _VRObjectService.GetVRHotspotsWithSceneId(sceneId),
                VRQuestionCards = _VRObjectService.GetVRQuestionsWithSceneId(sceneId)
            };

            if (viewModel.VRQuestionCards != null && viewModel.VRQuestionCards.Count() != 0)
            {
                if (viewModel.VRQuestionCards != null && viewModel.VRQuestionCards.Count() != 0)
                {
                    var responses = getResponsesWithQuestionCards(viewModel.VRQuestionCards);

                    if (responses != null)
                    {
                        if (responses.Count() > 0)
                        {
                            viewModel.Responses = responses;
                        }
                    }
                }
            }
            return(PartialView("_ObjectEditorCarousel", viewModel));
        }
Ejemplo n.º 4
0
        public BoneNodeEditorItem(ulong nodeId, SceneEditorViewModel sceneEditor)
            : base(nodeId, sceneEditor)
        {
            _sceneEditor = sceneEditor;

            CreateSubItems();
            RefreshPropertiesFromNode();
        }
Ejemplo n.º 5
0
        public SpriteNodeEditorItem(ulong nodeId, SceneEditorViewModel sceneEditor, SpriteBitmap spriteBitmap)
            : base(nodeId, sceneEditor)
        {
            _sceneEditor  = sceneEditor;
            _spriteBitmap = spriteBitmap;

            CreateSubItems();
            RefreshPropertiesFromNode();
        }
Ejemplo n.º 6
0
        public void Constructor_ShouldLoadTheSceneFromFile()
        {
            // Arrange
            _sceneLoader.Load(SceneFilePath).Returns(TestSceneFactory.Create());

            // Act
            _ = new SceneEditorViewModel(SceneFilePath, _eventBus, _sceneLoader, _sceneModelFactory);

            // Assert
            _sceneLoader.Received(1).Load(SceneFilePath);
        }
Ejemplo n.º 7
0
        public RotateItemOperation(SceneEditorViewModel sceneEditor, EditorItem editorItem, Vector initialMousePosition)
            : base(editorItem, initialMousePosition)
        {
            _sceneEditor = sceneEditor;
            var initialMouseFromCenter = initialMousePosition - editorItem.GetPositionInScreenSpace();

            _initialAngle = editorItem.Transformation.LocalRotation;

            _initialMouseAngle = (float)Math.Atan2(-initialMouseFromCenter.Y, initialMouseFromCenter.X);
            _rotationTracker   = new RotationTracker(_initialMouseAngle, _initialAngle);
        }
        public PartialViewResult UpdateHotspotModal(int sceneId)
        {
            SceneEditorViewModel viewModel = new SceneEditorViewModel()
            {
                VRObjects       = _VRObjectService.GetVROBjectsWithSceneId(sceneId),
                VRQuestionCards = _VRObjectService.GetVRQuestionsWithSceneId(sceneId)
            };

            foreach (VRObject v in viewModel.VRObjects)
            {
                Console.WriteLine(v.AssetName);
            }

            return(PartialView("_AddHotspotPartialModal", viewModel));
        }
Ejemplo n.º 9
0
        public void SaveDocument_ShouldSaveSceneToFile()
        {
            // Arrange
            var scene = TestSceneFactory.Create();

            _sceneLoader.Load(SceneFilePath).Returns(scene);

            var sceneEditorViewModel = new SceneEditorViewModel(SceneFilePath, _eventBus, _sceneLoader, _sceneModelFactory);

            // Act
            sceneEditorViewModel.SaveDocument();

            // Assert
            _sceneLoader.Received(1).Save(scene, SceneFilePath);
        }
        // GETTING METHODS
        public PartialViewResult GetScenes(int courseId)
        {
            IEnumerable <Scene> scenes   = _sceneService.GetScenesWithCourseId(courseId);
            List <int>          sceneIds = new List <int>();

            foreach (Scene scene in scenes)
            {
                sceneIds.Add(scene.Id);
            }

            IEnumerable <VRBackground> Backgrounds = _VRBackgroundService.getBackgroundImagesWithSceneIds(sceneIds);
            SceneEditorViewModel       viewModel   = new SceneEditorViewModel()
            {
                CourseId    = courseId,
                Scenes      = scenes,
                Backgrounds = Backgrounds
            };

            return(PartialView("_ExistingScenes", viewModel));
        }
Ejemplo n.º 11
0
        public void OnDocumentSelected_ShouldSendEventWithSceneModel()
        {
            // Arrange
            var scene      = TestSceneFactory.Create();
            var sceneModel = TestSceneModelFactory.Create(scene);

            _sceneLoader.Load(SceneFilePath).Returns(scene);
            _sceneModelFactory.Create(scene).Returns(sceneModel);

            var sceneEditorViewModel = new SceneEditorViewModel(SceneFilePath, _eventBus, _sceneLoader, _sceneModelFactory);

            SelectedSceneModelChangedEvent? @event = null;

            _eventBus.RegisterEventHandler <SelectedSceneModelChangedEvent>(e => @event = e);

            // Act
            sceneEditorViewModel.OnDocumentSelected();

            // Assert
            Assert.That(@event, Is.Not.Null);
            Assert.That(@event !.SceneModel, Is.EqualTo(sceneModel));
        }
        public PartialViewResult UpdateScene(int courseId, int selectedIndex)
        {
            SceneEditorViewModel viewModel;

            IEnumerable <Scene>          scenes          = _sceneService.GetScenesWithCourseId(courseId);
            IEnumerable <VRObject>       vRObjects       = _VRObjectService.GetVROBjectsWithSceneId(scenes.ElementAt(selectedIndex).Id);
            IEnumerable <VRHotspot>      vRHotspots      = _VRObjectService.GetVRHotspotsWithSceneId(scenes.ElementAt(selectedIndex).Id);
            IEnumerable <VRQuestionCard> vRQuestionCards = _VRObjectService.GetVRQuestionsWithSceneId(scenes.ElementAt(selectedIndex).Id);

            List <int> sceneIds = new List <int>();

            foreach (Scene scene in scenes)
            {
                sceneIds.Add(scene.Id);
            }

            IEnumerable <VRBackground> BackgroundImages = _VRBackgroundService.getBackgroundImagesWithSceneIds(sceneIds);

            viewModel = new SceneEditorViewModel()
            {
                CourseId          = courseId,
                AddSceneViewModel = new AddSceneViewModel(),
            };

            if (BackgroundImages != null)
            {
                viewModel.Backgrounds = BackgroundImages;
            }
            if (scenes.Count() != 0)
            {
                viewModel.Scenes        = scenes;
                viewModel.SelectedScene = 0;
            }

            if (vRObjects != null && vRObjects.Count() != 0)
            {
                viewModel.VRObjects = vRObjects;
            }
            if (vRQuestionCards != null && vRQuestionCards.Count() != 0)
            {
                viewModel.VRQuestionCards = vRQuestionCards;
            }
            if (vRHotspots != null && vRHotspots.Count() != 0)
            {
                viewModel.VRHotspots = vRHotspots;
            }

            if (selectedIndex > 0)
            {
                viewModel.SelectedScene = selectedIndex;
            }
            if (viewModel.VRQuestionCards != null && viewModel.VRQuestionCards.Count() != 0)
            {
                var responses = getResponsesWithQuestionCards(viewModel.VRQuestionCards);

                if (responses != null)
                {
                    if (responses.Count() > 0)
                    {
                        viewModel.Responses = responses;
                    }
                }
            }

            return(PartialView("_SceneCreation", viewModel));
        }
        public IActionResult SceneEditor(int courseId, int selectedIndex)
        {
            SceneEditorViewModel         viewModel;
            IEnumerable <Scene>          scenes          = _sceneService.GetScenesWithCourseId(courseId);
            IEnumerable <VRObject>       vRObjects       = new List <VRObject>();
            IEnumerable <VRHotspot>      vRHotspots      = new List <VRHotspot>();
            IEnumerable <VRQuestionCard> vRQuestionCards = new List <VRQuestionCard>();
            List <int> sceneIds = new List <int>();

            viewModel = new SceneEditorViewModel()
            {
                CourseId          = courseId,
                AddSceneViewModel = new AddSceneViewModel(),
            };

            if (scenes != null)
            {
                if (scenes.Count() > 0)
                {
                    if (_VRObjectService.GetVROBjectsWithSceneId(scenes.ElementAt(selectedIndex).Id) != null)
                    {
                        // If there are vr objects in the scene, return them
                        vRObjects = _VRObjectService.GetVROBjectsWithSceneId(scenes.ElementAt(selectedIndex).Id);
                    }
                    if (_VRObjectService.GetVRHotspotsWithSceneId(scenes.ElementAt(selectedIndex).Id) != null)
                    {
                        // If there are vrHotSpot objects in the scene, return them
                        vRHotspots = _VRObjectService.GetVRHotspotsWithSceneId(scenes.ElementAt(selectedIndex).Id);
                    }
                    if (_VRObjectService.GetVRQuestionsWithSceneId(scenes.ElementAt(selectedIndex).Id) != null)
                    {
                        // If there are vr Question objects in the scene, return them
                        vRQuestionCards = _VRObjectService.GetVRQuestionsWithSceneId(scenes.ElementAt(selectedIndex).Id);
                    }
                }
                // Return the scenes for the existing scenes component
                foreach (Scene scene in scenes)
                {
                    sceneIds.Add(scene.Id);
                }

                viewModel.Scenes        = scenes;
                viewModel.SelectedScene = 0;

                IEnumerable <VRBackground> Backgrounds = _VRBackgroundService.getBackgroundImagesWithSceneIds(sceneIds);

                if (vRObjects != null && vRObjects.Count() != 0)
                {
                    viewModel.VRObjects = vRObjects;
                }
                if (vRHotspots != null && vRHotspots.Count() != 0)
                {
                    viewModel.VRHotspots = vRHotspots;
                }
                if (vRQuestionCards != null && vRQuestionCards.Count() != 0)
                {
                    var responses = getResponsesWithQuestionCards(vRQuestionCards);

                    if (responses != null)
                    {
                        if (responses.Count() > 0)
                        {
                            viewModel.Responses = responses;
                        }
                    }

                    viewModel.VRQuestionCards = vRQuestionCards;
                }
                if (selectedIndex > 0)
                {
                    viewModel.SelectedScene = selectedIndex;
                }
                if (Backgrounds != null)
                {
                    viewModel.Backgrounds = Backgrounds;
                }
            }
            return(View(viewModel));
        }
Ejemplo n.º 14
0
 public TranslateItemOperation(SceneEditorViewModel sceneEditor, EditorItem item, Vector initialMousePosition) : base(item, initialMousePosition)
 {
     _sceneEditor = sceneEditor;
 }
Ejemplo n.º 15
0
 /// <inheritdoc />
 protected override EntityHierarchyEditorViewModel CreateEditorViewModel(AssetViewModel asset)
 {
     return(SceneEditorViewModel.Create((SceneViewModel)asset));
 }
Ejemplo n.º 16
0
 public PoseTool(SceneEditorViewModel sceneEditor)
 {
     _sceneEditor = sceneEditor;
 }
Ejemplo n.º 17
0
 public DrawBoneTool(SceneEditorViewModel sceneEditor)
 {
     _sceneEditor = sceneEditor;
 }
Ejemplo n.º 18
0
 public DrawBoneOperation(SceneEditorViewModel sceneEditor, Vector initialMousePosition) : base(initialMousePosition)
 {
     _sceneEditor = sceneEditor;
     _positionWorld = _sceneEditor.SceneViewport.ScreenToWorldPosition(initialMousePosition);
     CreateBoneGizmo(_positionWorld);
 }
Ejemplo n.º 19
0
 public SelectionGizmo(SceneEditorViewModel sceneEditor, ulong nodeId)
 {
     _sceneEditor = sceneEditor;
     _nodeId      = nodeId;
     CreateGizmo();
 }
Ejemplo n.º 20
0
 protected EditorItem(ulong nodeId, SceneEditorViewModel sceneEditor)
 {
     _sceneEditor = sceneEditor;
     NodeId       = nodeId;
 }
Ejemplo n.º 21
0
 public RotationGizmo(SceneEditorViewModel sceneEditor, EditorItem item)
 {
     _sceneEditor = sceneEditor;
     _item        = item;
     CreateGizmo();
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SceneEditorController"/> class.
 /// </summary>
 /// <param name="asset">The scene associated with this instance.</param>
 /// <param name="editor">The editor associated with this instance.</param>
 public SceneEditorController([NotNull] AssetViewModel asset, [NotNull] SceneEditorViewModel editor)
     : base(asset, editor, CreateEditorGame)
 {
 }
Ejemplo n.º 23
0
 public ModifyTool(SceneEditorViewModel sceneEditor)
 {
     _sceneEditor = sceneEditor;
 }
Ejemplo n.º 24
0
 public PanCameraOperation(SceneEditorViewModel sceneEditor, Vector initialMousePosition) : base(initialMousePosition)
 {
     _sceneEditor           = sceneEditor;
     _initialCameraPosition = sceneEditor.SceneViewport.SceneCamera.Position;
 }