2016年1月19日 星期二

ThirdPersonFollowCamera

(1)SpringArm(Scenes/oldCamera.unity)

insprited by Unreal Spring Arm componet

local Position of MainCamera is (0,0,0)

(2)CameraPivot(Scenes/planet.unity)

CameraPivot offer the same function as SpringArm
But using Quaternion make the code become clear and simple

z value of MainCamera is length of SpringArm

notes:
these two component has problem when using on planet. (when player moves , camera will shak a little)the Problem of CameraPivot is fixed  now!  

2016年1月8日 星期五

D3DXMatrixPerspectiveOffCenterLH

查看doc後會發現對x的變換應該長的像這樣 doc



上面的意思是,如果有個點在近平面上是(L,y,n)
代入函數(Ax+Bz)/z後,會得到 x' =(AL+Bn)/n =-1

其他同樣投影到這個位置x'的點,會是(s*L,s*y,s*n)
代入函數(Ax+Bz)/z後,仍然可以得到(A*s*L+B*s*n)/s*n=(AL+Bn)/n=-1 =x'
表示A,B對不是近平面上的點同樣有效

2016年1月6日 星期三

鏡子的問題

then Only part of the image is correct

Yes I use this method !



Just thinking

Mirror

在鏡子的另一邊放置1個mirror camera,render出來的結果,要記得重新投影到鏡子物件上



筆記:
(1)雖然unity的物件的移動旋轉是左手座標系,但是在render前
WorldToCameraSpace會把左手座標映射為右手座標 unity doc
所以transform.worldToLocalMatrix和Camera的worldToCameraMatrix是不一樣的
(之後就會使用右手座標的projection Matrix)

PS:
為什麼不從頭到尾都使用左手座標?


(2)directx和cg的貼圖座標不太一樣
(3)unity 的Matrix4x4是colume-major unity doc
(4)索引的方式

2016年1月4日 星期一

Camera on the planet


在Unity裡測試類似瑪利歐銀河的Camera


需要注意的是,當玩家在球上移動時
必須主動更新camera的旋轉,這樣camera才不會跑掉