//--------------------------------------------------- static public void estimateMemory(bool forceAutoSave, bool asyncTest) { if (mEstimatingMemory != 0) { return; } using (PerfSection p3 = new PerfSection("estimateMemory")) { System.Threading.Interlocked.Exchange(ref mEstimatingMemory, 1); TerrainGlobals.getTerrainFrontEnd().setMemoryEstimateString(null, "Calculating.."); if (asyncTest) { int hackedStatePacket = forceAutoSave ? 1 : 0; hackedStatePacket = hackedStatePacket << 1; hackedStatePacket |= asyncTest ? 1 : 0; BackgroundWorker mWorkerThread = new BackgroundWorker(); mWorkerThread.WorkerReportsProgress = false; mWorkerThread.WorkerSupportsCancellation = true; mWorkerThread.DoWork += bw_Work; mWorkerThread.RunWorkerAsync(hackedStatePacket); } else { doMemoryEstimate(forceAutoSave); updateGUIElements(asyncTest); } } }
private void checkBox3_CheckedChanged(object sender, EventArgs e) { mData.mDoSaveData["CopiedUnitData"] = checkBox3.Checked; mData.SetThumbnail(TerrainGlobals.getTerrainFrontEnd().renderThumbnail(mData.mDoSaveData["CopiedTextureData"], mData.mDoSaveData["CopiedUnitData"])); pictureBox1.Image = mData.mThumbnail; pictureBox1.Invalidate(); }
public void addSelectTexture(TerrainTextureButton but) { if (mSelectedButton != null) { mSelectedButton.Invalidate(); } mSelectedButton = but; mSelectedButton.Invalidate(); if (but is TerrainTextureSplatButton) { SelectedDef = SimTerrainType.getFromTypeName(but.typename); if (!isActiveSetSelected()) { TerrainGlobals.getTexturing().addActiveTexture(SimTerrainType.getWorkingTexName(mSelectedDef)); } } else if (but is TerrainTextureDecalButton) { if (!isActiveSetSelected()) { TerrainGlobals.getTexturing().addActiveDecal(((TerrainTextureDecalButton)but).mFullFilename); } TerrainGlobals.getTerrainFrontEnd().SelectedDecalIndex = TerrainGlobals.getTexturing().getActiveDecalIndex(((TerrainTextureDecalButton)but).mFullFilename); if (TerrainGlobals.getEditor().getRenderMode() == BTerrainEditor.eEditorRenderMode.cRenderTextureSelectRender) { TerrainGlobals.getTexturing().reloadCachedVisuals(); } } }
public void Init() { mBuffer = new Bitmap(pictureBox1.Width / 4, pictureBox1.Height / 4, System.Drawing.Imaging.PixelFormat.Format24bppRgb); mFloats = new float[pictureBox1.Width / 4, pictureBox1.Height / 4]; mFunction = (BasicNoise)TerrainGlobals.getTerrainFrontEnd().getNoiseFunction(); this.floatSlider1.Constraint = mFunction.mScaleX; this.floatSlider1.ValueName = "Scale X"; this.floatSlider2.Constraint = mFunction.mScaleY; this.floatSlider2.ValueName = "Scale Z"; this.floatSlider3.Constraint = mFunction.mPersistance; this.floatSlider3.ValueName = "Persistance"; this.floatSlider4.Constraint = mFunction.mOctaves; this.floatSlider4.ValueName = "Octaves"; this.floatSlider4.mbIntStep = true; this.floatSlider5.Constraint = mFunction.mFreq; this.floatSlider5.ValueName = "Frequency"; this.floatSlider6.Constraint = mFunction.mAmplitude; this.floatSlider6.ValueName = "Amplitude"; }
private void button2_Click(object sender, EventArgs e) { button2.Enabled = false; TerrainGlobals.getTerrainFrontEnd().updateMemoryEstimate(true, false); refresh(false); button2.Enabled = true; }
public void Init() { foreach (Modifier m in TerrainGlobals.getTerrainFrontEnd().mModifiers.Values) { ModifierControl c = new ModifierControl(); c.mModifier = m; flowLayoutPanel1.Controls.Add(c); } }
private void button2_Click(object sender, EventArgs e) { float eLOD = 0.25f; if (highMeshLOD.Checked) { eLOD = 0.25f; } if (medMeshLOD.Checked) { eLOD = 0.5f; } if (lowMeshLOD.Checked) { eLOD = 1.0f; } string outputFile = textBox1.Text; if (exportAllVerts.Checked) { if (refineRQT.Checked) { TerrainGlobals.getTerrainFrontEnd().exportRefinedRQTTerrainToObj(outputFile, exportSelectedVerts.Checked); } else if (refineTIN.Checked) { TerrainGlobals.getTerrainFrontEnd().exportRefinedTINTerrainToObj(outputFile, exportSelectedVerts.Checked, eLOD); } else if (refineNone.Checked) { ObjExporter exp = new ObjExporter(); exp.writeAll(outputFile); exp = null; } } else if (exportSelectedVerts.Checked) { if (refineRQT.Checked) { TerrainGlobals.getTerrainFrontEnd().exportRefinedRQTTerrainToObj(outputFile, exportSelectedVerts.Checked); } else if (refineTIN.Checked) { TerrainGlobals.getTerrainFrontEnd().exportRefinedTINTerrainToObj(outputFile, exportSelectedVerts.Checked, eLOD); } else if (refineNone.Checked) { ObjExporter exp = new ObjExporter(); exp.writeSelection(outputFile); exp = null; } } Close(); }
private void radioAddButton_CheckedChanged(object sender, EventArgs e) { if (mbSuspendUIUpdate) { return; } if (radioAddButton.Checked == false) { return; } TerrainGlobals.getTerrainFrontEnd().PasteOperation = BTerrainFrontend.ePasteOperation.Add; ClipArtSetDirty(); }
public void apply() { string fName = Path.GetFileNameWithoutExtension(mData.Texture); string dir = Path.GetDirectoryName(mData.Texture); string themeName = dir.Substring(dir.LastIndexOf("\\") + 1); TerrainTextureDef SelectedDef = SimTerrainType.getFromTypeName(themeName + "_" + fName); TerrainGlobals.getTexturing().addActiveTexture(SimTerrainType.getWorkingTexName(SelectedDef)); SimTerrainType.addActiveSetDef(SelectedDef); TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex = SimTerrainType.getActiveSetIndex(SelectedDef); TerrainGlobals.getEditor().applyTextureToMask(); }
private void InitToolBars() { mMaskPalette.mButtonSize = 32; mMaskPalette.mbRestrictTextureSize = false; if (CoreGlobals.getSettingsFile().ThreadedStart == true) { mMaskPalette.threadedInit(TerrainGlobals.getTerrainFrontEnd().getMaskTextures()); } else { mMaskPalette.init(TerrainGlobals.getTerrainFrontEnd().getMaskTextures()); } mMaskPalette.mTextureSelected += new TexturePalette.TextureSelected(mMaskPalette_mTextureSelected); mMaskPalette.OverflowButton.Size = new Size(100, 100); mMaskPalette.OverflowButton.AutoSize = false; }
void mMaskPalette_mTextureSelected(int id) { try { TerrainGlobals.getTerrainFrontEnd().SelectedMaskIndex = id; //Todo cleaner way to access this window??? if (MainWindow.mMainWindow.mBrushSettingsWindow != null) { MainWindow.mMainWindow.mBrushSettingsWindow.Stroke = TerrainGlobals.getEditor().getCurrentStroke(); } } catch (System.Exception ex) { CoreGlobals.getErrorManager().OnException(ex); } }
static void updateGUIElements(bool asyncTest) { //update our main GUI progress bar (previous element?) float amt = giveMemoryUsagePercent(); if (asyncTest) { ThreadSafeMessageList.MessagePacket mp = new ThreadSafeMessageList.MessagePacket(); mp.mCallback = TerrainGlobals.getTerrainFrontEnd().setMemoryEstimateGUIValue; mp.mDataObject = amt; CoreGlobals.getEditorMain().mMessageList.enqueueMessage(mp); } else { TerrainGlobals.getTerrainFrontEnd().setMemoryEstimateGUIValue(null, amt); } }
void SelectButton(ClipArtButton b) { if (mSelectedButton != null) { mSelectedButton.Invalidate(); } mSelectedButton = b; mSelectedButton.Invalidate(); //selectedgroupBox.Text = String.Format("Selected: {0}", Path.GetFileName(mSelectedButton.mData.mFileName)); //this.selectedMetaDesctextBox.Text = mSelectedButton.mData.mMetadata.mDescription; //this.selectedDesctextBox.Text = String.Format("VertCount:{0}\r\nDataChannels:\r\n{1}", mSelectedButton.mData.mMetadata.mVertCount, mSelectedButton.mData.getComponentList()); TerrainGlobals.getEditor().SetClipArt(mSelectedButton.mData); TerrainGlobals.getTerrainFrontEnd().PasteMode(); }
public void setTextureProperties() { BTerrainActiveTextureContainer act = TerrainGlobals.getTexturing().getActiveTexture(TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex); if (act == null) { CoreGlobals.ShowMessage("Error getting properties from active texture. index: = " + TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex.ToString()); TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex = 0; redrawPreviewList(0); return; } uScalebar.Value = act.mUScale; vScalebar.Value = act.mVScale; specExponentVal.Value = (Decimal)act.mSpecExponent; fresnelBiasVal.Value = (Decimal)act.mFresnelBias; fresnelPowerVal.Value = (Decimal)act.mFresnelPower; fresnelScaleVal.Value = (Decimal)act.mFresnelScale; fresnelRefractVal.Value = (Decimal)act.mFresnelRefractPercent; }
public void popertiesToActiveTextures() { BTerrainActiveTextureContainer act = TerrainGlobals.getTexturing().getActiveTexture(TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex); if (act == null) { CoreGlobals.ShowMessage("Error setting properties to active texture. index: = " + TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex.ToString()); TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex = 0; redrawPreviewList(0); return; } act.mUScale = uScalebar.Value; act.mVScale = vScalebar.Value; act.mSpecExponent = (float)specExponentVal.Value; act.mFresnelBias = (float)fresnelBiasVal.Value; act.mFresnelPower = (float)fresnelPowerVal.Value; act.mFresnelScale = (float)fresnelScaleVal.Value; act.mFresnelRefractPercent = (float)fresnelRefractVal.Value; // TerrainGlobals.getTexturing().writeTexturesToXML(); }
public void removeSelectedTexture() { if (mSelectedButton is TerrainTextureSplatButton) { if (TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex == 0) { return; } if (SimTerrainType.mActiveWorkingSet.Count - 1 <= 0) { return; } TerrainGlobals.getTexturing().removeActiveTexture(SimTerrainType.getActiveSetIndex(mSelectedDef)); SimTerrainType.removeActiveSetDef(mSelectedDef); flowLayoutPanel1.Controls.Remove(mSelectedButton); SelectedDef = SimTerrainType.getDefsOfActiveSet()[0]; } else { // if (TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex == 0) // return; int index = TerrainGlobals.getTexturing().getActiveDecalIndex(((TerrainTextureDecalButton)mSelectedButton).mFullFilename); TerrainGlobals.getTexturing().removeActiveDecal(index); flowLayoutPanel1.Controls.Remove(mSelectedButton); SelectedDef = SimTerrainType.getDefsOfActiveSet()[0]; } redrawPreviewList(0); mSelectedButton = (TerrainTextureButton)flowLayoutPanel1.Controls[firstSplatIndex()]; }
public void postTEDLoad(bool selectdIndexChanged) { try { if (selectdIndexChanged) { if (comboBox1.SelectedIndex != 0) { comboBox1.SelectedIndex = 0; redrawPreviewList(0); } if (TerrainGlobals.getEditor().getMode() == BTerrainEditor.eEditorMode.cModeTexEdit) { SelectButton((TerrainTextureButton)flowLayoutPanel1.Controls[firstSplatIndex() + TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex]); } else if (TerrainGlobals.getEditor().getMode() == BTerrainEditor.eEditorMode.cModeDecalEdit) { SelectButton((TerrainTextureButton)flowLayoutPanel1.Controls[firstDecalIndex() + TerrainGlobals.getTerrainFrontEnd().SelectedDecalIndex]); } } else { if (redrawList != null) { this.Invoke(redrawList); } } } catch (System.Exception ex) { if (mbPostTEDLoadRecovery) { CoreGlobals.getErrorManager().LogErrorToNetwork(ex.ToString()); try { if (TerrainGlobals.getEditor().getMode() == BTerrainEditor.eEditorMode.cModeTexEdit) { CoreGlobals.getErrorManager().LogErrorToNetwork(TerrainGlobals.getEditor().getMode().ToString() + " firstSplatIndex=" + firstSplatIndex().ToString() + " flowLayoutPanel1.Controls=" + flowLayoutPanel1.Controls.ToString() + " SelectedTextureIndex=" + TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex); } } catch (System.Exception ex2) { CoreGlobals.getErrorManager().OnException(ex2); } if (MessageBox.Show("Error building texture picker (error saved to network)", "Error", MessageBoxButtons.RetryCancel) == DialogResult.Retry) { postTEDLoad(selectdIndexChanged); } else { mbPostTEDLoadRecovery = false; } } } }