Mouse Movement/zh: Difference between revisions
(Created page with "... //如果为平滑相视角则应用过滤器") |
(Created page with "虽然俯仰角被限制在-90°和 90°之间,但偏航角并不像预想的那样限制在-180°和180°之间。") |
||
Line 118: | Line 118: | ||
虽然俯仰角被限制在-90°和 90°之间,但偏航角并不像预想的那样限制在-180°和180°之间。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
While the pitch is clamped between -90° and 90°, yaw is not restricted between -180° and 180° as would be expected. |
|||
</div> |
|||
这意味着'''偏航是无限的''',如果你故意朝一个方向转动足够长的时间,则会产生一些意想不到的后果。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
This means that '''yaw is unbounded''', which has some unintended consequences if you deliberately turn in one direction for long enough. |
|||
</div> |
|||
由于它是一个浮点数,所以它的精度会随着它变大而变差,以至于它在大值时变得明显不稳定。 |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
By nature of being a float, its precision becomes worse the bigger it gets, to the point where it becomes noticeably jittery at large values. |
|||
</div> |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
<div lang="en" dir="ltr" class="mw-content-ltr"> |
Revision as of 11:44, 1 October 2021
滑鼠移動表示光標在屏幕上的瞬時位移(以像素為單位): ()。
在《我的世界》中,滑鼠移動代表視角的即時旋轉(以角度表示): ()。
靈敏度
靈敏度(s)是一個參數,用於改變視角的旋轉速度。
可以在「控制」菜單中更改此設置。
- 默認靈敏度為"100%" ()
- 原版中最低的靈敏度是"0%" ()
- 原版中最高的靈敏度是"200%" ()
在1.8中, 計算如下:
以同樣的方式獲得,如果打開了「滑鼠反轉」,則乘以-1。
在默認靈敏度下(),滑鼠移動一個像素轉換為0.15°旋轉。
這意味著視角以0.15°的增量移動:如果要轉45°,則需要移動滑鼠300px。
此外,s理論上並不受 [0,1] 的限制,它可以取任何值(甚至是負值)
您可以在 options.txt ( .minecraft 文件夾中)中手動編輯 mouseSensitivity 的值
請注意,伺服器上可能允許也可能不允許修改 options.txt 文件。
特殊的值
由於可以將靈敏度設置為我們想要的任何值,因此調整靈敏度以匹配特定的旋轉增量可能會很有趣。
為了得到所需增量的靈敏度 ,我們可以使用逆公式:
此表列出了一些特殊的旋轉增量,以及 s 的相應值。
s | |
---|---|
0° | -0.3333333 |
0.1° | 0.3946504 |
0.15° | 0.5 |
0.25° | 0.6546926 |
0.5° | 0.9115013 |
1° | 1.2350600 |
45° | 5.2452746 |
180° | 8.5221547 |
偏航和俯仰
偏航(水平旋轉)和俯仰(垂直旋轉)是跟蹤實體頭部旋轉的浮點數。
轉向是將偏航限制在[-180,180],如F3所示。俯仰角自然夾在[-90,90]之間。
滑鼠移動直接修改玩家的偏航和俯仰:
/* In EntityRenderer.java */
public void updateMouseMovement(...)
{
... //忽略前面的代码
float f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
float mult = f * f * f * 8.0F;
float dX = (float)this.mc.mouseHelper.deltaX * mult;
float dY = (float)this.mc.mouseHelper.deltaY * mult;
int i = 1;
if (this.mc.gameSettings.invertMouse)
i = -1;
... //如果为平滑相视角则应用过滤器
this.mc.thePlayer.rotateEntity(dX, dY*i);
}
/* In Entity.java */
public void rotateEntity(float dX, float dY)
{
this.rotationYaw = this.rotationYaw + dX*0.15);
this.rotationPitch = this.rotationPitch - dY*0.15;
this.rotationPitch = MathHelper.clamp(this.rotationPitch, -90.0, 90.0);
}
雖然俯仰角被限制在-90°和 90°之間,但偏航角並不像預想的那樣限制在-180°和180°之間。
這意味著偏航是無限的,如果你故意朝一個方向轉動足夠長的時間,則會產生一些意想不到的後果。
由於它是一個浮點數,所以它的精度會隨著它變大而變差,以至於它在大值時變得明顯不穩定。
- When () it can only increase in increments of 0.5°.
- When () it can only increase in increments of 1°.
At some point, yaw can even mess with movement and stop the player in place.
This is because the yaw gets too large to be converted to a proper angle (see Angles).
This phenomenon happens when .
Turning even further can crash the game, when