2012年11月8日 星期四

關於 Collider 與 Ragidbody (碰撞體與剛體) 的碰撞偵測與怎麼做

(最近開始試用 Unity3D, 寫一下心得筆記, 但先說明不代表我的觀點是完全正確的, 畢竟我才用沒兩小時...)


關於 Collider 與 Ragidbody 的碰撞偵測與怎麼做

p.s. 一開始我有些不明白這兩個的差異, 我知道 Collider 是用在碰撞偵測, Ragidbody 是用在物理計算的需求, 但為什麼單純兩個有 Collider 的物體相撞沒有任何事件 (OnTriggerEnter)發生?

研究了一下, 此簡要設定碰撞事件的步驟:

1. 每個能被撞倒的物體(範例是隕石與子彈)都要有一個 Collider 元件 (檢查一下 Collider 元件有被啟動, 並調整好適合的大小/位置)

2. 每個移動(要去撞人家)物體, 除自己也要有 Collider 外, 還需附加 Ragidbody 元件(*)
   a) 先點選要附加元件的 GameObject
   b) Menu->Component->Physics->Ragibody
   c) 暫時不考慮重力加速度, 核銷 Ragibody 參數的 'Use Gravity' checkbox
  
NOTE: (*)
擁有 Ragidbody 的物體才會即時對場景中的每一個 Colliders 做偵測(要去撞人家), 沒有 Ragidbody 的物體, 儘管也許他能藉由程式碼操作被移動, 但 Unity3D 不考慮對其他的 Colliders 做偵測 (為了加速吧).

例如: 場景中有 A B C  三個物件, A 為 Ragidbody, B/C 非 Ragidbody,  則 Unity3D 偵測  A<->B, A<->C 有沒有碰撞, 不偵測 B<->C

所以下面說法是正確的:
                 
場景中 "只有" 兩個移動物體(各有 Collider), 只要一個有設 Ragidbody 就足夠發生碰撞了!


3. 隕石(有加入 Ragidbody 元件)的 Collider 參數中, 核選 'Is Trigger' checkbox(**)
  
   在 GameObject 物件中加入

public class meteor : MonoBehaviour {
   ...
   void OnTriggerEnter(Collider other)
   {
//      if (other.tag == "bullet")          // 物件參數裡有指定 Tag
        if (other.name == "Bullet(Clone)")  // 用類別的名字
        {
            print("hit by bullet");    
        }
   }
}


   處理被碰撞時做什麼事, 注意: OnTriggerEnter 兩個相撞物件各自都會呼叫

public class bullet : MonoBehaviour {
   ...
   void OnTriggerEnter(Collider other)
   {
        print("OnTriggerEnter: " + other.name + " tag=" + other.tag);
        ...
   }
}


NOTE: (**)
這表示此碰撞體為一個觸發器, 產生碰撞事件, OnTriggerEnter/Exit/Stay(Collider other) 會被呼叫, 時此 Ragidbody 物件不會加入物理引擎做運算(彈跳 etc).(***)

4. 移動中隕石與子彈如果發生碰撞各自 OnTriggerEnter 就被呼叫了.
    (實際只要選擇其中一個處理即可 )


NOTE: (***)
如果 'Is Trigger' 不用, 則會 Ragidbody 有物理作用, 此時碰撞改用 OnCollisionEnter/Exit/Stay(Collision collision)
注意此處傳遞的是 Collision 不是 Collider!
 
以上這樣子就明瞭了, Collider 的 'Is Trigger' 主要的用途了, 他一般是使用在類
似進入/離開/停留一個區域要'觸發'事件, 在那種不需要有物理推擠的時機.

P.S. 一個 GameObject 可以附加好幾個 Collider, 所以可以按需求不同的作用一起發
生.
 

2012年8月30日 星期四

用 Eclipse 每次編譯 (build) 時自動執行 bash & ndk-build 命令

這裡是之前的的紀錄 Eclipse+Android SDK/NDK 開發環境的過程 (2/2) 步驟 58~62 的附圖詳細說明, 今天 (離上次搞 andriod 有一段時間) 要弄一個別人的案子, 他沒有設置自動編譯 JNI, 對於要改 C 的我頗不方便, 我是少用 Eclipse 的人, 只想到可自動編譯阿, 但又忘了這些步驟, 而且是徹底沒印象怎麼做 :_ 還要回來找老文章 (還好我有留練習紀錄), 那...這次就將過程截圖下來吧, 並加上註解 ;-)

