Skip to content

Commit

Permalink
adopt handedness conversion scheme from the fabric mod
Browse files Browse the repository at this point in the history
conversion scheme still converts Minecraft's a right-handed system to Mumble's left-handed system but using a different approach (switching z axis instead of previously swapping z and y axis)

fixes #55
  • Loading branch information
zsawyer committed Jan 24, 2023
1 parent 8e016e7 commit abc95eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion mod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'idea'
apply plugin: 'maven-publish'

ext.modversion = "5.1.0"
ext.modversion = "6.0.0"
ext.mcversion = "1.18.1"
ext.forgeversion_dependency = "39"
ext.forgeversion = "39.0.0"
Expand Down
51 changes: 31 additions & 20 deletions mod/src/main/java/zsawyer/mods/mumblelink/mumble/UpdateData.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,65 +100,76 @@ public void set(Minecraft game) {
// 1 unit = 1 meter

// initialize multipliers
// converted to left-handed coordinate system
// (Mumble uses a left-handed, Minecraft uses a right-handed)
float fAvatarPositionX = 1;
float fAvatarPositionY = 1;
float fAvatarPositionZ = -1; // switch to left-handedness

float fCameraPositionX = 1;
float fCameraPositionY = 1;
float fCameraPositionZ = -1; // switch to left-handedness

float fAvatarFrontX = 1;
float fAvatarFrontY = 1;
float fAvatarFrontZ = 1;
float fAvatarFrontZ = -1; // switch to left-handedness

float fCameraFrontX = 1;
float fCameraFrontY = 1;
float fCameraFrontZ = 1;
float fCameraFrontZ = -1; // switch to left-handedness

float fAvatarTopX = 1;
float fAvatarTopY = 1; // Y points up
float fAvatarTopZ = 1;
float fAvatarTopY = 1;
float fAvatarTopZ = -1; // switch to left-handedness

float fCameraTopX = 1;
float fCameraTopY = 1; // Y points up
float fCameraTopZ = 1;
float fCameraTopY = 1;
float fCameraTopZ = -1; // switch to left-handedness

Vec3 lookDirection = game.player.getLookAngle();
Vec3 topDirection = getTopVec(game);

// Position of the avatar
fAvatarPosition = new float[]{
(float) game.player.getPosition(1f).x(),
(float) game.player.getPosition(1f).z(),
(float) game.player.getPosition(1f).y()
(float) game.player.getPosition(1f).x() * fAvatarPositionX,
(float) game.player.getPosition(1f).y() * fAvatarPositionY,
(float) game.player.getPosition(1f).z() * fAvatarPositionZ
};

// Unit vector pointing out of the avatar's eyes (here Front looks
// into scene).
fAvatarFront = new float[]{
(float) lookDirection.x * fAvatarFrontX,
(float) lookDirection.z * fAvatarFrontZ,
(float) lookDirection.y * fAvatarFrontY
(float) lookDirection.y * fAvatarFrontY,
(float) lookDirection.z * fAvatarFrontZ
};

// Unit vector pointing out of the top of the avatar's head (here
// Top looks straight up).
fAvatarTop = new float[]{
(float) topDirection.x * fAvatarTopX,
(float) topDirection.z * fAvatarTopZ,
(float) topDirection.y * fAvatarTopY
(float) topDirection.y * fAvatarTopY,
(float) topDirection.z * fAvatarTopZ
};

// TODO: use real camera position, s.a.
// Position of the camera
fCameraPosition = new float[]{
(float) game.player.getPosition(1f).x(),
(float) game.player.getPosition(1f).z(),
(float) game.player.getPosition(1f).y()
(float) game.player.getPosition(1f).x() * fCameraPositionX,
(float) game.player.getPosition(1f).y() * fCameraPositionY,
(float) game.player.getPosition(1f).z() * fCameraPositionZ
};

fCameraFront = new float[]{
(float) lookDirection.x * fCameraFrontX,
(float) lookDirection.z * fCameraFrontZ,
(float) lookDirection.y * fCameraFrontY
(float) lookDirection.y * fCameraFrontY,
(float) lookDirection.z * fCameraFrontZ
};

fCameraTop = new float[]{
(float) topDirection.x * fCameraTopX,
(float) topDirection.z * fCameraTopZ,
(float) topDirection.y * fCameraTopY
(float) topDirection.y * fCameraTopY,
(float) topDirection.z * fCameraTopZ
};

// Identifier which uniquely identifies a certain player in a
Expand Down

0 comments on commit abc95eb

Please sign in to comment.