private void _UpdateAtlasTextureRotate(bool bRotateCcw_) { if (IsValidAtlasTextureIndex(0) == true) { KTextureInfo textrInfo = new KTextureInfo(); bool bIsGetTextrInfo = m_textureAtlasInfo.GetTextureInfo(ref textrInfo, m_iSelectedMaterialIndex); if (bIsGetTextrInfo == true) { if (bRotateCcw_ == true) { // rotate by Ccw. jintaeks on 2013-11-18, 17:08 if (textrInfo.m_bIsRotateCcw == false) { textrInfo.RotateImage(90); // rotate by Ccw textrInfo.SwapWidthHeight(); textrInfo.m_bIsRotateCcw = bRotateCcw_; } //if } else // when ( bRotateCcw_ == false ) { // restore rotated image. rotate by Cw. jintaeks on 2013-11-18, 17:08 if (textrInfo.m_bIsRotateCcw == true) { textrInfo.RotateImage(-90); // rotate by Ccw textrInfo.SwapWidthHeight(); textrInfo.m_bIsRotateCcw = bRotateCcw_; } //if } //if.. else.. m_textureAtlasInfo.SetTextureInfo(m_iSelectedMaterialIndex, textrInfo); m_textureAtlasInfo.AutoAdjustAtlasSize(); _InvalidateTextureCanvas(); } //if } //if } //_UpdateAtlasTextureRotate()
}//_UpdateMaterialTextureInfo() private bool _UpdateAtlasTexturesFromMaterialList() { if (m_textureAtlasInfo == null || m_textureAtlasInfo.m_alistTextureInfo == null || m_alistMaterials == null) { return(false); }//if if (m_textureAtlasInfo.m_alistTextureInfo.Count == m_alistMaterials.Count) { int iTextrCount = m_alistMaterials.Count; for (int iTextr = 0; iTextr < iTextrCount; iTextr += 1) { KStdMaterialInfo stdMtrlInfo = ( KStdMaterialInfo )m_alistMaterials[iTextr]; KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[iTextr]; textrInfo.m_image = stdMtrlInfo.m_image; if (textrInfo.m_image != null && textrInfo.m_bIsRotateCcw == true) { textrInfo.RotateImage(90); //textrInfo.SwapWidthHeight(); }//if m_textureAtlasInfo.m_alistTextureInfo[iTextr] = textrInfo; } //for } //if return(true); }//_UpdateAtlasTexturesFromMaterialList()
}//listBoxMaterials_SelectedIndexChanged() private bool _UpdateMaterialTextureInfo() { m_iSelectedMaterialIndex = listBoxMaterials.SelectedIndex; if (m_iSelectedMaterialIndex == -1) { return(false); // return false when selected material index is invalid. jintaeks on 2013-11-04, 20:49 }//if if (m_textureAtlasInfo == null) { return(false); // invalid texture atlas info. jintaeks on 2013-11-06, 14:18 }//if KTextureInfo textrInfo = new KTextureInfo(); bool bIsGetTextrInfo = m_textureAtlasInfo.GetTextureInfo(ref textrInfo, m_iSelectedMaterialIndex); if (bIsGetTextrInfo == false) { return(false); // can't get texture info. }//if textBoxTextureFilename.Text = textrInfo.m_strTextureFileName; numericUpDownTextureWidth.Value = textrInfo.m_iWidth; numericUpDownTextureHeight.Value = textrInfo.m_iHeight; checkTextureRotate.Checked = textrInfo.m_bIsRotateCcw; // jintaeks on 2013-11-18, 17:32 string strAlternativePath = Path.GetDirectoryName(m_strOdmFileName); _UpdateMaterialPictureBox(m_iSelectedMaterialIndex); _InvalidateTextureCanvas(); return(true); }//_UpdateMaterialTextureInfo()
}//KTextureAtlasInfo() /// <summary> /// automatically adjust texture positions when atlas size is fixed. /// jintaeks on 2013-11-06, 17:18 /// </summary> /// <returns></returns> public bool AutoAdjustTexturePosition() { if (m_iAtlasWidth <= 0 || m_iAtlasHeight <= 0) { return(false); }//if int iNumTextures = m_alistTextureInfo.Count; int iNumRowTextures = ( int )Math.Log(iNumTextures, 2); if (iNumRowTextures <= 0) { return(false); }//if int iWidthStep = m_iAtlasWidth / iNumRowTextures; int iHeightStep = m_iAtlasHeight / iNumRowTextures; int iTextrCounter = 0; int iTextrLeft = 0; int iTextrLeftNext = 0; int iTextrTop = 0; int iTextrHeightMaxSoFar = 0; for (int iTextr = 0; iTextr < iNumTextures; ++iTextr) { KTextureInfo textrInfo = ( KTextureInfo )m_alistTextureInfo[iTextr]; iTextrLeftNext = iTextrLeft + Math.Min(iWidthStep, textrInfo.m_iWidth); iTextrCounter += 1; if (iTextrLeftNext > m_iAtlasWidth) { iTextrLeft = 0; iTextrLeftNext = Math.Min(iWidthStep, textrInfo.m_iWidth); iTextrTop += iTextrHeightMaxSoFar; iTextrHeightMaxSoFar = 0; }//if textrInfo.m_iLeft = iTextrLeft; textrInfo.m_iTop = iTextrTop; iTextrLeft = iTextrLeftNext; iTextrHeightMaxSoFar = Math.Max(iTextrHeightMaxSoFar, textrInfo.m_iHeight); // update modified texture info. m_alistTextureInfo[iTextr] = textrInfo; }//for return(true); }//AutoAdjustTexturePosition()
}//GetTextureInfo() public bool SetTextureInfo(int iTextrIndex_, KTextureInfo textrInfo_) { if (m_alistTextureInfo == null) { return(false); }//if if (iTextrIndex_ >= 0 && iTextrIndex_ < m_alistTextureInfo.Count) { m_alistTextureInfo[iTextrIndex_] = textrInfo_; return(true); }//if return(false); }//SetTextureInfo()
}//AutoAdjustAtlasSize() /// <summary> /// get texture info at specified texture index. /// jintaeks on 2013-11-06, 17:19 /// </summary> /// <param name="textrInfo_"></param> /// <param name="iTextrIndex_"></param> /// <returns></returns> public bool GetTextureInfo(ref KTextureInfo textrInfo_, int iTextrIndex_) { if (m_alistTextureInfo == null) { return(false); }//if if (iTextrIndex_ >= 0 && iTextrIndex_ < m_alistTextureInfo.Count) { // set [out] parameter. textrInfo_ = ( KTextureInfo )m_alistTextureInfo[iTextrIndex_]; return(true); }//if return(false); }//GetTextureInfo()
void _ResizeAllTexturesInAtlas(double dResizeRatio_) { int iTextrCount = m_alistMaterials.Count; for (int iTextr = 0; iTextr < iTextrCount; iTextr += 1) { KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[iTextr]; textrInfo.m_iLeft = ( int )(textrInfo.m_iLeft * dResizeRatio_); textrInfo.m_iTop = ( int )(textrInfo.m_iTop * dResizeRatio_); textrInfo.m_iWidth = ( int )(textrInfo.m_iWidth * dResizeRatio_); textrInfo.m_iHeight = ( int )(textrInfo.m_iHeight * dResizeRatio_); m_textureAtlasInfo.m_alistTextureInfo[iTextr] = textrInfo; } //foreach } //_ResizeAllTexturesInAtlas()
} //_UpdateAtlasTextureWidth() private void _UpdateAtlasTextureHeight() { if (IsValidAtlasTextureIndex(0) == true) { KTextureInfo textrInfo = new KTextureInfo(); bool bIsGetTextrInfo = m_textureAtlasInfo.GetTextureInfo(ref textrInfo, m_iSelectedMaterialIndex); if (bIsGetTextrInfo == true) { int iHeight = Convert.ToInt32(numericUpDownTextureHeight.Value); iHeight = Math.Min(2048, Math.Max(32, iHeight)); numericUpDownTextureHeight.Value = iHeight; textrInfo.m_iHeight = iHeight; m_textureAtlasInfo.SetTextureInfo(m_iSelectedMaterialIndex, textrInfo); m_textureAtlasInfo.AutoAdjustAtlasSize(); _InvalidateTextureCanvas(); } //if } //if } //_UpdateAtlasTextureHeight()
}//_PickTextureOnCanvas() private void panelTextureCanvas_MouseDown(object sender, MouseEventArgs e) { radioButtonDiffuseTexture.Focus(); // move texture in atlas if (e.Button == MouseButtons.Left) { int iPickedTextr = -1; bool bIsPickTexture = _PickTextureOnCanvas(ref iPickedTextr , ( int )((e.X - m_pntAtlasLeftTop.X) / m_fAtlasZoomRatio) , ( int )((e.Y - m_pntAtlasLeftTop.Y) / m_fAtlasZoomRatio)); if (bIsPickTexture == true) { KTextureInfo textrInfo = new KTextureInfo(); bool bIsGetTextureInfo = m_textureAtlasInfo.GetTextureInfo(ref textrInfo, iPickedTextr); Debug.Assert(bIsGetTextureInfo == true); if (bIsGetTextureInfo == true) { m_pntPickMouseOffset.X = ( int )(e.X - textrInfo.m_iLeft * m_fAtlasZoomRatio) - 1; m_pntPickMouseOffset.Y = ( int )(e.Y - textrInfo.m_iTop * m_fAtlasZoomRatio) - 1; m_iSelectedAtlasTextureIndex = iPickedTextr; m_eIsTextureLocatingMode = ETextureLocatingMode.TEXTURE; }//if // sync to material index if (m_iSelectedAtlasTextureIndex != m_iSelectedMaterialIndex) { m_iSelectedMaterialIndex = m_iSelectedAtlasTextureIndex; listBoxMaterials.SetSelected(m_iSelectedMaterialIndex, true); _UpdateMaterialTextureInfo(); } //if } //if } // move atlas itself. else if (e.Button == MouseButtons.Right) { m_pntPickMouseOffset.X = ( int )(e.X - m_pntAtlasLeftTop.X); m_pntPickMouseOffset.Y = ( int )(e.Y - m_pntAtlasLeftTop.Y); m_eIsTextureLocatingMode = ETextureLocatingMode.ATLAS; } //if.. else if.. } //panelTextureCanvas_MouseDown()
}//SetTextureInfo() public bool FindTextureInfo(ref int iTextrInfo_, string strMtrlName_) { if (m_alistTextureInfo == null) { return(false); // invalid texture info list. }//if int iNumTextures = m_alistTextureInfo.Count; for (int iTextr = 0; iTextr < iNumTextures; ++iTextr) { KTextureInfo textrInfo = ( KTextureInfo )m_alistTextureInfo[iTextr]; if (textrInfo.m_strMtrlName == strMtrlName_) { iTextrInfo_ = iTextr; return(true); } //if } //for return(false); } //FindTextureInfo()
}//IsValidAtlasTextureIndex() private bool _PickTextureOnCanvas(ref int iOutTextureIndex_, int x_, int y_) { if (IsValidAtlasTextureIndex(0) == false) { return(false); }//if int iTextrCount = m_textureAtlasInfo.m_alistTextureInfo.Count; for (int iTextr = 0; iTextr < iTextrCount; iTextr += 1) { KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[iTextr]; bool bIsPointIn = textrInfo.IsPointIn(x_, y_); if (bIsPointIn == true) { iOutTextureIndex_ = iTextr; return(true); } //if } //for return(false); }//_PickTextureOnCanvas()
private void panelTextureCanvas_MouseMove(object sender, MouseEventArgs e) { double fMouseX = e.X; // + cfSnapSize / 2.0; double fMouseY = e.Y; // +cfSnapSize / 2.0; bool bIsValidMtrlIndex = IsValidAtlasTextureIndex(m_iSelectedAtlasTextureIndex); if (bIsValidMtrlIndex == true && m_eIsTextureLocatingMode == ETextureLocatingMode.TEXTURE) { KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[m_iSelectedAtlasTextureIndex]; textrInfo.m_iLeft = ( int )((fMouseX - m_pntPickMouseOffset.X) / m_fAtlasZoomRatio); textrInfo.m_iTop = ( int )((fMouseY - m_pntPickMouseOffset.Y) / m_fAtlasZoomRatio); m_textureAtlasInfo.m_alistTextureInfo[m_iSelectedAtlasTextureIndex] = textrInfo; _InvalidateTextureCanvas(); } else if (m_eIsTextureLocatingMode == ETextureLocatingMode.ATLAS) { int iSnapXIndex = ( int )((fMouseX - m_pntPickMouseOffset.X)); int iSnapYIndex = ( int )((fMouseY - m_pntPickMouseOffset.Y)); m_pntAtlasLeftTop.X = iSnapXIndex; m_pntAtlasLeftTop.Y = iSnapYIndex; _InvalidateTextureCanvas(); }//if.. else if.. }
} //panelTextureCanvas_MouseDown() private void panelTextureCanvas_MouseUp(object sender, MouseEventArgs e) { double fMouseX = e.X; // + cfSnapSize / 2.0; double fMouseY = e.Y; // +cfSnapSize / 2.0; bool bIsValidMtrlIndex = IsValidAtlasTextureIndex(m_iSelectedAtlasTextureIndex); if (bIsValidMtrlIndex == true && m_eIsTextureLocatingMode == ETextureLocatingMode.TEXTURE) { double cfSnapSize = 32; // apply 32*32 virtual snap to grid. jintaeks on 2013-11-06, 10:40 KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[m_iSelectedAtlasTextureIndex]; int iSnapXIndex = ( int )((fMouseX - m_pntPickMouseOffset.X) / m_fAtlasZoomRatio / cfSnapSize); int iSnapYIndex = ( int )((fMouseY - m_pntPickMouseOffset.Y) / m_fAtlasZoomRatio / cfSnapSize); textrInfo.m_iLeft = ( int )(iSnapXIndex * cfSnapSize); textrInfo.m_iTop = ( int )(iSnapYIndex * cfSnapSize); m_textureAtlasInfo.SetTextureInfo(m_iSelectedAtlasTextureIndex, textrInfo); m_textureAtlasInfo.AutoAdjustAtlasSize(); _InvalidateTextureCanvas(); m_eIsTextureLocatingMode = ETextureLocatingMode.NONE; m_iSelectedAtlasTextureIndex = -1; } else if (m_eIsTextureLocatingMode == ETextureLocatingMode.ATLAS) { double cfSnapSize = 32; int iSnapXIndex = ( int )((fMouseX - m_pntPickMouseOffset.X) / cfSnapSize); int iSnapYIndex = ( int )((fMouseY - m_pntPickMouseOffset.Y) / cfSnapSize); m_pntAtlasLeftTop.X = ( int )(iSnapXIndex * cfSnapSize); m_pntAtlasLeftTop.Y = ( int )(iSnapYIndex * cfSnapSize); _InvalidateTextureCanvas(); m_eIsTextureLocatingMode = ETextureLocatingMode.NONE; }//if.. else if.. }
}//CreateTextureAtlasInfo() /// <summary> /// load .odm.a file /// jintaeks on 2013-11-12, 17:19 /// </summary> /// <param name="textureAtlasInfo_"></param> /// <param name="strOdmaFilePath_"></param> /// <returns></returns> public static bool LoadExistingAtlasInfo(ref KTextureAtlasInfo textureAtlasInfo_, string strOdmaFilePath_) { if (textureAtlasInfo_ == null) { return(false); // invalid atlas info. }//if if (System.IO.File.Exists(strOdmaFilePath_) == false) { MessageBox.Show("파일이 존재하지 않습니다. \nPath : " + strOdmaFilePath_); return(false); }//if int iParseMode = 0; string strLine = ""; // you must set 'Encoding.Default' to read Korean Hangul text from file. jintaeks on 2013-11-04, 14:48 StreamReader file = new StreamReader(strOdmaFilePath_, Encoding.Default); while ((strLine = file.ReadLine()) != null) { strLine.Trim(); if (strLine.Length <= 0) { continue; }//if if (iParseMode == 0) { int iStrLength = strLine.Length; int iEqualSignIndex = strLine.IndexOf("="); string strName = strLine.Substring(0, iEqualSignIndex); strName = strName.Trim(); strName = strName.ToLower(); int iRemainedTextLenght = iStrLength - iEqualSignIndex - 1; string strData = strLine.Substring(iEqualSignIndex + 1, iRemainedTextLenght); if (strName == "width") { textureAtlasInfo_.m_iAtlasWidth = Convert.ToInt32(strData); } else if (strName == "height") { textureAtlasInfo_.m_iAtlasHeight = Convert.ToInt32(strData); } else if (strName == "material") { string[] astrMtrlInfo = strData.Split(new char[] { ',' }); if (astrMtrlInfo.Length == 6) { for (int iDataIndex = 0; iDataIndex < 6; iDataIndex += 1) { astrMtrlInfo[iDataIndex] = astrMtrlInfo[iDataIndex].Trim(); }//for int iTextrInfoIndex = 0; bool bIsFindTextrInfo = textureAtlasInfo_.FindTextureInfo(ref iTextrInfoIndex, astrMtrlInfo[0]); Debug.Assert(bIsFindTextrInfo == true); if (bIsFindTextrInfo == true) { KTextureInfo textrInfo = new KTextureInfo(); bool bIsGetTextureInfo = textureAtlasInfo_.GetTextureInfo(ref textrInfo, iTextrInfoIndex); if (bIsGetTextureInfo == true) { textrInfo.m_iLeft = Convert.ToInt32(astrMtrlInfo[1]); textrInfo.m_iTop = Convert.ToInt32(astrMtrlInfo[2]); textrInfo.m_iWidth = Convert.ToInt32(astrMtrlInfo[3]); textrInfo.m_iHeight = Convert.ToInt32(astrMtrlInfo[4]); astrMtrlInfo[5] = astrMtrlInfo[5].ToLower(); textrInfo.m_bIsRotateCcw = String.Compare(astrMtrlInfo[5], "true") == 0; if (textrInfo.m_bIsRotateCcw == true) { textrInfo.RotateImage(90); }//if textureAtlasInfo_.SetTextureInfo(iTextrInfoIndex, textrInfo); } //if } //if } } //if.. else if.. } //if } //while file.Close(); return(true); }//LoadExistingAtlasInfo()
private bool _ApplyAtlasInfo() { // step 1. write atlas info to file. // string strObjectName = Path.GetFileNameWithoutExtension(m_strOdmFileName); // construct "odm.a" filename. string strAtlasFileName = m_strOdmFileName; strAtlasFileName += ".a"; StreamWriter sw = new StreamWriter(strAtlasFileName, false, Encoding.Default); string strData; string strOutput = ""; strData = String.Format("Version = {0}\r\n", m_strOdmaFileVersion); strOutput += strData; strData = String.Format("Object = {0}\r\n", strObjectName); strOutput += strData; strData = String.Format("Width = {0}\r\n", m_textureAtlasInfo.m_iAtlasWidth); strOutput += strData; strData = String.Format("Height = {0}\r\n", m_textureAtlasInfo.m_iAtlasHeight); strOutput += strData; int iTextrCount = m_alistMaterials.Count; Debug.Assert(m_alistMaterials.Count == m_textureAtlasInfo.m_alistTextureInfo.Count); if (m_alistMaterials.Count != m_textureAtlasInfo.m_alistTextureInfo.Count) { Clipboard.SetText("DsuAtlasTextureLocator : material error"); MessageBox.Show("DsuAtlasTextureLocator : material error"); return(false); }//if for (int iTextr = 0; iTextr < iTextrCount; iTextr += 1) { KStdMaterialInfo stdMtrlInfo = ( KStdMaterialInfo )m_alistMaterials[iTextr]; KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[iTextr]; strData = String.Format("Material = {0}, {1}, {2}, {3}, {4}, {5}\r\n" , textrInfo.m_strMtrlName , textrInfo.m_iLeft , textrInfo.m_iTop , textrInfo.m_iWidth , textrInfo.m_iHeight , textrInfo.m_bIsRotateCcw == true ? "true" : "false"); strOutput += strData; if (stdMtrlInfo.m_strDiffuseTextureName.Length >= 1) { strData = String.Format("Diffuse = {0}\r\n", stdMtrlInfo.m_strDiffuseTextureName); strOutput += strData; }//if if (stdMtrlInfo.m_strBumpTextureName.Length >= 1) { strData = String.Format("Bump = {0}\r\n", stdMtrlInfo.m_strBumpTextureName); strOutput += strData; }//if if (stdMtrlInfo.m_strSpecularTextureName.Length >= 1) { strData = String.Format("SpecularLevel = {0}\r\n", stdMtrlInfo.m_strSpecularTextureName); strOutput += strData; }//if if (stdMtrlInfo.m_strGlossinessTextureName.Length >= 1) { strData = String.Format("Glossiness = {0}\r\n", stdMtrlInfo.m_strGlossinessTextureName); strOutput += strData; } //if } //foreach sw.Write(strOutput); sw.Close(); // step 2. copy atlas data to clipboard. // Clipboard.SetText(strOutput); return(true); }//_ApplyAtlasInfo()
}//toolStripButtonOpen_Click() private void panelTextureCanvas_Paint(object sender, PaintEventArgs e) { // draw current atlas textures. jintaeks on 2013-11-05, 20:36 if (IsValidAtlasTextureIndex(0) == true) { int iAtlasLeft = m_pntAtlasLeftTop.X; int iAtlasTop = m_pntAtlasLeftTop.Y; //Graphics g = Graphics.FromImage( m_bitmapTextureCanvas ); Graphics g = e.Graphics; int iWidth = Convert.ToInt32(m_textureAtlasInfo.m_iAtlasWidth * m_fAtlasZoomRatio); int iHeight = Convert.ToInt32(m_textureAtlasInfo.m_iAtlasHeight * m_fAtlasZoomRatio); g.FillRectangle(Brushes.LightGray, iAtlasLeft, iAtlasTop, iWidth, iHeight); g.DrawRectangle(Pens.White, iAtlasLeft, iAtlasTop, iWidth, iHeight); foreach (KTextureInfo textrInfo in m_textureAtlasInfo.m_alistTextureInfo) { int iLeft = Convert.ToInt32(textrInfo.m_iLeft * m_fAtlasZoomRatio) + iAtlasLeft; int iTop = Convert.ToInt32(textrInfo.m_iTop * m_fAtlasZoomRatio) + iAtlasTop; iWidth = Convert.ToInt32(textrInfo.m_iWidth * m_fAtlasZoomRatio); iHeight = Convert.ToInt32(textrInfo.m_iHeight * m_fAtlasZoomRatio); if (textrInfo.m_image != null) { g.DrawImage(textrInfo.m_image, iLeft, iTop, iWidth, iHeight); } }//foreach int iTextrCount = m_textureAtlasInfo.m_alistTextureInfo.Count; for (int iTextr = 0; iTextr < iTextrCount; iTextr += 1) { KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[iTextr]; int iLeft = Convert.ToInt32(textrInfo.m_iLeft * m_fAtlasZoomRatio) + iAtlasLeft; int iTop = Convert.ToInt32(textrInfo.m_iTop * m_fAtlasZoomRatio) + iAtlasTop; iWidth = Convert.ToInt32(textrInfo.m_iWidth * m_fAtlasZoomRatio); iHeight = Convert.ToInt32(textrInfo.m_iHeight * m_fAtlasZoomRatio); g.DrawRectangle(Pens.Magenta, iLeft, iTop, iWidth, iHeight); }//for //if( IsValidAtlasTextureIndex( m_iSelectedAtlasTextureIndex ) == true ) //{ // KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[m_iSelectedAtlasTextureIndex]; // int iLeft = Convert.ToInt32( textrInfo.m_iLeft * m_fAtlasZoomRatio ); // int iTop = Convert.ToInt32( textrInfo.m_iTop * m_fAtlasZoomRatio ); // iWidth = Convert.ToInt32( textrInfo.m_iWidth * m_fAtlasZoomRatio ); // iHeight = Convert.ToInt32( textrInfo.m_iHeight * m_fAtlasZoomRatio ); // Pen pen = new Pen( Brushes.Magenta, 2 ); // g.DrawRectangle( pen, iLeft, iTop, iWidth, iHeight ); //}//if if (IsValidAtlasTextureIndex(m_iSelectedMaterialIndex) == true) { KTextureInfo textrInfo = ( KTextureInfo )m_textureAtlasInfo.m_alistTextureInfo[m_iSelectedMaterialIndex]; int iLeft = Convert.ToInt32(textrInfo.m_iLeft * m_fAtlasZoomRatio) + iAtlasLeft; int iTop = Convert.ToInt32(textrInfo.m_iTop * m_fAtlasZoomRatio) + iAtlasTop; iWidth = Convert.ToInt32(textrInfo.m_iWidth * m_fAtlasZoomRatio); iHeight = Convert.ToInt32(textrInfo.m_iHeight * m_fAtlasZoomRatio); Pen pen = new Pen(Brushes.Yellow, 2); g.DrawRectangle(pen, iLeft, iTop, iWidth, iHeight); } //if } //if } //panelTextureCanvas_Paint()