code style

顯示具有 software 標籤的文章。 顯示所有文章
顯示具有 software 標籤的文章。 顯示所有文章

9/30/2016

How to load dynamic library with Unity plugin on Mac OSX

When develop Unity plugin on Mac, you might want to load third party dynamic library. But it usually occurs "fail to load" situation. That is because loading path is different between development and production environment.

For instance, when you develop in Edit mode, the loading path will be
 ./Assets/Plugins/osxplugin.bundle/Contents/Resources/thirdparty.dylib

But when you build a release version, the loading path will be
./Contents/Plugins/osxplugin.bundle/Contents/Resources/thirdparty.dylib

Mac OSX provide a command line tool to modify that.

$ install_name_tool -id @loader_path/thirdparty.dylib thirdparty.dylib

You could use otool to check dylib status.

eg.
$ otool -L libcurl.dylib 
libcurl.dylib:
 @loader_path/libcurl.dylib (compatibility version 0.0.0, current version 0.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
 /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)

Now, you can develop and build a unity app without dylib loading issue.

1/08/2012

Create Sprite Sheets with TexturePacker


2D game為了提高效能,通常會將一個個sprite集合成一張大圖,也就是所謂的sprite sheet。3D game也是如此,只不過換了個名詞:sprite換成texture、sheet換成atlas。
Picture 1. Sprite Sheet Example

拼圖的演算法有數個,這裡舉個簡單例子:
每插入一個新的sprite,該區塊將會產生兩個更小的區塊,依此類推。如果sprite都無法插入每個小區塊,則表示sheet不夠大,必須將sheet放大重新來過。
Algorithm Example


如果你想在iOS上寫2D game的話,cocos2d是一套相當不錯的開源軟體,當然它也提供了sprite sheet的功能。那麼問題就在於要如何產生sprite sheet?其實市面上已經有一堆現成工具讓使用者能夠方便快速地製作sprite sheet。這裡我會介紹TexturePacker這套跨平台免費軟體(高階功能需要付費)。

工商服務時間




主要支援框架


支援貼圖格式

  • Flash (.swf) – consisting of single frames
  • PNG
  • JPG
  • TIFF
  • BMP

支援輸出格式

  • PNG – Portable Network Graphics
  • PVR – iPhone’s native image format
  • PVR.CCZ – zlib compressed version of PVR for cocos2d
  • PVR.GZ – gnu zip compressed PVR files
  • JPG – JPEG


TexturePacker提供兩種排版的演算法:

Basic
這是最基本的演算法,簡單無腦地依序插入sprite,直到填滿為止。免費版本只提供Basic排版。

MaxRects
MaxRects是一種快速、高密度的排版演算法。開啟sprite旋轉與修剪的功能可以得到更好的結果。TexturePackerPro/CLI版本可以使用這個演算法(付費版本)

如果對這些演算法有興趣,可以參考這個網頁(link)。

Dithering
  • RGBA8888, BGRA8888 – 32bit, 256 colors per channel, 16777216 colors, 256 transparency values
  • RGBA5555
  • RGBA5551 – 16bit, 32 colors per channel, 32768 colors, 1 “hard” transparency value
  • RGBA4444 – 16bit, 16 colors per channel, 4096 colors, 16 transparency values
  • RGB565 – 16bit, 65536 colors, no transparency
  • PVRTC2 – lossy compression for iPhone(付費版本)
  • PVRTC4 – lossy compression for iPhone(付費版本)

Trimming
修剪功能可以移除sprite周圍的透明像素,可以縮減貼圖大小、提高繪圖效能。2.3.5版本以前是免費,之後就改成付費版本了。

除此之外,TexturePacker支援command line,可以讓開發者在建置專案的過程中,同時把需要的sprite sheets給自動產生出來。因此也不需要版本控管這些sheets啦。

Tips
  • 使用PVR時可以補上–premultiply-alpha,當然也要記得作相對應的設定:[CCTexture2D PVRImagesHavePremultipliedAlpha:YES]
  • 使用inner-padding可以避免sprite吃到其他相鄰srpite的像素,造成黑色邊緣。



11/21/2011

Survey Perforce

最近在試用Perforce

據悉Google, Sony, NVidia, Pixar, Epic都在使用Perforce作為SCM工具


安裝真的挺方便的,不過我沒做過網管,沒有說服力

身為遊戲開發人員,SCM工具除了能夠version control以外

最好還要有能夠預覽所管理的psd、3ds max、maya等圖形檔案

Perforce很神奇地提供P4Thumb這個工具

P4Thumb可以針對Server上的檔案自動產生thumbnail
包含 * PSD (Photoshop) * MB (Maya) * MAX (3ds Max)

其他Client就可以取得預覽縮圖啦!

1/18/2011

msysgit with CopSSH for windows

 1. install GitExtensions (includes msysgit)
* by default, Git installs to C:\Program Files\Git\

2. install CopSSH
* by default, CopSSH installs to C:\Program Files\ICW\

3. control panel > user accounts > create new account (for example, git)

4. copssh control panel > users > add activated account, i.e. git
* choose "Linux shell and Sftp" for access type to enable shell command execution

5. in C:\Program Files\ICW\home\gi, edit .bashrc and append below script
gitpath=/cygdrive/c/Program\ Files/Git/bin
gitcore=/cygdrive/c/Program\ Files/Git/libexec/git-core
export PATH=$gitpath:$gitcore:$PATH

6. create a remote repository
$ssh git@localhost
$git init test
$cd test; touch abc
$git add .; git commit -m 'test'

7. clone from remote
$git clone git@localhost:test mytest

8. all done :)

If you want to use public keys to access git account, collect public keys and put them into home/git/.ssh/authorized_keys. Check this to get more information.

2/14/2009

Greasemonkey

用cooliris看正妹相簿實在相當方便

可惜台灣的正妹相簿大多放在無名

無名又沒有提供media rss給cooliris使用

所以只好找替代方案 "Greasemonkey"

Greasemonkey是FireFox上的萬能腳本外掛程式

已經有很多網友寫了一堆script供大家使用

gslin大神寫wretch album expander相當簡單俐落

[使用前]



[使用後]



如果要支援cooliris,就要參考這篇文章

基本上就是擷取相簿內容,轉換成media rss,再餵給cooliris


附註: 長輩推薦的autopagerizer也很好用!

5/27/2007

software engineering