private void frmSettings_FormClosing(object sender, FormClosingEventArgs e) { if (!OKPressed) { settings = tmpSettings; } }
public static void SaveSettings(ProgramSettings settings) { try { string settingsFile = Path.Combine(Application.StartupPath, "settings.xml"); using (var fs = new FileStream(settingsFile, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) { var xs = new XmlSerializer(typeof(ProgramSettings)); xs.Serialize(fs, settings); fs.Close(); } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmMain_Load(object sender, EventArgs e) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); this.Text = string.Format("{0} {1}", Helpers.PROGRAM_NAME, Helpers.PROGRAM_VERSION); Helpers.CreateDataPaths(Application.StartupPath); Settings = Helpers.LoadSettings(); LoadObjectInObjectsTreeView(Path.Combine(Application.StartupPath, Settings.FolderBase)); InitialiseSceneTreeView(); core = new Core(pnlRenderer.Handle, Settings); selectedTool = Tool.None; mousePosition3D = core.Globals.Vector3(0, 0, 0); initialPosition = core.Globals.Vector3(0, 0, 0); sceneFileName = string.Empty; defaultProductName = Text; btnSnap.Checked = Settings.SnapToGrid; allMeshes = new List<Engine.Mesh>(); Show(); Focus(); doLoop = true; MainLoop(); }
public Mesh(ICore core, ProgramSettings settings, string fileName) : base(core) { this.core = core; this.settings = settings; mass = 0f; staticFriction = 0.9f; kineticFriction = 0.5f; softness = 0.1f; bounciness = 0.1f; materialIdx = -1; SetMaterialToCustom(); FileName = fileName; customTexture = string.Empty; //Name = fileName.Split(new[] { '\\' }).Last(); PhysicsId = -1; enableLightning = true; Name = core.GetName<Mesh>(); string ending = fileName.Split(new[] { '\\' }).Last().ToUpper(); mesh = core.Scene.CreateMeshBuilder(); if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.TVM))) { mesh.LoadTVM(fileName, true, false); } else if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.X))) { mesh.LoadXFile(fileName, true, false); } else if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.TVA))) { TVActor actor = core.Scene.CreateActor(); actor.Load(fileName, true, false); mesh = actor.GetDeformedMesh(); core.Scene.DestroyAllActors(); IsAnimated = true; } else return; mesh.EnableFrustumCulling(true, true); mesh.ComputeNormals(); mesh.ComputeBoundings(); mesh.ComputeOctree(); mesh.SetCullMode(CONST_TV_CULLING.TV_BACK_CULL); mesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA); mesh.SetAlphaTest(true); mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); mesh.SetShadowCast(true, true); lightmapIdx = mesh.GetTextureEx((int)CONST_TV_LAYER.TV_LAYER_LIGHTMAP); textureScale = new UV(1.0f, 1.0f); LoadTextures(); UniqueId = mesh.GetMeshName(); }
public frmSettings(ProgramSettings settings) { this.settings = settings; tmpSettings = settings; InitializeComponent(); }