マウス移動

From Minecraft Parkour Wiki
Revision as of 09:44, 19 July 2022 by KK kaku (talk | contribs) (Created page with "→‎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); } </syntaxhighlight>")
Other languages:

マウス移動は、画面上でのマウスカーソルの瞬間的な移動量を表す(単位はピクセル/px): ()。

Minecraftにおいては、マウス移動は視点の瞬間的な回転量を表す(単位は度):()。



マウス感度

マウス感度(s)は、視点の回転速度を変更するパラメーターである。

操作設定のメニューから変更できる。

  • デフォルトのマウス感度は「100%」(
  • バニラでの最低感度は「0%」(
  • バニラでの最高感度は「200%」(


1.8では、は次のように計算される:

も同様に求められ、「マウス操作の反転」の設定がオンの場合は-1倍される。


デフォルトのマウス感度()では、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


YawとPitch

Yaw (horizontal rotation) and pitch (vertical rotation) are floats that keep track of an entity's head rotation.

Facing is the restriction of the yaw to [-180, 180], as it is represented in F3. Pitch is naturally clamped between [-90, 90].

Mouse movement directly modifies the player's yaw and pitch:
/* In EntityRenderer.java */
public void updateMouseMovement(...)
{
    ... //previous code ignored
</div>

    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);
}


While the pitch is clamped between -90° and 90°, yaw is not restricted between -180° and 180° as would be expected.

This means that yaw is unbounded, which has some unintended consequences if you deliberately turn in one direction for long enough.


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.

  • When () it can only increase in increments of 0.5°.
  • When () it can only increase in increments of 1°.


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