Mouse Movement/zh: Difference between revisions

From Minecraft Parkour Wiki
Content added Content deleted
(Created page with "鼠标运动")
 
No edit summary
 
(33 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
鼠标移动表示光标在屏幕上的瞬时位移(以像素为单位):(<math display="inline">dx,dy</math>)。
<div lang="en" dir="ltr" class="mw-content-ltr">
Mouse movement represents the instant displacement of the cursor on the screen (in pixels) : (<math display="inline">dx,dy</math>).
</div>


在《我的世界》中,鼠标移动代表视角的即时旋转(以角度表示):(<math display="inline">\Delta x , \Delta y</math>)。
<div lang="en" dir="ltr" class="mw-content-ltr">
When it comes to Minecraft, mouse movement represents the instant rotation of the camera (in degrees) : (<math display="inline">\Delta x , \Delta y</math>).
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<br />
<br />
</div>




<span id="Sensitivity"></span>
<div lang="en" dir="ltr" class="mw-content-ltr">
== Sensitivity ==
== 灵敏度 ==
</div>


灵敏度('''s''')是一个参数,用于改变视角的旋转速度。
<div lang="en" dir="ltr" class="mw-content-ltr">
Sensitivity ('''s''') is a parameter that changes how fast the camera should turn.
</div>


可以在“控制”菜单中更改此设置。
<div lang="en" dir="ltr" class="mw-content-ltr">
This setting can be changed in the Controls menu.
</div>


* 默认灵敏度为“100%”(<math display="inline">s=0.5</math>)
<div lang="en" dir="ltr" class="mw-content-ltr">
* The default sensitivity is "100%" (<math display="inline">s=0.5</math>)
</div>


* 原版中最低的灵敏度是“0%”(<math display="inline">s=0.0</math>)
<div lang="en" dir="ltr" class="mw-content-ltr">
* The lowest vanilla sensitivity is "0%" (<math display="inline">s=0.0</math>)
* 原版中最高的灵敏度是“200%”(<math display="inline">s=1.0</math>
* The highest vanilla sensitivity is "200%" (<math display="inline">s=1.0</math>)
</div>




在1.8中,<math display="inline">\Delta x</math> 计算如下:
<div lang="en" dir="ltr" class="mw-content-ltr">
In 1.8, <math display="inline">\Delta x</math> is calculated as:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<math>\Delta x = 1.2dx \times (0.6s + 0.2)^{3}</math>
<math>\Delta x = 1.2dx \times (0.6s + 0.2)^{3}</math>
</div>


<math display="inline">\Delta y</math>以同样的方式获得,如果打开了“鼠标反转”,则乘以-1。
<div lang="en" dir="ltr" class="mw-content-ltr">
<math display="inline">\Delta y</math> is obtained in the same way, and is multiplied by -1 if "Invert Mouse" is ON.
</div>




在默认灵敏度下(<math display="inline">s=0.5</math>),鼠标移动一个像素转换为 0.15° 旋转。
<div lang="en" dir="ltr" class="mw-content-ltr">
With default sensitivity (<math display="inline">s=0.5</math>), one pixel of mouse movement translates into 0.15° of rotation.
</div>


这意味着视角以 0.15° 的增量移动:如果要转 45°,则需要移动鼠标 300px。
<div lang="en" dir="ltr" class="mw-content-ltr">
This means that the camera moves in increments of 0.15°: to turn 45°, you would need to move your mouse by 300px.
</div>






此外,'''s''' 理论上并不受 [0,1] 的限制,它可以取任何值(甚至是负值)
<div lang="en" dir="ltr" class="mw-content-ltr">
Furthermore, '''s''' isn't technically bounded by [0,1], and can take any value (even negative).
</div>


您可以在 options.txt(.minecraft 文件夹中)中手动编辑 mouseSensitivity 的值
<div lang="en" dir="ltr" class="mw-content-ltr">
You can manually edit the value of mouseSensitivity in the options.txt file (found in the .minecraft folder)
</div>


请注意,服务器上可能允许也可能不允许修改 options.txt 文件。
<div lang="en" dir="ltr" class="mw-content-ltr">
Be warned that modifying the options.txt file may or may not be allowed on servers.
</div>








<span id="Remarkable_values"></span>
<div lang="en" dir="ltr" class="mw-content-ltr">
== Remarkable values ==
== 特殊的值 ==
</div>


由于可以将灵敏度设置为我们想要的任何值,因此可以调整灵敏度以获得特定的旋转增量。
<div lang="en" dir="ltr" class="mw-content-ltr">
Since it's possible to set the sensitivity to any value we want, it might be interesting to adjust the sensitivity to match specific rotation increments.
</div>


为了得到所需增量 <math display="inline">\delta</math> 所匹配的灵敏度,我们可以使用逆公式:
<div lang="en" dir="ltr" class="mw-content-ltr">
To get the required sensitivity for the desired increment <math display="inline">\delta</math>, we can use the inverse formula:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<math>s = \frac{\sqrt[3]{\frac{\delta}{1.2}} - 0.2}{0.6}</math>
<math>s = \frac{\sqrt[3]{\frac{\delta}{1.2}} - 0.2}{0.6}</math>
<br />
<br />
</div>


此表列出了一些特殊的旋转增量,以及 '''s''' 的相应值。
<div lang="en" dir="ltr" class="mw-content-ltr">
This table lists remarkable increments of rotation, and the corresponding values of '''s'''.
{| class="wikitable"
{| class="wikitable"
!<math display="inline">\delta</math>
!<math display="inline">\delta</math>
Line 120: Line 81:
|8.5221547
|8.5221547
|}<br />
|}<br />
</div>


<span id="Yaw_and_Pitch"></span>
<div lang="en" dir="ltr" class="mw-content-ltr">
== Yaw and Pitch ==
== 偏航和俯仰 ==
</div>


偏航(水平旋转)和俯仰(垂直旋转)是跟踪实体头部旋转的[http://zh.wiki.sxisa.org/wiki/%E6%B5%AE%E7%82%B9%E6%95%B0 浮点数]。
<div lang="en" dir="ltr" class="mw-content-ltr">
Yaw (horizontal rotation) and pitch (vertical rotation) are [https://en.wikipedia.org/wiki/Floating-point_arithmetic floats] that keep track of an entity's head rotation.
</div>


[[Special:MyLanguage/Facing and Angles|转向]]是将偏航限制在 [-180,180],如[[Special:MyLanguage/Debug Screen|F3]]所示。俯仰角自然夹在 [-90,90] 之间。
<div lang="en" dir="ltr" class="mw-content-ltr">
[[Special:MyLanguage/Facing and Angles|Facing]] is the restriction of the yaw to [-180, 180], as it is represented in [[Special:MyLanguage/Debug Screen|F3]]. Pitch is naturally clamped between [-90, 90].
</div>


鼠标移动直接修改玩家的偏航和俯仰:<syntaxhighlight lang="java">
<div lang="en" dir="ltr" class="mw-content-ltr">
/* 在EntityRenderer.java中 */
Mouse movement directly modifies the player's yaw and pitch:<syntaxhighlight lang="java">
/* In EntityRenderer.java */
public void updateMouseMovement(...)
public void updateMouseMovement(...)
{
{
... //previous code ignored
... //忽略前面的代码
</div>


float f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
<div lang="en" dir="ltr" class="mw-content-ltr">
float f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
float mult = f * f * f * 8.0F;
float mult = f * f * f * 8.0F;
float dX = (float)this.mc.mouseHelper.deltaX * mult;
float dX = (float)this.mc.mouseHelper.deltaX * mult;
float dY = (float)this.mc.mouseHelper.deltaY * mult;
float dY = (float)this.mc.mouseHelper.deltaY * mult;
</div>


int i = 1;
<div lang="en" dir="ltr" class="mw-content-ltr">
int i = 1;
if (this.mc.gameSettings.invertMouse)
if (this.mc.gameSettings.invertMouse)
i = -1;
i = -1;
</div>


... //如果为平滑相视角则应用过滤器
<div lang="en" dir="ltr" class="mw-content-ltr">
... //Applies filters if smooth camera
</div>


this.mc.thePlayer.rotateEntity(dX, dY*i);
<div lang="en" dir="ltr" class="mw-content-ltr">
this.mc.thePlayer.rotateEntity(dX, dY*i);
}
}
</div>




/* 在Entity.java中 */
<div lang="en" dir="ltr" class="mw-content-ltr">
/* In Entity.java */
public void rotateEntity(float dX, float dY)
public void rotateEntity(float dX, float dY)
{
{
Line 174: Line 118:
}
}
</syntaxhighlight>
</syntaxhighlight>
</div>






虽然俯仰角被限制在 -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>


* 当 <math>|yaw| > 4194304</math> (<math display="inline">2^{22}</math>) 它只能以 0.5° 的增量增加。
<div lang="en" dir="ltr" class="mw-content-ltr">
* When <math>|yaw| > 4194304</math> (<math display="inline">2^{22}</math>) it can only increase in increments of 0.5°.
* <math>|yaw| > 8388608</math> (<math display="inline">2^{23}</math>) 它只能以 1° 的增量增加。
* When <math>|yaw| > 8388608</math> (<math display="inline">2^{23}</math>) it can only increase in increments of 1°.
</div>






在某些时候,偏航甚至可以[https://youtu.be/DEI_CeFlatM 扰乱运动并使玩家停止在原地]。
<div lang="en" dir="ltr" class="mw-content-ltr">
At some point, yaw can even [https://youtu.be/DEI_CeFlatM mess with movement and stop the player in place].
</div>


这是因为偏航太大而无法转换为合适的角度(参见[[Special:MyLanguage/Angles|角度]])。
<div lang="en" dir="ltr" class="mw-content-ltr">
This is because the yaw gets too large to be converted to a proper angle (see [[Special:MyLanguage/Angles|Angles]]).
</div>


这种现象发生在 <math>|yaw| \geq 11796480 = 360 \times 2^{15}</math> 时。
<div lang="en" dir="ltr" class="mw-content-ltr">
This phenomenon happens when <math>|yaw| \geq 11796480 = 360 \times 2^{15}</math>.
</div>




当 <math display="inline">|yaw| > 8.59 \times 10^9</math> 时,可能会导致游戏崩溃。
<div lang="en" dir="ltr" class="mw-content-ltr">
Turning even further can crash the game, when <math display="inline">|yaw| > 8.59 \times 10^9</math>
</div>

Latest revision as of 05:28, 16 August 2023

Other languages:

鼠标移动表示光标在屏幕上的瞬时位移(以像素为单位):()。

在《我的世界》中,鼠标移动代表视角的即时旋转(以角度表示):()。



灵敏度

灵敏度(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.3333333
0.1° 0.3946504
0.15° 0.5
0.25° 0.6546926
0.5° 0.9115013
1.2350600
45° 5.2452746
180° 8.5221547


偏航和俯仰

偏航(水平旋转)和俯仰(垂直旋转)是跟踪实体头部旋转的浮点数

转向是将偏航限制在 [-180,180],如F3所示。俯仰角自然夹在 [-90,90] 之间。

鼠标移动直接修改玩家的偏航和俯仰:

/* 在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);
}


/* 在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° 之间。

这意味着偏航是无限的,如果你故意朝一个方向转动足够长的时间,则会产生一些意想不到的后果。


由于它是一个浮点数,所以它的精度会随着它变大而变差,以至于它在大值时变得明显不稳定。

  • () 它只能以 0.5° 的增量增加。
  • () 它只能以 1° 的增量增加。


在某些时候,偏航甚至可以扰乱运动并使玩家停止在原地

这是因为偏航太大而无法转换为合适的角度(参见角度)。

这种现象发生在 时。


时,可能会导致游戏崩溃。