前提:

1. 你已經安裝好 cygwin + NDK 等環境了
2. 你已經做好手動建立 JNI 的 makefile 了 (或是拿別人的專案要改自動化NDK)

如非上述, 請忽略本文吧. 還是從我之前的 Eclipse+Android SDK/NDK 開發環境的過程 1 & 2 開始練起.

---------------------------------------------------------------------

58. (2) (用 Eclipse 每次編譯 (build) 時自動建立 libhello.so)

59. menu -> 'Project' -> 'Properties', 開啟 Properties for xx 對話盒

註: 如果在 Project Explorer 裡有多個專案, 請確認哪一個需要做自動執行 ndk-build, 先選好其中的一個 project, 也可以在其名字上按滑鼠右鍵彈出選單後, 選 'Properties'. 如果多個專案都需要自動執行 ndk-build, 那 "各自" 都要做下面的步驟!

   

60. 點選 Builders 項目, 按下 'New...', 開啟 Choose configuration type
    對話盒


61. 點選 Program 項目, 按下 'OK', 開啟 Edit launch configuration
    properties 對話盒

    Name: 隨你高興        (建議取有意義的字, 我都用 'NDK Builder')

    Main 標籤頁下 (如下圖):

        Location: C:\cygwin\bin\bash.exe
        Working Directory: (留白)
        Arguments: --login -c "/cygdrive/c/android-ndk/ndk-build -C `cygpath -u '${build_project}' `"

    NOTE: 1. 以上 cygwin 及 android-ndk 路徑, 請依真實情況修改
          2. 另外一種 Arguments 寫法:

--login -c "cd '${project_loc}' && /cygdrive/c/android-ndk/ndk-build"


註: 這裡非常重要, 就是實際手動執行 bash, ndk-build 的方式在此輸入好.




    Refresh 標籤頁下 (如下圖):

        Refresh resources upon completion    打勾

註:告知當 ndk-build 執行完畢後, 要接著刷新專案的哪些資源, 一般我們只選因為 ndk-build 執行後所影響(變更)的文件 (如 libs...), 這樣專案其他不相關的文件不會重新又編譯一次.

        選取下方的
        The Entire workspace
        或
        Specific resources 項目
        按 'Specify Resources...' 按鈕, 將專案中的 libs 目錄(*)  打勾

 註: (*) 第一次建立時, 若沒有編譯 jni 過, 可能沒有 libs 目錄, 建議編譯過 jni 後改選這個.

        Recursive include sub-folders        打勾




    Environment 標籤頁下 (如下圖):

        (留白)



     Build Options 標籤頁下 (如上圖):

        Allocate Console       打勾
        File                   不勾

        Launch in background   打勾

        After a "Clean"        打勾 (或不勾看你習慣)
        During manual builds   打勾
        During auto builds     打勾 (或不勾看你習慣)
        During a "Clean"       不勾 (或勾看你習慣)

        Specify working set of relevant resources  打勾

 註: Eclipse help 裡說鑑於效能考量, 不建議 During auto builds 打勾, 我是覺得還好啦. 看你習不習慣 Eclipse 自動(暗自)啟動 ndk-build 囉.



    按 'Specify Resources...' 按鈕, 將專案中的 jni 目錄打勾

註: 這樣子只有 jni 資源目錄下的文件有變更時才會啟動自動編譯, 或是依你需求可以加選擇其他的資源目錄. (例如把 C/C++ source files 放在另外一個目錄, 如果不選 Specify working set of relevant resources 則專案內任一資源變動都會啟動自動編譯)



    設置好後, 按 'Finish' 回到上一層對話盒, 再按 'OK'



62. 此時, 你的 makefile 會依 Run the builder 的指定時機自動編譯, 或手動在選單->Project->Clean + Build Project

    注意 NDK Builder 編譯的時候, Eclipse 的 Console 視窗會同手動一樣顯示 ndk-build 結果,下圖, Console 顯示 bash 執行 NDK Builder...


