• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            戰(zhàn)魂小筑

            討論群:309800774 知乎關(guān)注:http://zhihu.com/people/sunicdavy 開(kāi)源項(xiàng)目:https://github.com/davyxu

               :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              257 隨筆 :: 0 文章 :: 506 評(píng)論 :: 0 Trackbacks

            #

            Patch

            patch只是顯示當(dāng)前版本發(fā)生了怎樣的變化,基于文本。例如:

            文本變化:

            del /s /q game\bin\*.lib
            del /s /q game\bin\*.dll
            +
            \ No newline at end of file

             

            二進(jìn)制變化:

            diff -r 2f3c677ed7ab -r c0efe12f9de3 game/bin/091208A002.jpg
            Binary file game/bin/091208A002.jpg has changed

            對(duì)于hg來(lái)說(shuō),據(jù)我所了解,無(wú)法像svn那樣apply一個(gè)patch。hg的patch可以在提交后從log中提取

            而svn的patch只能在未提交前提取,svn在這點(diǎn)上顯然有些麻煩。

             

            Bundle

            bundle包含了版本修改的所有信息,包括二進(jìn)制。其本身基于二進(jìn)制,無(wú)法閱讀,可以通過(guò)Repository Explorer的Add Bundle來(lái)將修改打入你的版本庫(kù)。但須注意Bundle之間必須連續(xù),如果當(dāng)中跳過(guò)任何一個(gè)Bundle,都是無(wú)法成功完整的打入你的版本庫(kù)的


                  鑒于使用HgSubversion無(wú)法從SVN服務(wù)器獲取版本,我找到了另外一個(gè)方法能解決公司使用SVN與自己攜帶方式編碼的平衡點(diǎn):同時(shí)使用SVN與HG進(jìn)行代碼管理。

                  在現(xiàn)有的SVN文件夾下,創(chuàng)建HG的代碼庫(kù),編輯.hgignore文件,一般對(duì)于VC項(xiàng)目,可以這樣參考這樣的寫(xiě)法

            *中文為注釋?zhuān)灰獙?xiě)入文件

            glob:.hgignore             忽略.hgignore本身
            glob:.svn                    忽略所有的svn管理文件
            glob:*.user                 本地用戶配置文件
            glob:*.suo                  solution本地配置文件
            glob:*.ncb                  Intelisence庫(kù)
            glob:*.exe                  exe可以由代碼生成
            glob:*.dll                    dll可以由代碼生成
            glob:game/Lib             直接忽略lib里所有文件
            glob:game/Obj            直接忽略obj里所有文件

            這里的glob就是通配符,也可以使用工具做正則表達(dá)式

            .hgignore可以由烏龜shell菜單中的Edit ignore filter來(lái)管理,而且還可以時(shí)時(shí)查看修改情況,可惜的是右邊的結(jié)果居然沒(méi)有排序功能……所以我的一般做法是直接在根目錄Commit,在列表中查看filter結(jié)果是否正確

             

            確認(rèn)無(wú)誤后,直接將代碼提交到hg代碼庫(kù),以后代碼做修改時(shí),SVN與HG會(huì)同時(shí)偵測(cè)到文件修改。一般可以自己認(rèn)為HG是大的版本,而SVN是小的版本即可。 當(dāng)需要帶走版本時(shí),只需要直接拷貝hg目錄,或者用clone指令即可。別人需要獲得一份干凈的穩(wěn)定版本,也可以新建一個(gè)HG版本庫(kù),從這個(gè)混合庫(kù)中pull過(guò)去

             

            這種做法在git+svn也是一樣的,:)

            posted @ 2010-01-29 11:55 戰(zhàn)魂小筑 閱讀(5464) | 評(píng)論 (4)編輯 收藏

                 當(dāng)我們的代碼寫(xiě)的差不多,需要提交給其他人怎么辦?這里可以將自己的電腦作為WebServer:

                 在要共享的hg版本庫(kù)目錄中命令行中鍵入

                 hg serve

                 或者在烏龜中選擇WebServer一項(xiàng),就可以將本機(jī)作為WebServer,在瀏覽器中敲入http://127.0.0.1:8000就可以訪問(wèn)自己的代碼庫(kù)

                 另外一個(gè)代碼庫(kù)可以通過(guò)pull指令,或者在烏龜?shù)腞epository Explorer中鍵入這個(gè)地址,然后使用pull菜單命令直接獲取更新,然后再u(mài)pdate,將庫(kù)中最新的更新變?yōu)榇a

                這里有詳細(xì)教程

             

                bundle,查看文檔和菜單時(shí),經(jīng)常看到這個(gè)詞。它是changeset的一個(gè)集合文件,可以使用Incoming來(lái)導(dǎo)入

               

                patch, 這種文件一般是文檔,可以查看修改,貌似可以和其他代碼管理工具通用

             

                Hg權(quán)限管理貌似只有Web Server 配置里的Alllw Push, Deny Push兩種方法,但是你的庫(kù)只要打開(kāi),對(duì)于別人來(lái)說(shuō)就等于完全訪問(wèn),這一塊也貌似沒(méi)有人研究過(guò),確實(shí)沒(méi)有權(quán)限管理?

            posted @ 2010-01-29 10:44 戰(zhàn)魂小筑 閱讀(2332) | 評(píng)論 (2)編輯 收藏

                今天試用了下Mercurial(簡(jiǎn)稱(chēng)Hg)分布式代碼管理系統(tǒng),查了下,居然烏龜這家公司做的WindowsShell,趕快下載

                Hg比Svn最大的優(yōu)勢(shì)就是在于

                1. 分布式代碼管理,無(wú)需服務(wù)器hosting(當(dāng)然也支持這種方式)

                2. 只在根目錄有1個(gè)hg目錄用于代碼管理,其他目錄都很干凈。這點(diǎn)是svn的最大詬病,尤其是這些目錄都保存有文件的修改base,所以對(duì)于一些很大的二進(jìn)制文件,一般目錄大小會(huì)是常規(guī)的2倍

                 安裝好后,直接選一個(gè)空目錄建立一個(gè)版本庫(kù),直接在版本庫(kù)里就可以添加文件并commit,這點(diǎn)跟svn就不一樣了,還得分清楚客戶端和服務(wù)器。

                 如果需要從原來(lái)的svn庫(kù)導(dǎo)入到Hg的庫(kù),只需要用convert指令就可以。但是實(shí)際操作中,發(fā)現(xiàn)好像這個(gè)過(guò)程并不需要密碼……

                 有一個(gè)叫hgsubversion的庫(kù),可以從svn中將代碼pull過(guò)來(lái),也可以push回去。但是在我的VisualSVN Server中pull時(shí),反復(fù)提示輸入帳號(hào)及密碼,實(shí)在不清楚是為什么。

                 總結(jié):公司做項(xiàng)目,用svn比較適合,畢竟Hg的分布式代碼管理不是那么多人都會(huì)用而且有這個(gè)習(xí)慣,svn能統(tǒng)一習(xí)慣,再者,公司都是局域網(wǎng),速度不成問(wèn)題。如果是和幾個(gè)朋友一起寫(xiě)代碼,交流只能靠網(wǎng)絡(luò),而且網(wǎng)速不是很理想時(shí),Hg就是很好的選擇

            posted @ 2010-01-28 17:06 戰(zhàn)魂小筑 閱讀(2120) | 評(píng)論 (3)編輯 收藏

            前段時(shí)間曾經(jīng)碰到過(guò)RT紋理繪制出來(lái)時(shí)需要透明的問(wèn)題。當(dāng)時(shí)也Google了一下,但是很少有人提起過(guò)這個(gè)問(wèn)題。昨天看劍孤寒的空間的Galaxy2D引擎中使用RT的透明繪制,文章在這里。發(fā)現(xiàn)這個(gè)特性居然需要顯卡支持,馬上查過(guò)DX9SDK文檔,發(fā)現(xiàn)這樣一篇文章,已經(jīng)告訴我們?cè)趺醋隽耍?/p>

            Render Target Alpha (Direct3D 9)

            The frame buffer blender can now blend alpha channels independent from color-channel blending on render targets. This control is enabled with a new render state, D3DRS_SEPARATEALPHABLENDENABLE.

            When D3DRS_SEPARATEALPHABLENDENABLE is set to FALSE (which is the default condition), the render-target blending factors and operations applied to alpha are the same as those defined for blending color channels. A driver needs to set the D3DPMISCCAPS_SEPARATEALPHABLEND cap to indicate that it can support render-target alpha blending. Be sure to enable D3DRS_ALPHABLEND to tell the pipeline that alpha blending is needed.

            To control the factors in the alpha channel of the render-target blenders, two new render states are defined as follows:

            D3DRS_SRCBLENDALPHA 
            D3DRS_DESTBLENDALPHA 
            

            Like the D3DRS_SRCBLEND and D3DRS_DESTBLEND, these can be set to one of the values in the D3DBLEND enumeration. The source and destination blend settings can be combined in several ways, depending on the settings in the SrcBlendCaps and DestBlendCaps members of D3DCAPS9.

            The alpha blending is done as follows:

            renderTargetAlpha = (alphain* srcBlendOp) BlendOp (alphart* destBlendOp) 
            

            Where:

            • alphain is the input alpha value.
            • srcBlendOp is one of the blend factors in D3DBLEND.
            • BlendOp is one of the blend factors in D3DBLENDOP.
            • alphart is the render-target alpha value.
            • destBlendOp is one of the blend factors in D3DBLEND.
            • renderTargetAlpha is the final blended alpha value.

             

            翻譯如下:

               使用 D3DRS_SEPARATEALPHABLENDENABLE渲染狀態(tài)可以讓Frame Buffer 混合器將RT中的Alpha通道與顏色通道分開(kāi)混合。

            當(dāng)D3DRS_SEPARATEALPHABLENDENABLE 設(shè)置為 FALSE(默認(rèn)),RT渲染參數(shù)和操作會(huì)跟顏色通道一樣被應(yīng)用到Alpha通道。 這項(xiàng)特性需要顯卡支持D3DPMISCCAPS_SEPARATEALPHABLEND 特性。記住,在之前設(shè)置D3DRS_ALPHABLEND以便打開(kāi)Alpha混合。

               RT混合器的Alpha通道混合因子渲染狀態(tài)如下:

            D3DRS_SRCBLENDALPHA

            D3DRS_DESTBLENDALPHA

            其被定義在D3DBLEND枚舉中,D3DRS_SRCBLEND 和D3DRS_DESTBLEND也是這樣定義的。來(lái)源色與目標(biāo)顏色將會(huì)有很多組合方式,主要依賴于D3DCAPS9中的SrcBlendCaps 和DestBlendCaps

            Alpha混合公式如下:

            renderTargetAlpha = (alphain* srcBlendOp) BlendOp (alphart* destBlendOp)

            其中:

                alphain為輸入alpha值

                srcBlendOp是D3DBLEND中的一個(gè)混合因子

                BlendOp是 D3DBLENDOP中的一個(gè)混合因子

                alphart是RT的alpha值

                destBlendOp是D3DBLEND中的一個(gè)混合因子

                renderTargetAlpha是最后混合后的alpha值

            posted @ 2010-01-20 16:56 戰(zhàn)魂小筑 閱讀(2857) | 評(píng)論 (1)編輯 收藏

            早上打開(kāi)GR閱讀新聞時(shí)還是中文版,剛才刷新了下,全變英文版了,有圖有真相

            image

            而昨天下午,Google.cn又解除了對(duì)中國(guó)的搜索屏蔽,不得不覺(jué)得Google太杯具了。

            最近在看李開(kāi)復(fù)自傳,還沒(méi)看到谷歌那章,但已經(jīng)在微軟那節(jié)感覺(jué)中國(guó)GOV實(shí)在不是什么好BIRD。

            那天問(wèn)女友為什么一直喜歡用Chrome和谷歌,她說(shuō),Google的logo好看,百度的太丑。我想,也許Google不僅僅是logo好看,即便在中國(guó)被過(guò)濾,但其不作惡的作風(fēng),還有給用戶提供最新的技術(shù)(Google Earth,Google 地圖搜索中的面部識(shí)別,Chrome)上,我永遠(yuǎn)支持Google

            posted @ 2010-01-15 11:16 戰(zhàn)魂小筑 閱讀(2944) | 評(píng)論 (11)編輯 收藏

            前幾天需要做一個(gè)鼠標(biāo)點(diǎn)擊判定,具體是判斷一個(gè)點(diǎn)是否在某個(gè)凸四邊形中。

            最簡(jiǎn)單的方法莫過(guò)于判斷鼠標(biāo)點(diǎn)是否在2個(gè)三角形中。但是很多判定方法都是有問(wèn)題的,比如說(shuō)

             

            copy自IndieLib

            bool Triangle2D::Inside2( const Vector2& p )
            {
                Vector2 v0 = mP3 - mP1;
                Vector2 v1 = mP2 - mP1;
                Vector2 v2 = p - mP1; 
            
                // Compute dot products
                float dot00 =  Vector2::DotProduct( v0, v0 );
                float dot01 =  Vector2::DotProduct( v0, v1 );
                float dot02 =  Vector2::DotProduct( v0, v2 );
                float dot11 =  Vector2::DotProduct( v1, v1 );
                float dot12 =  Vector2::DotProduct( v1, v2 ); 
            
                // Compute barycentric coordinates
                float invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
                float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
                float v = (dot00 * dot12 - dot01 * dot02) * invDenom; 
            
                // Check if point is in triangle
                return (u > 0) && (v > 0) && (u + v < 1);
            } 
            
              
            

            Google出的某人代碼

            float Triangle2D::CrossProduct3(const Vector2& p1,const Vector2& p2, const Vector2& p0 )
            {
                return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
            } 
            
            bool Triangle2D::Inside( const Vector2& p )
            {
                return (CrossProduct3(mP1,p,mP2)*CrossProduct3(mP3,p,mP2)<0) &&
                       (CrossProduct3(mP2,p,mP1)*CrossProduct3(mP3,p,mP1)<0) &&
                       (CrossProduct3(mP1,p,mP3)*CrossProduct3(mP2,p,mP3)<0);
            } 
            

             

            這2個(gè)方法都有缺陷,當(dāng)點(diǎn)在三角形邊上時(shí),就無(wú)法得出。當(dāng)用在一個(gè)正方形判斷時(shí),正方形中心點(diǎn)就判定為沒(méi)有在其內(nèi)部,顯然是一個(gè)錯(cuò)誤。

             

            之后,又Google出某幾個(gè)大俠的算法和思想,考慮了下,判定點(diǎn)與四邊形重心點(diǎn)的線段是否與四邊形4條邊相交,相交時(shí),其在四邊形外部,反之亦然。

            bool Quadrangle::Inside2( const Vector2& p )
            {
                Vector2 c = Segement2D::GetCrossPoint( mP1, mP3, mP2, mP4 ); 
            
                return !(Segement2D::Intersect( mP1, mP2, c, p) || 
                       Segement2D::Intersect( mP2, mP3, c, p) ||
                       Segement2D::Intersect( mP3, mP4, c, p) ||
                       Segement2D::Intersect( mP4, mP1, c, p) );
            } 
            
            bool Segement2D::Intersect( const Vector2& p1, const Vector2& p2,const Vector2& p3, const Vector2& p4 )
            {
                float gradab, gradcd, ycptab, ycptcd, interceptX, intercepty; 
            
                // In order to avoid divisions by zero
                //if (mP1.y == mP2.y)
                //    mP2.y += 0.0001f; 
            
                //if (mP1.x == mP2.x)
                //    mP2.x += 0.0001f; 
            
                //if (seg.mP1.y == seg.mP2.y)
                //    seg.mP2.y += 0.0001f; 
            
                //if (seg.mP1.x == seg.mP2.x)
                //    seg.mP2.x += 0.0001f; 
            
                // Calculates the intersection between the two lines
                gradab = (p1.y - p2.y) / (p1.x - p2.x);
                gradcd = (p3.y - p4.y) / (p3.x - p4.x); 
            
                ycptab = p1.y - p1.x * gradab;
                ycptcd = p3.y - p3.x * gradcd;
                interceptX = (ycptab - ycptcd) / (gradcd - gradab);
                intercepty = (ycptab - (gradab * ycptcd) / gradcd) / (1 - gradab / gradcd); 
            
                // Checking in the intersection is inside the segment
                if (!((interceptX >= p1.x && interceptX <= p2.x) || (interceptX >= p2.x && interceptX <= p1.x)))
                    return 0; 
            
                if (!((intercepty >= p1.y && intercepty <= p2.y) || (intercepty >= p2.y && intercepty <= p1.y)))
                    return 0; 
            
                if (!((interceptX >= p3.x && interceptX <= p4.x) || (interceptX >= p4.x && interceptX <= p3.x)))
                    return 0; 
            
                if (!((intercepty >= p3.y && intercepty <= p4.y) || (intercepty >= p4.y && intercepty <= p3.y)))
                    return 0; 
            
                return 1;
            } 
            
            Vector2 Segement2D::GetCrossPoint(const Vector2& p1, const Vector2& p2, const Vector2& q1, const Vector2& q2)
            {
                //必須相交求出的才是線段的交點(diǎn),但是下面的程序段是通用的 
            
                /*根據(jù)兩點(diǎn)式化為標(biāo)準(zhǔn)式,進(jìn)而求線性方程組*/
                Vector2 crossPoint;
                //求x坐標(biāo)
                float tempLeft = (q2.x - q1.x) * (p1.y - p2.y) - (p2.x - p1.x) * (q1.y - q2.y);
                float tempRight = (p1.y - q1.y) * (p2.x - p1.x) * (q2.x - q1.x) + q1.x * (q2.y - q1.y) * (p2.x - p1.x) - p1.x * (p2.y - p1.y) * (q2.x - q1.x);
                crossPoint.x = tempRight / tempLeft;
                //求y坐標(biāo)
                tempLeft = (p1.x - p2.x) * (q2.y - q1.y) - (p2.y - p1.y) * (q1.x - q2.x);
                tempRight = p2.y * (p1.x - p2.x) * (q2.y - q1.y) + (q2.x- p2.x) * (q2.y - q1.y) * (p1.y - p2.y) - q2.y * (q1.x - q2.x) * (p2.y - p1.y);
                crossPoint.y = tempRight / tempLeft; 
            
                return crossPoint;
            }
            

            這個(gè)算法效率并不是很高,但對(duì)于設(shè)計(jì)器來(lái)說(shuō)無(wú)所謂了,如果有好的準(zhǔn)確算法,可以討論

            posted @ 2010-01-08 10:29 戰(zhàn)魂小筑 閱讀(2751) | 評(píng)論 (6)編輯 收藏

            前幾天需要做一個(gè)鼠標(biāo)點(diǎn)擊判定,具體是判斷一個(gè)點(diǎn)是否在某個(gè)凸四邊形中。

            最簡(jiǎn)單的方法莫過(guò)于判斷鼠標(biāo)點(diǎn)是否在2個(gè)三角形中。但是很多判定方法都是有問(wèn)題的,比如說(shuō)

             

            copy自IndieLib

            bool Triangle2D::Inside2( const Vector2& p )
            {
                Vector2 v0 = mP3 - mP1;
                Vector2 v1 = mP2 - mP1;
                Vector2 v2 = p - mP1; 
            
                // Compute dot products
                float dot00 =  Vector2::DotProduct( v0, v0 );
                float dot01 =  Vector2::DotProduct( v0, v1 );
                float dot02 =  Vector2::DotProduct( v0, v2 );
                float dot11 =  Vector2::DotProduct( v1, v1 );
                float dot12 =  Vector2::DotProduct( v1, v2 ); 
            
                // Compute barycentric coordinates
                float invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
                float u = (dot11 * dot02 - dot01 * dot12) * invDenom;
                float v = (dot00 * dot12 - dot01 * dot02) * invDenom; 
            
                // Check if point is in triangle
                return (u > 0) && (v > 0) && (u + v < 1);
            } 
            
              
            

            Google出的某人代碼

            float Triangle2D::CrossProduct3(const Vector2& p1,const Vector2& p2, const Vector2& p0 )
            {
                return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
            } 
            
            bool Triangle2D::Inside( const Vector2& p )
            {
                return (CrossProduct3(mP1,p,mP2)*CrossProduct3(mP3,p,mP2)<0) &&
                       (CrossProduct3(mP2,p,mP1)*CrossProduct3(mP3,p,mP1)<0) &&
                       (CrossProduct3(mP1,p,mP3)*CrossProduct3(mP2,p,mP3)<0);
            } 
            

             

            這2個(gè)方法都有缺陷,當(dāng)點(diǎn)在三角形邊上時(shí),就無(wú)法得出。當(dāng)用在一個(gè)正方形判斷時(shí),正方形中心點(diǎn)就判定為沒(méi)有在其內(nèi)部,顯然是一個(gè)錯(cuò)誤。

             

            之后,又Google出某幾個(gè)大俠的算法和思想,考慮了下,判定點(diǎn)與四邊形重心點(diǎn)的線段是否與四邊形4條邊相交,相交時(shí),其在四邊形外部,反之亦然。

            bool Quadrangle::Inside2( const Vector2& p )
            {
                Vector2 c = Segement2D::GetCrossPoint( mP1, mP3, mP2, mP4 ); 
            
                return !(Segement2D::Intersect( mP1, mP2, c, p) || 
                       Segement2D::Intersect( mP2, mP3, c, p) ||
                       Segement2D::Intersect( mP3, mP4, c, p) ||
                       Segement2D::Intersect( mP4, mP1, c, p) );
            } 
            
            bool Segement2D::Intersect( const Vector2& p1, const Vector2& p2,const Vector2& p3, const Vector2& p4 )
            {
                float gradab, gradcd, ycptab, ycptcd, interceptX, intercepty; 
            
                // In order to avoid divisions by zero
                //if (mP1.y == mP2.y)
                //    mP2.y += 0.0001f; 
            
                //if (mP1.x == mP2.x)
                //    mP2.x += 0.0001f; 
            
                //if (seg.mP1.y == seg.mP2.y)
                //    seg.mP2.y += 0.0001f; 
            
                //if (seg.mP1.x == seg.mP2.x)
                //    seg.mP2.x += 0.0001f; 
            
                // Calculates the intersection between the two lines
                gradab = (p1.y - p2.y) / (p1.x - p2.x);
                gradcd = (p3.y - p4.y) / (p3.x - p4.x); 
            
                ycptab = p1.y - p1.x * gradab;
                ycptcd = p3.y - p3.x * gradcd;
                interceptX = (ycptab - ycptcd) / (gradcd - gradab);
                intercepty = (ycptab - (gradab * ycptcd) / gradcd) / (1 - gradab / gradcd); 
            
                // Checking in the intersection is inside the segment
                if (!((interceptX >= p1.x && interceptX <= p2.x) || (interceptX >= p2.x && interceptX <= p1.x)))
                    return 0; 
            
                if (!((intercepty >= p1.y && intercepty <= p2.y) || (intercepty >= p2.y && intercepty <= p1.y)))
                    return 0; 
            
                if (!((interceptX >= p3.x && interceptX <= p4.x) || (interceptX >= p4.x && interceptX <= p3.x)))
                    return 0; 
            
                if (!((intercepty >= p3.y && intercepty <= p4.y) || (intercepty >= p4.y && intercepty <= p3.y)))
                    return 0; 
            
                return 1;
            } 
            
            Vector2 Segement2D::GetCrossPoint(const Vector2& p1, const Vector2& p2, const Vector2& q1, const Vector2& q2)
            {
                //必須相交求出的才是線段的交點(diǎn),但是下面的程序段是通用的 
            
                /*根據(jù)兩點(diǎn)式化為標(biāo)準(zhǔn)式,進(jìn)而求線性方程組*/
                Vector2 crossPoint;
                //求x坐標(biāo)
                float tempLeft = (q2.x - q1.x) * (p1.y - p2.y) - (p2.x - p1.x) * (q1.y - q2.y);
                float tempRight = (p1.y - q1.y) * (p2.x - p1.x) * (q2.x - q1.x) + q1.x * (q2.y - q1.y) * (p2.x - p1.x) - p1.x * (p2.y - p1.y) * (q2.x - q1.x);
                crossPoint.x = tempRight / tempLeft;
                //求y坐標(biāo)
                tempLeft = (p1.x - p2.x) * (q2.y - q1.y) - (p2.y - p1.y) * (q1.x - q2.x);
                tempRight = p2.y * (p1.x - p2.x) * (q2.y - q1.y) + (q2.x- p2.x) * (q2.y - q1.y) * (p1.y - p2.y) - q2.y * (q1.x - q2.x) * (p2.y - p1.y);
                crossPoint.y = tempRight / tempLeft; 
            
                return crossPoint;
            }
            

            這個(gè)算法效率并不是很高,但對(duì)于設(shè)計(jì)器來(lái)說(shuō)無(wú)所謂了,如果有好的準(zhǔn)確算法,可以討論

            posted @ 2010-01-08 10:27 戰(zhàn)魂小筑 閱讀(662) | 評(píng)論 (0)編輯 收藏

                 準(zhǔn)備為自己的2D游戲動(dòng)畫(huà)系統(tǒng)選擇一套給外部使用的接口方式,有如下幾種選擇:

             

            1. 純C API方式導(dǎo)出,類(lèi)似于Windows API方式

            優(yōu)點(diǎn):簡(jiǎn)潔,可以供C/C#乃至其他可以導(dǎo)入C DLL的語(yǔ)言使用

            缺點(diǎn):C++的系統(tǒng)轉(zhuǎn)化為C會(huì)遇到很多性能以及架構(gòu)的折損,對(duì)于對(duì)象控制類(lèi)功能導(dǎo)出比較多的系統(tǒng),這種方式簡(jiǎn)直是噩夢(mèng)

             

            2. C++方式導(dǎo)出,宏方式實(shí)現(xiàn)RTTI以及C++反射系統(tǒng)

            優(yōu)點(diǎn):強(qiáng)大,易用。

            缺點(diǎn):對(duì)象生命周期不容易控制,反射系統(tǒng)設(shè)計(jì)比較費(fèi)時(shí),可能暴露很多類(lèi)的細(xì)節(jié),只能給C++使用

             

            3. COM方式,類(lèi)DirectX的接口方式

            優(yōu)點(diǎn):商業(yè)項(xiàng)目已經(jīng)證明這種接口方式的強(qiáng)大地方。無(wú)論是多個(gè)對(duì)象的類(lèi)功能導(dǎo)出,還是COM接口重載都非常方便。而且,可以極為容易的讓.NET訪問(wèn)。XBOX SDK里的XUI就是采用這種方式,而且還設(shè)計(jì)了一套C API搭配的強(qiáng)大C++反射系統(tǒng),支持動(dòng)態(tài)類(lèi)創(chuàng)建,RTTI,動(dòng)態(tài)類(lèi)型轉(zhuǎn)換等等。

            缺點(diǎn):需要系統(tǒng)注冊(cè),不能跨平臺(tái)。COM標(biāo)準(zhǔn)學(xué)習(xí)起來(lái)需要時(shí)間

             

            4. 腳本綁定

            優(yōu)點(diǎn):保持你的系統(tǒng)對(duì)外C/C++接口的干凈,簡(jiǎn)潔。通過(guò)腳本類(lèi)綁定,可以很快的將C++功能注冊(cè)到腳本中。

            缺點(diǎn):腳本如果沒(méi)有調(diào)試器,將會(huì)讓開(kāi)發(fā)中碰到的棘手問(wèn)題,甚至于在后期維護(hù)系統(tǒng)以及系統(tǒng)架構(gòu)大變動(dòng)變得異常復(fù)雜。腳本的性能決定了不能讓其做實(shí)時(shí)處理,例如:渲染

             

            最終選擇下來(lái),由于有自己的界面系統(tǒng)Motion使用lua的函數(shù)綁定的前例,因此還是決定選擇一款腳本語(yǔ)言來(lái)做系統(tǒng)的對(duì)外接口,這里有幾個(gè)選擇:

            1. Lua

              可以說(shuō)最好的游戲系統(tǒng)腳本語(yǔ)言。穩(wěn)定,高效,bug幾乎沒(méi)有(即便有,普通開(kāi)發(fā)者也是很難察覺(jué)的)。配上LuaPlus的強(qiáng)大C++綁定系統(tǒng),你的系統(tǒng)開(kāi)發(fā)效率可以提高很多。這里推薦notepad++來(lái)做lua開(kāi)發(fā),稍微配置下,彈出提示給你感覺(jué)在使用Visual Studio,:)

               同時(shí)需要指出的是,lua的類(lèi)功能確實(shí)比較弱。雖然可以用metatable方式來(lái)模擬。但逼近跟native class支持還差很遠(yuǎn),實(shí)際開(kāi)發(fā)中,你能體會(huì)出class中的權(quán)限控制(private,protected)有多么重要。

            2. Python

               誠(chéng)然,這是個(gè)最OO的腳本。但是對(duì)于游戲,它太慢了。雖然本人只是用python寫(xiě)過(guò)一些build系統(tǒng),但從很多朋友反應(yīng)的情況來(lái)看,Python嵌入游戲系統(tǒng),確實(shí)太慢。用Stackless Python? 用第三方開(kāi)源產(chǎn)品,還是認(rèn)準(zhǔn)品牌,呵呵,這里如果有用過(guò)的同學(xué),歡迎提供感受。

            3. C#

               語(yǔ)言和系統(tǒng)都很美,但是想嵌入游戲,還是很痛的。.net平臺(tái)可惜就在于,到現(xiàn)在為止,可能還不是所有機(jī)器默認(rèn)安裝有.net平臺(tái)。如果你的游戲是C++寫(xiě)成,但卻要安裝.net以便你的腳本能運(yùn)行,這很奇怪吧?所以,如果要用C#,還不如不用腳本,全盤(pán).net就好了。Managed DX? 那東西幾年前就被MS打入冷宮了。XNA? 那東西只是一個(gè)玩具,別摸。

            4.Squirrel松鼠腳本

               這是個(gè)好東西。類(lèi)lua的語(yǔ)法,C/C++/Java的語(yǔ)言結(jié)構(gòu),純正的native class外加OO支持。擁有開(kāi)源的C++類(lèi)綁定系統(tǒng)。最爽的是,SQDEV支持日食(Eclipse)下的遠(yuǎn)程調(diào)試,開(kāi)發(fā)環(huán)境還支持動(dòng)態(tài)語(yǔ)法檢查。oh,my god。還說(shuō)不定哪天這腳本被MS招安,跟IronPython一樣弄個(gè).net綁定。

             

            posted @ 2009-12-31 11:42 戰(zhàn)魂小筑 閱讀(2212) | 評(píng)論 (2)編輯 收藏

            中文社區(qū):http://silverlight.cn/

            微軟官方中文MSDN:http://msdn.microsoft.com/zh-cn/library/cc838158(VS.95).aspx

            微軟官方英文MSDN例子:http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/index.htm#/?sref=HomePage

            posted @ 2009-12-30 16:45 戰(zhàn)魂小筑 閱讀(1421) | 評(píng)論 (0)編輯 收藏

            僅列出標(biāo)題
            共26頁(yè): First 16 17 18 19 20 21 22 23 24 Last 
            久久久青草青青国产亚洲免观| 狠狠狠色丁香婷婷综合久久五月 | 久久九色综合九色99伊人| 国产成人综合久久久久久| 久久无码国产| 国产偷久久久精品专区| 97久久天天综合色天天综合色hd| 日本三级久久网| 精品国产乱码久久久久软件| 婷婷久久久亚洲欧洲日产国码AV | 精品熟女少妇aⅴ免费久久| 亚洲性久久久影院| 久久99国产综合精品女同| 国内精品久久久久久久影视麻豆| 久久久国产视频| 国产91色综合久久免费| 久久综合九色欧美综合狠狠| 久久精品国产AV一区二区三区 | 国产真实乱对白精彩久久| 久久99热这里只有精品国产| 久久香蕉一级毛片| 久久天天躁狠狠躁夜夜不卡| 精品一区二区久久| 99久久香蕉国产线看观香| 国产精品久久久久久影院| 中文精品99久久国产| 99re久久精品国产首页2020| 久久亚洲国产最新网站| 久久国产精品久久国产精品| 亚洲伊人久久成综合人影院| 久久精品午夜一区二区福利| 亚洲国产成人精品无码久久久久久综合 | 99国内精品久久久久久久| 男女久久久国产一区二区三区| 久久久久综合中文字幕| 国产三级久久久精品麻豆三级| 亚洲欧美日韩精品久久亚洲区| 国产99久久精品一区二区| 亚洲精品乱码久久久久久| 蜜桃麻豆www久久国产精品| 久久久青草青青亚洲国产免观|