May 28, 2009

Prince of Persia !

怎麼可以有了新歡就忘了舊愛呢?G1S 我還沒忘記你啊!且看看你做了什麼事!

話說前一陣子在玩新的波斯王子,還沒玩完,不過已經讓我碰到幽靈事件了:


走近一看……



公主到底是怎麼飛上去的啊!波斯王子的畫面依然令我驚豔(之前只玩過時之砂),改變不大,要說最大的變化就是……這一代是波斯公主遇到一個很強的路人,只是公主太強大了,所以只要路人在年老力衰前達成任務即可,就算往懸崖跳一百次,公主也不會只救你九十九次!比較難過的是隨著劇情發展,公主跟路人會開始調情……是怎樣!打個電動都活該被閃嗎! \_/

stupid flying triangle

Finally, I rendered a stupid flying triangle in iPhone simulator. Though I never investigate OpenGL before, but it easier than d3d. So writing code to render simple object is quickly. But I am usually confused with gl functions. Like the "glTranslatef", this C function can`t tell me which matrix I try to translate now, just like many old C functions. It`s fortunate that I still don`t have to take care heavily matrix calculation in current stage.

I guess it`s time to start to make a simple game after learning how to render text, since the basic touch function need only override some method in UIView.



BTW, I tried to programming on symbian (sdk from nokia) long long ago. Maybe I was too weak so I could not make the simulator work correctly. I bough a book for that OS, but I never touch them again after several "days". (OK, that happened in 4th month of my programming life).

May 27, 2009

xcode is still not my friend !

Though I said Hello world 3 times, I am still not familiar with xcode. It took me several minutes to check why the debugger can`t work as visual studio. Then I unchecked the "Load symbols lazily" in accident and debugger can stop at the break point in the beginning. I don`t know if visual studio can do the same thing. But it should be useful in somewhere, maybe the symbols can be loaded when application crashing. That will help when debugging a big app. BTW, I don`t know if there is any default app like mspaint.exe in Mac, so there is no mark to show you the position of the option. It is the first one in the right panel. Wish you don`t have to enjoy it... XD

May 18, 2009

Lua

這幾天看Lua,寫了個測試程式,記得以前剛開始學windows GDI 的時候,最喜歡寫一堆字母在視窗裡飛來飛去的效果,還寫個螢幕保護程式版。配上 Lua 之後,每一個新的效果只要寫寫幾行 script 就搞定啦!

function OnLaunched()
local c = 512;

local x = 0;
local y = 0;

while (c > 0) do

x = math.random(0, 800);
y = math.random(0, 600);

AddNewParticle(math.random(65, 90));
SetNewParticleColor(
256 * math.random(0, 255),
0x00000200);

SetNewParticlePosition(x, y);
SetNewParticleVecl(0, math.random(1, 4));
SetNewParticleAccel(0, math.random(1, 4));
DeliverParticle();

c = c - 1;
end
end

function OnLButtonUp(x, y)
end

function OnParticleKilled(c)
local x = 0;
local y = 0;

while (c > 0) do
x = math.random(0, 800);
y = math.random(0, 600);

AddNewParticle(math.random(65, 90));
SetNewParticleColor(
256 * math.random(0, 255),
0x00000200);
SetNewParticlePosition(x, y);
SetNewParticleVecl(0, math.random(1, 4));
SetNewParticleAccel(0, math.random(1, 4));
DeliverParticle();

c = c - 1;
end
end


沒力了。

不想貼了。

自己猜吧!

New Toy !

I bought a new Mac Book from Apple store last week. I never played Mac OS before, and this made me suffer recently. But Leopard does have a good looking, so maybe I will enjoy in this OS soon.

There is some problems that make me post this in English. First, I don`t know how to change IME in Mac OS. Second, I only use LIU for Chinese, but I think it`s hard to find a Mac version. The main purpose to play this machine is I wanna practice programming in Mac. I don`t know if I could get any help from this domain, but to learn more is always better.

Here is a screen shot from my first GUI program in Mac. A simple window to translate ASCII code to Morse Code. It cost me about 3 hours to make it work, though I can do the same thing by MFC in 10 minutes. The level of AppKit is higher than MFC, so to create a new window application is easier. But if my experience from windows is still work, it`s better to study window programming in lower level. Just like I started ui programming with win32 (yes, register window class, create windows), and that made me better in gui programming till now.
 

BTW, <Learn Objective-C on the Mac> is really good for an experienced C/C++ programmer. Though there are many different feature, it`s possible to pick it up in 4 days. My own problems is how to become more familiar with those new topic, like category & protocol.

May 4, 2009

thinking about depth buffer


我的 software rendering 用的 view matrix 跟 d3d 一樣,但是會有問題,這個問題也許是整個pipeline 最大的瓶頸。

主要的問題是這樣,為了讓 z 可以 mapping 到 near 跟 far plane,view matrix 裡會做些手腳,讓最後的 z 變成 (f / (f - n)) * (1 - n / z),如此一來,當 z 是n 時,深度為0,z 是 f 時深度為 1。上圖是 depth - z 的關係。問題出在 z 小於 0 的時候,depth是正的,如果在這時才作 z 方向上的 culling,那整個三角形的方向就錯了!如果這一塊是無法解決的,那整塊 mesh 就得在 normaliz 之前先跟 view frustum clip,結果則是產生更多的小三角形。讓我慶幸的是……我可以懶得管這件事,讓dx去解決。