註: 我經驗上, 以上是設置好了, 但 console 視窗卻沒有出現上圖執行過程...原因

1. 確認步驟 61 的 bash ndk-build 路徑有沒有正確...
2. Eclipse 認定不需要執行 NDK Builder (也許因為你已經手動執行過一次了, 之後沒有再修改 C sources 或 makefile), 試著強制從選單-> clean project 看看...
P.S. 我都是修改一下 jni 的 makefile 內容, 多加一個空白按儲存, 就 (或按 F5 Refresh) 判定需要重新編譯了~
3. C sources 的檔案應該要放到 Project Explorer 裡得 jni folder (或 working set of relevant resources 之處) 才能有相依關連.


後記:
以上的設置 Eclipse 會放在 .externalToolBuilders 下 (NAME).launch, 我的是 NDK_Builder.launch, 這個文件可以直接編輯, 我把此文件隨著專案檔案控管, 當專案其他的成員 check out 時也能直接使用(或修改一下路徑)而不是重複以上的 NDK 環境設置.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration
..略...
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="--login -c &quot;/cygdrive/c/android-ndk/ndk-build -C `cygpath -u '${build_project}' `&quot;"/>
..略...
</launchConfiguration>


2012年8月21日 星期二

Visual Studio (as C/C++) 20xx 問題與解決 1

在我使用 VC6 至今(*) VS2010 已經數十年頭, 有些問題常常遇到但很多不知所以然....

(*) sorry, 其實 m$ 在 vs200x 的時候我都還堅守 VC6 啦, 最近才開始混用 VC6 and VS2010


問題1:編譯時遇到下面訊息

xx.lib(oo.obj) : warning LNK4204: 'C:\..\Debug\vc100.pdb' is missing debugging information for referencing module; linking object as if no debug info

原因:
Reason:

1)
這警告是因為要去建立除錯版本時, 使用到外部的某一個程式庫卻沒有該庫對應的 xx.pdb (program database) 檔案, 這檔案包含了一些除錯需要的型別及符號的資訊.

像是你編譯除錯版 (Debug) 的應用程式, 但你引用程式庫全都是發行 (Release) 版, 這樣你無法取得這些庫的偵錯資訊.

It was warning about debugging with particular external lib but without its xx.pdb ( program database) file which contains the type and symbolic debugging information.

It would appear that you're compiling your application in a Debug configuration, but the libraries you referenced are all Release builds, meaning there is no debug information for them.

2)
另外一個可能性是... 該程式庫跟另外一個程式庫用的 .pdb 名字相同 (大多發生在採用預設的 vcx0.pdb), 但在拷貝中檔案被覆蓋過去了.

or in the same name (default as vcx0.pdb) with another .pdb file and been overwrote while copying into.

3)
這也發生在一個 'rebuild solution' 之後, 如果有兩個以上 .vcproj 檔案, 他共享相同的暫時輸出 (intermediate-output) 目錄, 而發生存取相同名字的 'Program Database File Name' (vcx0.pdb) 衝突.

It is also seen after a 'rebuild solution', if two .vcproj files share the same intermediate-output directory and there is a conflict in accessing the same 'Program Database File Name' (vcx0.pdb).


解決 1 和 2:
Solution for 1 and 2:

1)
就忽略這些警告吧 (大家都這樣吧...)

just ignored these warnings (you should already now...)

2)
建立一個程式庫, 把偵錯訊息嵌入進去 (也就是不用 .pdb)

在 Visual Studio 2005/2008/2010 你可以在設定裡這樣做:

Project Properties -> C++ -> General -> Debug Information Format 改成 “/Z7″

一般這選項是預設為 “/ZI” 這樣把偵錯訊息產生在另外的檔案.

make the library to embed the debug information (aka without .pdb)

In Visual Studio 2005/2008/2010 one can do that by setting:

Project Properties -> C++ -> General -> Debug Information Format to “/Z7″

usually this option was set to “/ZI” which generates debug info to external file.

3)
否則找到該 'pdb' (含偵錯訊息) 檔案, 必須放置在跟程式庫相同的目錄下.

otherwise find the 'PDB' file (with debug info) must be placed in the same folder as the libaray.

