//--------------------// #region Handlers /// <inheritdoc/> protected override void OnInitialize() { #region File handling if (Path.IsPathRooted(FilePath)) { _fullPath = FilePath; if (!_overwrite && File.Exists(_fullPath)) { // Load existing file Log.Info("Load file: " + _fullPath); _preset = XmlStorage.LoadXml <GpuParticlePreset>(_fullPath); } else { // Create new file Log.Info("Create file: " + _fullPath); _preset = new GpuParticlePreset(); _preset.SaveXml(_fullPath); } } else { // File name only? Might not save to same dir loaded from! Log.Info("Load file: " + FilePath); _preset = GpuParticlePreset.FromContent(FilePath); _fullPath = ContentManager.CreateFilePath("Graphics/GpuParticleSystem", FilePath); } #endregion // Initialize engine renderPanel.Setup(); // Setup scene _particleSystem = new GpuParticleSystem(_preset); _scene = new Scene { Positionables = { _particleSystem } }; renderPanel.Engine.Views.Add(new View(_scene, Camera) { BackgroundColor = Color.Black }); base.OnInitialize(); }
/// <inheritdoc/> protected override void RegisterRenderablesSync() { RegisterWater(); RegisterRenderComponentLight(); RegisterRenderComponent <StaticMesh>((entity, component) => { if (string.IsNullOrEmpty(component.Filename)) { return(null); } var model = new Model(XMesh.Get(Engine, component.Filename)) { Name = entity.Name }; ConfigureModel(model, component); return(model); }); RegisterRenderComponent <AnimatedMesh>((entity, component) => { if (string.IsNullOrEmpty(component.Filename)) { return(null); } var model = new AnimatedModel(XAnimatedMesh.Get(Engine, component.Filename)) { Name = entity.Name }; ConfigureModel(model, component); return(model); }); RegisterRenderComponent <TestSphere>((entity, component) => { var model = Model.Sphere(Engine, XTexture.Get(Engine, component.Texture), component.Radius, component.Slices, component.Stacks); model.Name = entity.Name; ConfigureModel(model, component); return(model); }); RegisterRenderComponent <CpuParticleSystem>((entity, component) => { if (string.IsNullOrEmpty(component.Filename)) { return(null); } var particleSystem = new OmegaEngine.Graphics.Renderables.CpuParticleSystem(CpuParticlePreset.FromContent(component.Filename)); ConfigureParticleSystem(entity, particleSystem, component); return(particleSystem); }); RegisterRenderComponent <GpuParticleSystem>((entity, component) => { if (string.IsNullOrEmpty(component.Filename)) { return(null); } var particleSystem = new OmegaEngine.Graphics.Renderables.GpuParticleSystem(GpuParticlePreset.FromContent(component.Filename)); ConfigureParticleSystem(entity, particleSystem, component); return(particleSystem); }); }