public void SceneManager_AddRemoveRenderable_Test() { var sceneMgr = new SceneManager(Device, AssetManager); var renderable = TestHelpers.CreateRenderableMock(Device); Assert.IsTrue(sceneMgr.AddRenderable(renderable)); Assert.IsFalse(sceneMgr.AddRenderable(renderable)); Assert.IsTrue(sceneMgr.RemoveRenderable(renderable)); Assert.IsFalse(sceneMgr.RemoveRenderable(renderable)); }
public WorldEditorViewModel(WorldAsset worldAsset, Framework framework) { SceneManager = new SceneManager(framework.Device, framework.AssetManager); WorldEditor = new WorldEditor(worldAsset.World, framework.AssetManager); var terrain = new Terrain(framework.Device, framework.AssetManager, 128, 128, 20, new string[] { "Test/water.bmp", "Test/slime2.bmp", "Test/slime1.bmp" }); SceneManager.AddRenderable(terrain); SceneManager.World = worldAsset.World; SceneManager.Camera.EyePos = new Vector3(0.0f, terrain.GetHeight(0, 0) + 10.0f, 0.0f); SceneManager.Camera.LookAt = new Vector3(100.0f, 0.0f, 100.0f); SceneManager.Camera.UpVec = Vector3.UnitY; SceneManager.Camera.FovY = new Radian(MathUtils.PI / 4); SceneManager.Camera.SetPlaneDistance(1.0f, 10000.0f); RenderViewModel = new RenderViewModel(framework, SceneManager); RenderViewModel.MouseMove += RenderViewModel_MouseMove; SaveCommand = new DelegateCommand(() => { worldAsset.World.Save(worldAsset.FullPath); StatusBarService.StatusText = "World saved: " + worldAsset.ShortName; }); }
public void SceneManager_Render_Test() { var sceneMgr = new SceneManager(Device, AssetManager); sceneMgr.AddRenderable(TestHelpers.CreateRenderableMock(Device)); sceneMgr.AddSprite(TestHelpers.CreateSpriteMock(Device)); Assert.IsTrue(sceneMgr.Render(RenderSystem, RenderSystem.PrimaryRenderTarget, false)); }
protected override bool RenderThumbnail(RenderTarget renderTarget) { var sceneManager = new SceneManager(this.framework.Device, this.framework.AssetManager); sceneManager.AddRenderable(new MeshNode(this.framework.Device, Mesh)); sceneManager.LocateCameraLookingMesh(Mesh); return sceneManager.Render(this.framework.Renderer, renderTarget, false); }
protected override bool RenderThumbnail(RenderTarget renderTarget) { var mesh = Mesh.CreateSphere(this.framework.Device, this.framework.AssetManager, Material, 5.0f, 80, 80); var sceneManager = new SceneManager(this.framework.Device, this.framework.AssetManager); sceneManager.AddRenderable(new MeshNode(this.framework.Device, mesh)); sceneManager.LocateCameraLookingMesh(mesh); return sceneManager.Render(this.framework.Renderer, renderTarget, false); }
public Asteroid(Framework framework, SceneManager sceneManager, int type) { string meshFile = @"RocketCommander\asteroid" + (type + 1).ToString() + ".meshb"; Mesh = framework.AssetManager.Load(meshFile) as Mesh; var random = new Random(); float[] scalings = new float[] {0.0249557421f, 0.01308855f, 0.0136641478f, 0.0136658037f, 0.008148187f}; float scale = random.Next(minScale, maxScale) * scalings[type]; MeshNode = new MeshNode(framework.Device, Mesh) { Scale = new Vector3(scale, scale, scale) }; sceneManager.AddRenderable(MeshNode); }
public SmallAsteroid(Framework framework, SceneManager sceneManager, int type) { string meshFile = @"RocketCommander\SmallAsteroid" + (type + 1).ToString() + ".meshb"; Mesh = framework.AssetManager.Load(meshFile) as Mesh; var random = new Random(); float[] scalings = new float[] {0.00243701926f, 0.00213851035f, 0.00200786744f}; float scale = (smallAsteroidSize + RandomHelper.GetRandomFloat(-2.5f, 5.0f)) * scalings[type]; MeshNode = new MeshNode(framework.Device, this.Mesh) { Scale = new Vector3(scale, scale, scale) }; sceneManager.AddRenderable(MeshNode); }
public Item(Framework framework, SceneManager sceneManager, Type type) { ItemType = type; string meshFile = @"RocketCommander\" + Enum.GetName(typeof(Type), ItemType) + ".meshb"; Mesh = framework.AssetManager.Load(meshFile) as Mesh; float[] scalings = new float[] { 0.006876214f, 0.009066273f, 0.0125944568f, 0.0146259107f, 0.0168181341f }; float scale = scalings[(int)type]; MeshNode = new MeshNode(framework.Device, Mesh) { Scale = new Vector3(scale, scale, scale) }; sceneManager.AddRenderable(MeshNode); }
public MaterialEditorViewModel(MaterialAsset materialAsset, Framework framework) { MaterialEditor = new MaterialEditor(materialAsset.Material); ResetCommand = new DelegateCommand<PropertyItem>((item) => System.Windows.MessageBox.Show(item.ToString())); AdvancedOptions = new List<MenuItem>(); AdvancedOptions.Add(new MenuItem() { Header = "Reset", Command = ResetCommand }); SaveCommand = new DelegateCommand(() => { materialAsset.Material.Save(materialAsset.FullPath); StatusBarService.StatusText = "Material saved: " + materialAsset.ShortName; }); var mesh = Mesh.CreateSphere(framework.Device, framework.AssetManager, materialAsset.Material, 5.0f, 80, 80); this.meshNode = new MeshNode(framework.Device, mesh); var sceneManager = new SceneManager(framework.Device, framework.AssetManager); sceneManager.LocateCameraLookingMesh(mesh); sceneManager.AddRenderable(this.meshNode); RenderViewModel = new RenderViewModel(framework, sceneManager); RenderViewModel.MouseMove += RenderViewModel_MouseMove; }
public ImportMeshViewModel(Framework framework, Mesh mesh, string initialSaveFolder) { this.framework = framework; // Actually, import already done. See argument "mesh" :) Mesh = mesh; var sceneManager = new SceneManager(framework.Device, framework.AssetManager); sceneManager.LocateCameraLookingMesh(mesh); sceneManager.AddRenderable(new MeshNode(framework.Device, Mesh)); RenderViewModel = new RenderViewModel(framework, sceneManager); MaterialEditor = new MaterialEditor(mesh.Material); SaveName = Path.GetFileNameWithoutExtension(Mesh.Name); SaveFolder = initialSaveFolder; OkCommand = new DelegateCommand(ExecuteOk, CanExecuteOk); CancelCommand = new DelegateCommand(() => { RequestCancel(); }); BrowseCommand = new DelegateCommand(ExecuteBrowse); FlipVCommand = new DelegateCommand(() => Mesh.FlipTextureV()); }