more info: http://msdn.microsoft.com/en-us/library/958x11bc%28v=VS.100%29.aspx

4)
在 Visual Studio 2005 之前...

避免這個警告,試著按下面步驟建立自己的除錯模式的程式庫:

a) 把 "Debug Information Format" 從 /ZI 改成 Disabled <-- 注意:只有在 vs2005 更早的版本才有
b) 把 "Enable Minimal Rebuild" 從 /Gm 改成 Disabled
c) 改 "Basic Runtime Checks" 為 Default

這基本跟預設的發行磨是設定差不多,少了最佳化. 使用這些設定,你可以移除全部的 OBJ, PDB, 和 IDB 檔案並且使用這些程式庫不會有連結的警告.

before Visual Studio 2005...

To prevent these warnings, try the following to debug mode for my lib:

a) Switched the "Debug Information Format" from /ZI to Disabled <-- note: only available before vs2005
b) Switched the "Enable Minimal Rebuild" from /Gm to Disabled
c) Changed "Basic Runtime Checks" to Default

This is basically the same setup as the default release mode settings, minus the optimization. Using these settings, you can remove all of the OBJ, PDB, and IDB files from compilation and just use the LIB file with no linker warnings.


解決 3:
Solution for 3:

1)
為每一個 .vcproj 修改 Intermediate Output 目錄名字
(在 'Configuration Properties > General > Intermediate Directory' 之下)

change the Intermediate Output dir for one .vcproj
(under 'Configuration Properties > General > Intermediate Directory')

2)
修改 'Program Database File Name' 為另外一個非 VC70.pdb 的名字
(在 'Configuration Properties > C/C++ > Output Files > Program Database File Name' 之下)

change the name of the 'Program Database File Name' to something different than vc70.pdb.
(under 'Configuration Properties > C/C++ > Output Files > Program Database File Name')

2012年7月1日 星期日

如何在 Vistual Studio C++ 6 用其他的顯示字體

Visual Stdio C++ 6 算是有點老但是又常常在戰場上不退的編譯器. 因為相較他的繼承者, 她更小, 穩, 對於只寫 C/C++ MFC/Win32 的程式師, 她沒有過多的無用的功能, 是非常好用的. 我到現在還是繼續使用 (推薦加 Visual Assist X 的外掛).

跟大多數的編輯器一樣, 在程式碼編輯器上, 她永許你自訂使用不同的字體. 但不知道為什麼她的字體的設置, 不是把全部的系統安裝的字體全都列出來可供挑選. 我不知道她的選法, 就少少十幾種左右.


這些字體換了反而顯示效果更差, 把網路有很多漂亮的程式設計用的字體(稍後我會分享介紹) 安裝到系統, 但這裡的列表還是不會列出, 那要怎麼突破這個限制呢!

多年前我發現了一個方法, 這個方法我不曾在網路哪裡看過, 也許有人也知道, 秘而不宣, 或在網海中也很難搜尋到...今天就把他分享出來, 算是 "程式設計的藝術" 專題的 "前篇" 吧!

方法是利用修改 VC6 存在系統的 Register 表的設定值

詳細步驟如下:

首先我們要他在 Register 登錄表裡面產生一個自訂字體的項目

1. 在 VC6 選單 -> 'Tools' -> 'Option'

2. 選 'Format' 頁

3. 改變 'Category:' 到你想要自訂字體的項目 (如: Source Windows 或其他)

4. 改變 'Font:' 選擇列表裡面任何一個非預設的字體 (如: 細明體)

5. 以上 3,4 如果有不同視窗, 請各自都挑一個字體, 完成後, 按 'OK' 離開, 離開 VC6

接著我們要開始修改 Register 登錄表.

6. 在命令列(或 '開始' ->'執行')裡, 執行登錄編輯程式 regedit

7. 找到下面項目

    HKEY_CURRENT_USER\Software\Microsoft\Devstudio\6.0\Format

   打開, 在其下你會看到出現, 你剛剛修改(step 3)的 Source Windows 或其他視窗
 
8. 點上面的機碼, 修改下面的鍵值

   FontFace
   FontSize


   為你想到的字體與大小



  p.s. 字體的名字需要是已經安裝在系統字體的 "顯示名字", 很簡單你在其他的可以選擇字體的應用程式列出的名字

