public CTexObj(string pName, Device pdevice, string pTexFile, float[,] pheightData, int pWIDTH, int pHEIGHT, float pSCALE_FACTOR, int pShiftX, int pShiftY, int pImageWidth, int pImageHeight) { this.visible = true; this.Name = pName; this.m_device = pdevice; this.m_TextureFile = pTexFile; this.ObjSymbol = CSymbol3.GetSymbol(this.m_TextureFile); this.ImageWidth = pImageWidth; this.ImageHeight = pImageHeight; this.heightData = pheightData; this.WIDTH = pWIDTH + 1; this.HEIGHT = pHEIGHT + 1; this.SCALE_FACTOR = pSCALE_FACTOR; this.ShiftX = pShiftX; this.ShiftY = pShiftY; this.PixelsPerGridX = (int)Math.Ceiling((double)this.ImageWidth / (double)pWIDTH); this.PixelsPerGridY = (int)Math.Ceiling((double)this.ImageHeight / (double)pHEIGHT); this.terrainWIDTH = this.heightData.GetUpperBound(0); this.terrainHEIGHT = this.heightData.GetUpperBound(1); this.texs = new List <Texture>(); this.VertexDeclaration(); this.IndicesDeclaration(); this.LoadTexturesAndMaterials(this.m_TextureFile); this.meshTex = this.CreateMesh(); this.Position = new Vector3((float)(this.WIDTH - 1) / 2f + (float)this.ShiftX, (float)(this.HEIGHT - 1) / 2f + (float)this.ShiftY, 0f); }
private void ExportTexObjs(string pFileName, List <CActDef> pActions) { int num = 0; Dictionary <string, string> dictionary = new Dictionary <string, string>(); Bitmap bitmap = new Bitmap(modSaBan.myTextureFile); Graphics graphics = Graphics.FromImage(bitmap); graphics.SmoothingMode = SmoothingMode.AntiAlias; checked { using (StreamWriter streamWriter = new StreamWriter(pFileName)) { streamWriter.WriteLine("<TexObjs>"); try { IEnumerator enumerator = this.m_Symbol3Objs.GetEnumerator(); while (enumerator.MoveNext()) { CSymbol3 cSymbol = (CSymbol3)enumerator.Current; if (this.IsActiveSymbol(cSymbol.Name, pActions)) { num++; string mImageFile = modSaBan.mySaBanDir + "\\TexObj" + num.ToString("000") + ".xml"; streamWriter.WriteLine(this.GetTexObjStr(cSymbol, mImageFile)); } else { this.Draw3(graphics, cSymbol); } } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } streamWriter.WriteLine("</TexObjs>"); streamWriter.Close(); } bitmap.Save(modSaBan.mySaBanDir + "\\DienTapMap.jpg"); bitmap.Dispose(); } }
private void Draw3(Graphics g, CSymbol3 pSymbol) { Graphics graphics = this.m_Map.CreateGraphics(); GraphicsContainer container = g.BeginContainer(); g.TranslateTransform((float)pSymbol.GocX, (float)pSymbol.GocY); g.RotateTransform(pSymbol.Heading); try { IEnumerator enumerator = pSymbol.GObjs.GetEnumerator(); while (enumerator.MoveNext()) { GraphicObject graphicObject = (GraphicObject)enumerator.Current; try { if (graphicObject.GetObjType() == OBJECTTYPE.Text) { SizeF sizeF = g.MeasureString(((TextGraphic)graphicObject).Text, ((TextGraphic)graphicObject).Font); float num = graphics.MeasureString(((TextGraphic)graphicObject).Text, ((TextGraphic)graphicObject).Font).Width / sizeF.Width; Font font = new Font(((TextGraphic)graphicObject).Font.Name, ((TextGraphic)graphicObject).Font.Size * num, ((TextGraphic)graphicObject).Font.Style, ((TextGraphic)graphicObject).Font.Unit); ((TextGraphic)graphicObject).Font = font; } } catch (Exception expr_104) { ProjectData.SetProjectError(expr_104); ProjectData.ClearProjectError(); } } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } pSymbol.GObjs.DrawObjects(g, (float)pSymbol.Zoom); g.EndContainer(container); }
private void DrawSymbol3(Image pbmpImage) { Graphics g = Graphics.FromImage(pbmpImage); try { IEnumerator enumerator = this.m_Symbol3Objs.GetEnumerator(); while (enumerator.MoveNext()) { CSymbol3 pSymbol = (CSymbol3)enumerator.Current; this.Draw3(g, pSymbol); } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } }
private string GetTexObjStr(CSymbol3 aSymbol, string mImageFile) { string str = "<TexObj"; RectangleF bounds = aSymbol.GetBounds(); string name; int value; int value2; int value3; int value4; Rectangle rectangle; checked { int num = (int)Math.Round(unchecked (Math.Floor((double)bounds.X / this.myPixelsPerGridX) - 1.0)); int num2 = (int)Math.Round(unchecked (Math.Floor((double)bounds.Y / this.myPixelsPerGridY) - 1.0)); int num3 = (int)Math.Round(unchecked (Math.Ceiling((double)(bounds.X + bounds.Width) / this.myPixelsPerGridX) + 1.0)); int num4 = (int)Math.Round(unchecked (Math.Ceiling((double)(bounds.Y + bounds.Height) / this.myPixelsPerGridY) + 1.0)); name = aSymbol.Name; value = num3 - num; value2 = num4 - num2; value3 = num; value4 = modSaBan.myGRID_HEIGHT - 1 - num4; rectangle = new Rectangle((int)Math.Round(unchecked ((double)num * this.myPixelsPerGridX)), (int)Math.Round(unchecked ((double)num2 * this.myPixelsPerGridY)), (int)Math.Round(unchecked ((double)(checked (num3 - num)) * this.myPixelsPerGridX)), (int)Math.Round(unchecked ((double)(checked (num4 - num2)) * this.myPixelsPerGridY))); } aSymbol.GocX -= (double)rectangle.X; aSymbol.GocY -= (double)rectangle.Y; aSymbol.KH2File(mImageFile); str = str + " Name=\"" + name + "\""; str = str + " ImageFile=\"" + mImageFile + "\""; str = str + " Width=\"" + Conversions.ToString(value) + "\""; str = str + " Height=\"" + Conversions.ToString(value2) + "\""; str = str + " ShiftX=\"" + Conversions.ToString(value3) + "\""; str = str + " ShiftY=\"" + Conversions.ToString(value4) + "\""; str = str + " ImageWidth=\"" + Conversions.ToString(rectangle.Width) + "\""; str = str + " ImageHeight=\"" + Conversions.ToString(rectangle.Height) + "\""; return(str + " />"); }
private void LoadSymbols() { base.ClearModels(); base.ClearBillboards(); this.m_Symbol3Objs.Clear(); double num; double num2; checked { num = Convert.ToDouble(decimal.Multiply(new decimal(this.m_TexImage.Width), new decimal(1000L))) / (double)(modSaBan.myGRID_WIDTH - 1) / 1000.0; num2 = Convert.ToDouble(decimal.Multiply(new decimal(this.m_TexImage.Height), new decimal(1000L))) / (double)(modSaBan.myGRID_HEIGHT - 1) / 1000.0; Graphics graphics = Graphics.FromImage(this.m_TexImage); } try { IEnumerator enumerator = myModule.fMain.myBando.drawingSymbols.GetEnumerator(); while (enumerator.MoveNext()) { CSymbol cSymbol = (CSymbol)enumerator.Current; PointF surfPosition = modSaBan.GetSurfPosition(cSymbol.GocX, cSymbol.GocY); float valueX = (float)((double)surfPosition.X / num); float valueY = (float)((double)(checked (modSaBan.myGRID_HEIGHT - 1)) - (double)surfPosition.Y / num2); float dHeading = -CTerrain.DegreeToRadian(cSymbol.Heading); Vector3 pPos = new Vector3(valueX, valueY, -7f); int num3 = base.GetModelMeshIndex(cSymbol.Description); if (num3 > -1) { base.Load1Model(cSymbol.Description, num3, pPos, dHeading); } else { num3 = base.GetBillboardMeshIndex(cSymbol.Description); if (num3 > -1) { base.Load1Billboard(cSymbol.Description, num3, pPos, dHeading); } else { double zoom = cSymbol.Zoom / (double)cSymbol.MWidth * (modSaBan.my3DSoPixelsPer1000m / 1000.0); CGraphicObjs cGraphicObjs = new CGraphicObjs(); try { IEnumerator enumerator2 = cSymbol.GObjs.GetEnumerator(); while (enumerator2.MoveNext()) { GraphicObject graphicObject = (GraphicObject)enumerator2.Current; GraphicObject aGObj = graphicObject.Clone(); cGraphicObjs.Add(aGObj); } } finally { IEnumerator enumerator2; if (enumerator2 is IDisposable) { (enumerator2 as IDisposable).Dispose(); } } CSymbol3 cSymbol2 = new CSymbol3(cSymbol.Description, surfPosition, cGraphicObjs); cSymbol2.Zoom = zoom; cSymbol2.Heading = cSymbol.Heading; this.m_Symbol3Objs.Add(cSymbol2); } } } } finally { IEnumerator enumerator; if (enumerator is IDisposable) { (enumerator as IDisposable).Dispose(); } } }