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

2022年8月22日 星期一

Viewport豆知識:Untiy Vs Unreal

今天在Unreal把MousePosition映射到NDC

(Editor Mode)

-1 < Xn < 1

-1 < Yn < 1


再從NDC映射到Camera的近平面上的點P時

Field of View = θ

ratio = screen width / screen height


scaleU = Xn * tan(θ/2) * ratio

scaleV = Yn * tan(θ/2) 

P = CameraPos + CameraX

 + CameraY * scaleU

 + CameraZ * scaleV

(Unreal的Camera是X軸和近平面垂直)

發現不管怎麼結果都很奇怪


後來先把ratio拿掉

scaleU = Xn * tan(θ/2) 

scaleV = Yn * tan(θ/2) 

才看出Unreal和Unity處理NDC到P的做法是不一樣的


Unreal使用的是

scaleU = Xn * tan(θ/2) 

scaleV = Yn * tan(θ/2) /ratio

假設 ratio = 2、θ = π/2 (90度)

當 Yn = 0.5, 有 scalueV = 1 


Unity使用的是

scaleU = Xn * tan(θ/2) * ratio

scaleV = Yn * tan(θ/2) 

假設 ratio = 2、θ = π/2 (90度)

當 Xn = 1, 有 scalueU = 2 


這代表,在Unity裡

你把Screen Width拉長時

水平方向會看到更多的東西


而在Unreal裡

當你把Screen Width拉長時

水平方向看到的範圍不變

但垂直方向看到的東西會變少


乘下的2個Case

在Unity裡, 把Screen Height拉長時


在Unreal裡, 把Screen Height拉長時


2022年5月17日 星期二

Static Function and Blueprintcallable

當SetWahCarTime的參數 WashCarTime
和Static變數 WashCarTime 同名
Comiper會過不了 並告訴你錯誤的地方


人家C#、Java、Typescript都沒這問題
就你毛最多


但是當你把 WashCarTime 
從 float 改成 dobule 時
它什麼毛都不會告訴你



為什麼要把WashCarTime
宣告成dobule呢?

不是
FTimespan回傳給你的就是dobule阿



但就算你把參數
改成pWahCarTime
還是Comiper不過就是了



倒敘法大概就是這麼1回事吧

2022年5月7日 星期六

Unreal Delegate 初體驗

5:10 自動完成 阿就是出不來


定義Delegate


宣告Delegate物件


自動完成出不來 不要以為少了那個步驟
(因為它是用Marco定義 VS不一定認的出來)

曾幾何時

對Unity Programminer來說

「想當然耳」要有的「自動完成」

(Code completion)

也變成了「可遇不可求」


Unity 

我好想你 我好想你 就深藏在心