9. 重開 VS6 ^^

有圖有真相, 改用 Dina 字體 :-)


附未修改前的採預設字體的樣子



P.S. 我後來就把鍵值直接輸出為一個文件, 下次就直接點選改入~ 如果你懶惰的話....

 -------------------------------------
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Format]

[HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Format\Output Window]
"FontFace"="Dina"
"FontSize"=dword:0000000c

[HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Format\Source Browser]
"FontFace"="Dina"
"FontSize"=dword:0000000a

[HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Format\Source Window]
"FontFace"="Dina"
"FontSize"=dword:0000000c

[HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Format\Workspace Window]
"FontFace"="Dina"
"FontSize"=dword:0000000a
 -------------------------------------

2012年6月25日 星期一

Eclipse+Android SDK/NDK 開發環境的過程 (2/2)

接...Eclipse+Android SDK/NDK 開發環境的過程 (1/2)

接著要整合 NDK 產生的 lib (as xx.so) 能在 Eclipse 專案裡使用...

---------------------------------------------------------------------

46. 測試 NDK 與 Eclipse 整合 (僅開發 C/C++ libraries 需要)

47. 執行 Eclipse.exe

48. 開啟 step 25~31 的專案為基礎, 如果沒有請重做

49. 在 Package Explorer 下新增一個目錄 'jni'

50. 在 'jni' 目錄下新增一個 'File' 命名為 Andriod.mk, 編輯內容如下

    LOCAL_PATH := $(call my-dir)

    include $(CLEAR_VARS)

    # Here we give our module name and source file(s)
    LOCAL_MODULE    := hello
    LOCAL_SRC_FILES := hello.c

    include $(BUILD_SHARED_LIBRARY)

    P.S. 如果 C 文件不只一個可以在 LOCAL_SRC_FILES 裡面列出

2012年6月20日 星期三

4. Install the phpMyadmin 3.x

Install the phpMyadmin 3.x

=====================================================================

(v3.5.1 tested)

STEP1: Apache, PHP and MySQL must be installed first...

STEP2: download and unzip the phpMyAdmin-3.x-all-languages.zip to

       your  Apache web doc folder like [Apache-folder]\htdocs

STEP3: copy config.sample.inc.php and rename it to config.inc.php

STEP4: edit config.inc.php to use http authentication

       $cfg['Servers'][$i]['auth_type'] = 'http';

STEP5: open url http://127.0.0.1/[phpMyAdmin-folder]/index.php

       enter user name 'root' and password set in MySQL

3. Install the MySQL 5.5.X w/ Apache+PHP

Install the MySQL 5.5.X w/ Apache+PHP
=====================================================================

(v5.5.25 tested)

STEP1:  Apache and PHP must be installed first...

STEP2:  download MySQL Community Server and execute the

        mysql-5.5.x-win32.msi

STEP3:  must be 'I accept the terms...'

STEP4:  recommend to use Custom setup so it can change to install to

        C:\MySQL

        just for easy accessing

STEP5:  use default features as options and install

2. Install PHP 5.2.x/5.3.x with MySQL extentions

Which version do I choose?
=====================================================================

If you are using PHP with Apache 1 or Apache2 from apache.org you

need to use the VC6 versions of PHP

VC6 Versions are compiled with the legacy Visual Studio 6 compiler

If you are using PHP with IIS you should use the VC10 versions of PHP

VC10 Versions are compiled with the Visual Studio 2010 compiler and

have improvements in performance and stability. The VC10 versions

require you to have the Microsoft 2010 C++ runtime installed

*** Do NOT use VC10 version with offical apache.org binaries ***


Install PHP 5.2.x/5.3.x with MySQL extensions
=====================================================================

(v5.3.14-VC9 tested)

STEP1:  Apache must be installed first!

STEP2:  download and execute php-5.2.x-win32-installer.msi with

        default setting

        NOTE: if you had installed the Apache from ASF build,

              use php-5.2.x-Win32-VC6-x86.msi

              if you had installed the Apache from Apache Lounge build,

              use php-5.3.x-Win32-VC10-x86.msi

