Пример #1
0
        }//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()
Пример #2
0
        }//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()