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 AssetBrowserViewModel(string rootPath, Framework framework) { var rootFolder = new AssetFolder(rootPath, framework, this.thumbnailMgr); AssetFolders = new List<AssetFolder>(1) { rootFolder }; ShownAssets = new ObservableCollection<Asset>(); AssetFolders.ForEach((f) => AddToShownAssets(f)); // Type filters AssetTypeFilters = framework.AssetManager.AllAssetTypes .Select((type) => new AssetTypeFilter() { Type = type, Name = type.Name, IsChecked = false }).ToList(); AssetTypeFilters.Insert(0, new AssetTypeFilter() { Name = "All", IsChecked = true }); AssetTypeFilters.ForEach((f) => f.PropertyChanged += (o, e) => { if (e.PropertyName == "IsChecked") { AssetTypeFilter filter = o as AssetTypeFilter; if (filter.Name == "All" && filter.IsChecked == true) { AssetTypeFilters.Where((f2) => f2.Name != "All").ToList() .ForEach((f3) => f3.IsChecked = false); } else if (filter.Name != "All" && filter.IsChecked == true) { AssetTypeFilters.Find((f2) => f2.Name == "All").IsChecked = false; } UpdateShownAssetsView(); } }); // Register all assets to service (for global access) AssetService.SetAssetFolders(AssetFolders); }
public RenderViewModel(Framework fw, SceneManager sceneManager) { this.framework = fw; this.sceneManager = sceneManager; CompositionTarget.Rendering += CompositionTarget_Rendering; }
public LayoutEditorViewModel(LayoutAsset layoutAsset, Framework framework) { this.layoutAsset = layoutAsset; SceneManager = new SceneManager(framework.Device, framework.AssetManager); UpdateVisualTree(); RenderViewModel = new RenderViewModel(framework, SceneManager); RenderViewModel.SizeChanged += ((o, e) => { layoutAsset.Layout.Size = new Size(RenderViewModel.Width, RenderViewModel.Height); }); Elements = new ObservableCollection<UIElementEditor>() { UIElementEditor.Create(null, layoutAsset.Layout, framework.AssetManager) }; Elements.First().TreeChanged += (o, e) => UpdateVisualTree(); SaveCommand = new DelegateCommand(() => { layoutAsset.Layout.Save(layoutAsset.FullPath); StatusBarService.StatusText = "Layout saved: " + layoutAsset.ShortName; }); Document = new TextDocument(); IsDesignMode = true; this.xmlUpdateTimer.Interval = TimeSpan.FromMilliseconds(500); this.xmlUpdateTimer.Tick += UpdateXmlDocument; UpdateXmlDocument(this, EventArgs.Empty); RenderViewModel.MouseMove += RenderViewModel_MouseMove; RenderViewModel.MouseDown += RenderViewModel_MouseDown; RenderViewModel.MouseUp += RenderViewModel_MouseUp; }
public AssetFolder(string path, Framework framework, IThumbnailManager thumbnailMgr) { FullPath = Path.GetFullPath(path); Name = Path.GetFileName(FullPath); string rootDir = framework.AssetManager.RootPath; // Sub folders var folders = Directory.GetDirectories(FullPath).ToList(); folders.RemoveAll((f) => (File.GetAttributes(f) & FileAttributes.Hidden) == FileAttributes.Hidden); ChildFolders = new List<AssetFolder>(folders.Count); folders.ForEach((f) => ChildFolders.Add(new AssetFolder(f, framework, thumbnailMgr))); // Files var files = Directory.GetFiles(FullPath); Assets = new List<Asset>(files.Length); foreach (var file in files) { string name = FileService.GetRelativePath(rootDir + Path.DirectorySeparatorChar, file); var asset = Asset.Create(name, framework, thumbnailMgr); if (asset == null) continue; Assets.Add(asset); } }
public Rocket(Framework framework) { Mesh = framework.AssetManager.Load(@"RocketCommander\rocket.meshb") as Mesh; MeshNode = new MeshNode(framework.Device, this.Mesh) { Scale = new Vector3(scale, scale, scale) }; }
public void Framework_Constructor_Test() { var window = new Window("FrameworkTest", 640, 480); Framework fw = new Framework(window.Handle, window.Width, window.Height, RenderSettings.MediaPath); Assert.IsNotNull(fw.Device); Assert.IsNotNull(fw.AssetManager); Assert.IsNotNull(fw.Renderer); Assert.IsNotNull(fw.Light); }
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 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 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 Game(string title, int width, int height) { Width = width; Height = height; this.form = new Form() { Text = title, ClientSize = new System.Drawing.Size(Width, Height) }; // Initialize render system string mediaPath = Path.Combine(Directory.GetCurrentDirectory(), "../../../Media"); RenderSettings.MediaPath = Path.GetFullPath(mediaPath); this.framework = new Framework(form.Handle, Width, Height, RenderSettings.MediaPath); this.sceneManager = new SceneManager(this.framework.Device, this.framework.AssetManager); this.sceneManager.Camera.AspectRatio = (float)Width / (float)Height; }
public MainViewModel() { var hwnd = new HwndSource(0, 0, 0, 0, 0, "HwndSource for MainViewModel", IntPtr.Zero); Framework = new Framework(hwnd.Handle, 0, 0, RenderSettings.MediaPath); Framework.AssetManager.RegisterAssetFactory(new LayoutFactory()); // View-models ErrorListViewModel = new ErrorListViewModel(); OutputViewModel = new OutputViewModel(); StatusBarViewModel = new StatusBarViewModel(); // Commands ExitCommand = new DelegateCommand(() => Application.Current.Shutdown()); ShowAssetBrowserCommand = new DelegateCommand(() => DocumentService.ShowDocument(AssetBrowserDoc, false)); ExecuteBitmapFontBuilderCommand = new DelegateCommand(() => Process.Start(Settings.BitmapFontBuilderPath)); // Services StatusBarService.SetStatusBarViewModel(StatusBarViewModel); StatusBarService.StatusText = "Ready"; }
public Asset(Type assetType, string name, Framework framework, IThumbnailManager thumbnailMgr) { this.framework = framework; this.thumbnailMgr = thumbnailMgr; AssetType = assetType; Name = name; FullPath = this.framework.AssetManager.GetFullPath(name); ShortName = this.framework.AssetManager.GetShortName(name); ThumbnailPath = Name + ".jpg"; if (File.Exists(FullPath)) { FileSize = new FileInfo(FullPath).Length; } Operations = new List<Operation>() { new Operation() { Name = "Update Thumbnail Image", Command = new DelegateCommand(() => UpdateThumbnail()) } }; }
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()); }
public static Asset Create(string name, Framework framework, IThumbnailManager thumbnailMgr) { Type type = framework.AssetManager.GetAssetType(name); if (type == null) return null; string assetTypeName = typeof(Asset).Namespace + "." + type.Name + "Asset"; Type assetType = Type.GetType(assetTypeName); if (assetType == null) return null; return assetType.Assembly.CreateInstance(assetTypeName, false, BindingFlags.Default, null, new object[] { name, framework, thumbnailMgr }, null, null) as Asset; }
public MissionSelectionScreen(RocketCommanderGame game, Framework framework) : base(game, framework) { }
public HelpScreen(RocketCommanderGame game, Framework framework) : base(game, framework) { }
public MainMenuScreen(RocketCommanderGame game, Framework framework) : base(game, framework) { }
public void SetUp() { var hwnd = new HwndSource(0, 0, 0, 0, 0, "HwndSource for Framework", IntPtr.Zero); Framework = new Framework(hwnd.Handle, 0, 0, RenderSettings.MediaPath); }
public Screen(RocketCommanderGame game, Framework framework) { this.game = game; this.framework = framework; }
public ShaderAsset(string name, Framework framework, IThumbnailManager thumbnailMgr) : base(typeof(Shader), name, framework, thumbnailMgr) { this.openCommand = new DelegateCommand(OpenEditor); Operations.Add(new Operation() { Name = "Edit Using Shader Editor...", Command = OpenCommand }); }
public FontAsset(string name, Framework framework, IThumbnailManager thumbnailMgr) : base(typeof(Font), name, framework, thumbnailMgr) { }
public DirectXMeshAsset(string name, Framework framework, IThumbnailManager thumbnailMgr) : base(typeof(DirectXMesh), name, framework, thumbnailMgr) { this.importCommand = new DelegateCommand(ShowImportDialog); Operations.Add(new Operation() { Name = "Import...", Command = this.importCommand }); }