1. Install the Apache 2.2.X

Install the Apache 2.2.X
=====================================================================

A) from Official ASF build from http://httpd.apache.org/
---------------------------------------------------------------------

(v2.2.22 tested)

STEP1:  download and execute apache_2.2.x-win32-x86-no_ssl.msi most

        with default setting

STEP1:  must be 'I accept the terms...', click 'Next'

STEP2:  in Server Information,

        enter your 'Network Domain' & 'Server Name' and you don't

        have one just enter 'localhost'

        NOTE:   you can still edit lines below in the

                [Apache-folder]\conf\httpd.conf

                after installed...

                        Listen 80

                        ServerAdmin admin@example.com

                        ServerName www.example.com:80

        enter a email address

        pick 'for All Users, on Port 80, as a Service', click 'Next'

Web App 應用需要四個基礎套件

很多 Web App 應用大多需要四個基礎套件安裝

1. Apache
2. PHP
3. MySQL
4. phpMyadmin

我已知有一個 AppServ 組織作了一條龍的套件, 但我沒試過, 因為我總是自己一個一個安裝.
其實每一個安裝過程大部分都很簡單, 只是偶而會遇到怪事.我現在養成習慣記錄下來.

下面我想就分成四篇筆記心得分享一下囉. 抱歉目前是用破英文寫的心得. 不是我耍屌, 只是安裝當時就直接記錄, 輸入英文比較快, 如果有人看不懂, 我想你也不適合自己 "親手" 用這些東西吧. 有空我會改中文. 中文字畢竟漂亮阿.

2012年5月1日 星期二

OpenGL 貼圖錯誤!?

最近開始進行用 OpenGL 實作 2D 圖形庫, 在開發過程出現了一個困擾的錯誤:

連續兩個四邊型(由兩三角形組成)物件各使用各自不同的貼圖, 但顯示後卻都是同一張圖!!

我花了很多時間想要找出哪裡作錯, 是我 glBindTexture 用錯導致? 是我不熟悉 OpenGL 的 pipeline 流程?

後來我換了電腦測試, 同一個 exe 在公司裡的電腦執行是正確的!

我越發奇怪,想真的是我不懂 OpenGL 了, 我開始找了網路最簡單的 texture 範例 (NeHe網站), 人家可是 OpenGL 高手可以了吧, 我改了一下把他的範例原是一張貼圖, 弄成貼兩張不同圖, 結果在家裡的電腦跑還是一樣出錯!

我又把該修改範例的 exe 丟給我朋友測試, 他說他那邊正常!

2012年3月21日 星期三

Eclipse+Android SDK/NDK 開發環境的過程 (1/2)

後記: 

02/11/2014, 我重灌電腦, 再度安裝 andriod 開發環境, 發現 andriod 官網已經把下述之 Eclipse IDE 跟 SDK (step 7~21) 整合成一個 adt-bundle 了, 下載該包後, 解壓縮到硬碟任何地方即可以. (但前提 JRE 還是要先裝), 我沒有再新建專案, 去測試剩餘的步驟的有無差異. 
參見再度安裝 andriod 開發環境



-------------------
Eclipse+Android SDK/NDK 開發環境的過程

以下為我記錄第一次就搞定 Eclipse + Android SDK/NDK 開發環境的過程

時間為 2012/3/21 當時下載的最新版軟體及 SDK

其實在參照人家分享的過程中, 我發現

1. Cygwin 根本不用裝到 devel 整個套件
2. 不必修改任何 Cygwin 的 bash profile 檔案, 就可以讓 ndk 正常運作, 可
   能是我習慣 "不用多做的事情盡量不要做" 吧, 所以試著少做一些看看...


以下:
p.s. 這是記錄日誌, 不是教學~
--------------------------------------------------------------------

1. 下載 Java SE(Standard Edition) Development Kit
   url: http://www.oracle.com/technetwork/java/javase/downloads/
   ref: jdk-7u3-windows-i586.exe (84.1MB)

2. 下載 Eclipse IDE for Java Developers
   url: http://www.eclipse.org/downloads/
   ref: eclipse-java-indigo-SR2-win32.zip (128MB)

