Ejemplo n.º 1
0
        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()
Ejemplo n.º 2
0
        }//_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()
Ejemplo n.º 3
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()