3. 下載 Android SDK
   url: http://developer.android.com/sdk/
   ref: android-sdk_r16-windows.zip (28.1MB)
        installer_r16-windows.exe (28.1MB)

4. 下載 Android NDK
   (*** only needed for developing C/C++ native code libraries ***)
   url: http://developer.android.com/sdk/ndk/
   ref: android-ndk-r7b-windows.zip (76.6MB)

   NOTE: 開發 NDK 還需要有 GNU 的 bash 和 make 工具, Windows 下可以安
         裝 Cygwin 環境

   下載 Cygwin (only needed for NDK)
   url: http://cygwin.com/install.html
   ref: setup.exe (681KB)

2012年2月23日 星期四

SVN folder as sub module of GIT

這是上一篇中 '方法B' 的筆記

1) Prepare svn:// protocol:

(NOTE: don't use file:/// because it might has file format compilable problem)

In my case:

    1. svn repo at d:\work\repo\my_projects

    2. set svn service (I had set root at d:\work\repo) and make sure service was activated

    3. test svn checkout from svn://localhost/my_projects (or relative to yout root  in step2) has no polblem

    where repo tree is like:

    svn://my_projects/bla1/...
                     /bla2/...
                     /src/boo1/...
                     /src/boo2/...
                     /src/boo3/...
                     /src/...


    (NOTE: I don't use /trunk /branches /tags naming layout)
 

2) Purpose: 

the svn://my_projects/src/boo3/* is the library part, I need it to be used as

a git clone where in d:\work\my_test\boo3-clone

so git://d:\work\my_test\boo3-clone

will sync to/and from svn://localhost/my_projects/src/boo3


3)  using msysgit:

1. use GIT for windows' 'GIT bash here' at d:\work\my_test

2. use 'git svn clone url_of_svn_repo folde_rname

(NOTE: if using /trunk /branches /tags naming layout, use 'git svn clone -s ...' as -s is -stdlayout)

3. in my case

$ git svn clone svn://localhost/my_projects/src/boo3 boo3-clone
Initialized empty Git repository in d:/work/my_test/boo3-clone/.git/
r75 = 1324d83fab0b6d93f526b8f8252e8404d49c9e08 (refs/remotes/git-svn)
        A       boo3.vcxproj.user
...
        A       boo3.dsw
        A       boo3.vcxproj.filters
        A       boo3.dsp
r80 = 9f6afc8b5c2d68c4901de44a99e946b9edab5926 (refs/remotes/git-svn)
..
        M       boo3.dsp
r81 = cbb1be75466bfb695c76c8366828af3fd7c03a80 (refs/remotes/git-svn)
Checked out HEAD:
  svn://localhost/my_projects/src/boo3 r81


4. so now d:\work\my_test\boo3-clone had filled as a git repo where all files/folders/logs

   are the same as svn's

Ref: 使用 git-svn 整合 git 與 svn



 4) Another example by using TortoiseGit:

1. git svn clone setup


2. git svn clone done


3. add submodule


GIT 跟 SVN 一起工作的實驗作法...

情景:
-----
工作在 A project, 其中有一個子模組 B 是來自其他的 SVN controlled project

方法 A:
-------
目前的實驗作法, 是將子模組 B 當成一個目錄, 然後整個 svn checkout 到到該目錄, 此

時可以把他當作 project A 的一個目錄(與其他的目錄一樣) import/commit to GIT

A-+-B-1.c
  |   2.c
  |
  +-C-3.c
  ...

如上圖, 整個 A 是 GIT 控制的, 而 B 目錄是 checkout from SVN,

工作時以 GIT 為主, 如果有修改 1.c, 2.c 也把修改送上 GIT,

唯需要將 1.c, 2.c 的修改也送回 SVN (可以每次 GIT commit 後, 或累積數次) 時,

則切到 B 目錄上操做 SVN 的 commit 動作.

如果 B 的 SVN 源頭有新的修改, 也是在 B 目錄上操作 SVN update(or merge),

然後再 GIT commit 此次的 B 的 SVN update.

問題:
-----
B 目錄(並其子目錄) 下會有一大堆 .svn\* 的控制目錄(可能被隱藏起來)跟檔案.

GIT 不應該管控他, 如果這些檔案被送交 GIT, 則不適當的順序(commit 1.c, 2.c 沒有依先

SVN commit, 再 GIT commit...)操作, 有可能會毀掉 B 的 .svn 的控制.

解決:
-----

就不要把 .svn 之類的目錄跟檔案送進 GIT 控制, 方法是利用在 A 目錄(GIT project 根目錄)下

放一個 .gitignore 文字檔案.

裡面一行文字描述要 GIT 忽略的檔案類型

.svn*

p.s. 建議可以多加一些可忽略的檔案格式(如每次 build VS6/VS2010 都會重新產生的檔案)

.svn*
*.obj
*.pch
*.idb
*.pdb
*.log
*.tlog
*.suo
*.user
*.aps
*.clw
*.ncb
*.opt
*.plg

問題:
-----
如果是 M$ Windows 下, 是不永許產生"無前檔名"的文件 :(

解決:
-----

利用 msysgit 的 bash 環境產生!

開啟 GIT bash 切到 A 目錄下(或在目錄 A 上執行右選單的 GIT Bash here), 執行

>touch .gitignore

看看有沒有產生

>ls -al

explorer 打開目錄 A window, 也能看到 .gitignore, 此時用任何編輯器編輯他...

編輯好後存起來, 可以在 GIT bash 裡面切到 B 目錄, 執行

>git status

應該看不到 .svn 了...

git commit 時, 這些 .gitignore 裡面描述的檔案也是 "不會出現"




方法 B:
-------
一般比較正統的作法是用 git-svn 指令, 見 svn folder as sub module of git 描述方法

我實際試用了一次:

1. clone svn 步驟是需要學習的.

2. [印象中] 在我實際(當前 GIT) project, 我只要 SVN repo 個的一個子目錄(模組), 而非全部目錄,

   不容易這樣子做, 我試了許久, 繞了一圈有做出來, 但又好像怪怪的...

3. [印象中] 可以直接一次 git commit 就送回 SVN repo, 這是方法 A 不及的.

以上 [印象中] 因為時間過太久了, 我忘了為什麼又放棄此法, 有時間我還要再驗證一次.

2012年2月13日 星期一

TortoiseGIT 1.7.7 有感

從去年(2011)七月開始試用 GIT, 雖然一開始不太習慣, 但還是被他的快速吸引, 並有一些功能很特殊 like stash save 等, 只是我是一個 GUI 控, 版本控制用標準的命令列操作要記一堆指令跟打字, 我絕對無法面對, 我一直以來都是 TortoiseSVN 的愛用者, 當然就立刻裝了 TortoiseGIT 1.5 來用看看, 只是試用了一下, 充滿無奈, 有幾個嚴重的問題, 特別是 overlay icons 不正確, 如果直接由彈出選單操作也無法正確顯示有哪些檔案被修改過, 甚至會列出一大堆沒有修改的標為改過! 以上是 Tortoise 系列最重度需要的特色, 一度我開始找其他的 Free GUI clients 替代方案, like Git Extensions, SmartGIT 等, 試裝了結果又砍了, 因為操作直覺不順利, 其 UI 也醜, SCM 是每天必要的工具, 要快, 要順才對!
PC 上的 GIT clients 方案沒幾個, 試了一輪, 只好又回到 TortoiseGIT 上, 在其 issues 上參加討論 (有幾次使用上遭遇問題, 還會想乾脆來幫忙看怎麼修改? 只是自救都無暇了還幫人, 還是放棄該念頭.), 並改了用 nightly build 跟隨著, 因為我只用一個私人的小專案在 GIT 上, 所以輔助 MsysGIT GUI 一起操作還行, 所幸 TortoiseGIT 作者是積極的開發, 最後跟到 1.7.6 最後幾個 nightly build 我在乎的幾個問題都解了, 前幾日放出正式的 1.7.7, 謝謝該作者在開放軟體上無私的付出...
P.S. 不過美話說回來這幾版的 TortoiseGIT commit 花太多時間在 preparing (每次都要掃瞄目錄裡全部的文件!), 這好像比以前慢了(*)!?

(*)3/22 修正 : 過慢問題已經在 Issue 1085  提出並獲得修正,目前沒什麼可以挑剔的, 繼續使用了..