Skip to content

Commit

Permalink
Merge pull request #3 from noggaholic/with-angle
Browse files Browse the repository at this point in the history
Use yaw/pitch from camera instead of view matrix
  • Loading branch information
karliky authored May 5, 2020
2 parents b94ba2c + e50c86c commit eba4fed
Show file tree
Hide file tree
Showing 37 changed files with 1,152 additions and 465 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@
## Key Features 🎉

* All WoW versions supported from Alpha to Legion
- Out of the box support for 0.5.3, 0.8.0 ... 1.12 ... 2.3.4... 3.3.5a ... 7.3
- Out of the box support for 0.5.3, 0.8.0 ... 1.12.1 ... 2.3.4... 3.3.5a ... 7.3.5
* Built with latest technologies like Electron.js, Vue.js, Bulma.io and Robot.js
* Build complex cinematic scenes with it's built-in editor
* Full control of the environment
* An explorer's dream come true ✨
* Custom free camera mode for Alpha and Vanilla
* Custom spectate camera mode for Alpha and Vanilla

### Features per version:

| Version | Spectate | Cinematic | Environment |
|---------|----------|-----------|------------- |
| 0.5.3 | ✔️ | ✔️ | ⚙️ |
| 0.8.0 | ✔️ | ✔️ | ⚙️ |
| 1.8.0 | ✔️ | ✔️ | ⚙️ |
| 1.12.0 | ✔️ | ✔️ | ⚙️ |
| 2.4.3 | ✔️ | ✔️ | ⚙️ |
| 3.3.5a | ✔️ | ✔️ | ⚙️ |
| 4.3.4 | ✔️ | ✔️ | ⚙️ |
| 6.2.3 | ✔️ | ✔️ | ⚙️ |
| 7.2.5(24742) | ✔️ | ✔️ | ⚙️ |
| 7.3.5(26972) | ✔️ | ⚙️ | ⚙️ |
| Version | Spectate | Cinematic mode | Environment | |
|------------------|----------|----------------|-------------|------------------- |
| 0\.5\.3 | ✔️ | ✔️ | Time of day | Max view distance |
| 0\.8\.0 | ✔️ | ✔️ | ✔️ | ⚙️ |
| 1\.8\.0 | ✔️ | ✔️ | ✔️ | ⚙️ |
| 1\.12\.0 | ✔️ | ✔️ | ✔️ | ⚙️ |
| 2\.4\.3 | ✔️ | ✔️ | ✔️ | ⚙️ |
| 3\.3\.5a | ✔️ | ✔️ | ✔️ | ⚙️ |
| 4\.3\.4 | ✔️ | ✔️ | ✔️ | ⚙️ |
| 6\.2\.3 | ✔️ | ✔️ | ✔️ | ⚙️ |
| 7\.2\.5\(24742\) | ✔️ | ✔️ | ✔️ | ⚙️ |
| 7\.3\.5\(26972\) | ✔️ | ✔️ | ⚙️ | ⚙️ |

⚙️ Means that the development of that feature it's not finished yet for that version.

Expand Down
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"dependencies": {
"axios": "^0.16.1",
"bulma": "0.8.2",
"curve-interpolator": "^2.0.6",
"gsap": "^3.0.2",
"lodash.clonedeep": "^4.5.0",
"robot-js": "[email protected]:Robot/robot-js.git#dev",
Expand Down
3 changes: 2 additions & 1 deletion src/core/domain/disableSpectate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function disableSpectate(Game, Memory, Offsets, Module) {
SpectatePointer,
} = CameraStruct;
if (Game.client === 'vanilla' || Game.client === 'alpha') {
Memory.writeData(InstructionPointer, Offsets[Game.client].camera.pattern, Offsets[Game.client].camera.pattern.byteLength);
const fixPositionPattern = Offsets[Game.client].camera.position[Game.build].pattern;
Memory.writeData(InstructionPointer, fixPositionPattern, fixPositionPattern.byteLength);
} else if (Game.client === 'ctl') {
Memory.writeData(Module + Offsets[Game.client].SpectatePointer, Offsets[Game.client].DisableSpectate, Offsets[Game.client].DisableSpectate.byteLength);
Memory.writeData(Pointer + Offsets[Game.client].EnableCorrectKeyboardControls, Offsets[Game.client].DisableSpectateOnCam, Offsets[Game.client].DisableSpectateOnCam.byteLength);
Expand Down
11 changes: 6 additions & 5 deletions src/core/domain/disableViewMatrixUpdate.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

function disableViewMatrixUpdate(Game, Memory, Offsets) {
return (ViewMatrixInstructionsPointer) => {
Memory.writeData(ViewMatrixInstructionsPointer,
Offsets[Game.client].cameraViewMatrix.version[Game.build].fix,
Offsets[Game.client].cameraViewMatrix.version[Game.build].fix.byteLength,
);
return () => {
if (Game.client !== 'alpha') return;
const patterns = Offsets[Game.client].cameraViewMatrix.version[Game.build];
patterns.forEach((instruction) => {
Memory.writeData(instruction.offset, instruction.fix, instruction.fix.byteLength);
});
};
}

Expand Down
26 changes: 15 additions & 11 deletions src/core/domain/enableKeyboardControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const Robot = require('robot-js');
const Keyboard = Robot.Keyboard;
const Mouse = Robot.Mouse;

function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, GetCameraData, SetPosition, SetSpeed) {
function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, GetCameraData, SetPosition, SetSpeed, Offsets, Memory) {
return (CameraStruct, speed) => {
const {
Pointer,
Expand All @@ -16,6 +16,10 @@ function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, Ge
return 1;
}

const enableCameraFacingBuffer = new Buffer([0xD6, 0x00, 0x00, 0x00, 0x61, 0x0E, 0xC2, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
const enableCameraFacingPtr = Offsets[Game.client].enableCameraFacing;
Memory.writeData(Pointer + enableCameraFacingPtr, enableCameraFacingBuffer, enableCameraFacingBuffer.byteLength);

EnableSpectate(CameraStruct, Pointer);
EnableViewMatrixUpdate(ViewMatrixInstructionsPointer);
return setInterval(() => {
Expand All @@ -26,28 +30,28 @@ function EnableKeyboardControls(Game, EnableSpectate, EnableViewMatrixUpdate, Ge
const camera = GetCameraData(Pointer);
const state = Mouse.getState();
if (Keyboard.getState(Robot.KEY_W) || (state[Robot.BUTTON_LEFT] && state[Robot.BUTTON_RIGHT])) {
const x = camera.position.x + camera.yaw.x * speed;
const y = camera.position.y + camera.yaw.y * speed;
const z = camera.position.z + camera.yaw.z * speed;
return SetPosition(Pointer, x, y, z);
const x = camera.position.x + camera.forward.x * speed;
const y = camera.position.y + camera.forward.y * speed;
const z = camera.position.z + camera.forward.z * speed;
return SetPosition(CameraStruct, x, y, z);
}
if (Keyboard.getState(Robot.KEY_S)) {
const x = camera.position.x - camera.yaw.x * speed;
const y = camera.position.y - camera.yaw.y * speed;
const z = camera.position.z - camera.yaw.z * speed;
return SetPosition(Pointer, x, y, z);
const x = camera.position.x - camera.forward.x * speed;
const y = camera.position.y - camera.forward.y * speed;
const z = camera.position.z - camera.forward.z * speed;
return SetPosition(CameraStruct, x, y, z);
}
if (Keyboard.getState(Robot.KEY_SPACE)) {
const x = camera.position.x;
const y = camera.position.y;
const z = camera.position.z + speed;
return SetPosition(Pointer, x, y, z);
return SetPosition(CameraStruct, x, y, z);
}
if (Keyboard.getState(Robot.KEY_LCONTROL)) {
const x = camera.position.x;
const y = camera.position.y;
const z = camera.position.z - speed;
return SetPosition(Pointer, x, y, z);
return SetPosition(CameraStruct, x, y, z);
}
}, 0);
};
Expand Down
8 changes: 4 additions & 4 deletions src/core/domain/enableSpectate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ function enableSpectateMode(Game, Memory, Offsets, Module, GetCameraData, SetPos
InstructionPointer,
SpectatePointer,
Pointer,
CameraValuesPointer,
} = CameraStruct;
if (Game.client === 'vanilla' || Game.client === 'alpha') {
Memory.writeData(InstructionPointer, Offsets[Game.client].camera.fix, Offsets[Game.client].camera.fix.byteLength);
const fixPositionPattern = Offsets[Game.client].camera.position[Game.build].fix;
Memory.writeData(InstructionPointer, fixPositionPattern, fixPositionPattern.byteLength);
} else if (Game.client === 'ctl') {
const { position } = GetCameraData(Pointer);
SetPosition(CameraValuesPointer, position.x, position.y, position.z);
SetPosition(CameraStruct, position.x, position.y, position.z);
Memory.writeData(Module + Offsets[Game.client].SpectatePointer, Offsets[Game.client].EnableSpectate, Offsets[Game.client].EnableSpectate.byteLength);
Memory.writeData(Pointer + Offsets[Game.client].EnableCorrectKeyboardControls, Offsets[Game.client].EnableSpectateOnCam, Offsets[Game.client].EnableSpectateOnCam.byteLength);
} else {
const { position } = GetCameraData(Pointer);
SetPosition(CameraValuesPointer, position.x, position.y, position.z);
SetPosition(CameraStruct, position.x, position.y, position.z);
Memory.writeData(SpectatePointer, Offsets[Game.client].EnableSpectate, Offsets[Game.client].EnableSpectate.byteLength);
}
};
Expand Down
11 changes: 6 additions & 5 deletions src/core/domain/enableViewMatrixUpdate.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

function enableViewMatrixUpdate(Game, Memory, Offsets) {
return (ViewMatrixInstructionsPointer) => {
Memory.writeData(ViewMatrixInstructionsPointer,
Offsets[Game.client].cameraViewMatrix.version[Game.build].pattern,
Offsets[Game.client].cameraViewMatrix.version[Game.build].pattern.byteLength,
);
return () => {
if (Game.client !== 'alpha') return;
const patterns = Offsets[Game.client].cameraViewMatrix.version[Game.build];
patterns.forEach((instruction) => {
Memory.writeData(instruction.offset, instruction.pattern, instruction.pattern.byteLength);
});
};
}

Expand Down
10 changes: 10 additions & 0 deletions src/core/domain/environment/disableTimeOfDay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

function DisableTimeOfDayUpdate(Game, Memory, Offsets) {
return ({ enableTimeOfDay }) => {
if (!enableTimeOfDay) return;
const enableUpdateOfTimeOfday = Offsets[Game.client].environment.version[Game.build].timeOfDayPattern;
Memory.writeData(enableTimeOfDay, enableUpdateOfTimeOfday, enableUpdateOfTimeOfday.byteLength);
};
}

module.exports = DisableTimeOfDayUpdate;
10 changes: 10 additions & 0 deletions src/core/domain/environment/enableTimeOfDay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

function EnableTimeOfDayUpdate(Game, Memory, Offsets) {
return ({ enableTimeOfDay }) => {
if (!enableTimeOfDay) return;
const enableUpdateOfTimeOfday = Offsets[Game.client].environment.version[Game.build].timeOfDayPatternFix;
Memory.writeData(enableTimeOfDay, enableUpdateOfTimeOfday, enableUpdateOfTimeOfday.byteLength);
};
}

module.exports = EnableTimeOfDayUpdate;
4 changes: 3 additions & 1 deletion src/core/domain/environment/getEnvPtr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ function GetEnvPtr(Game, memory, Module, offsets) {
return () => {
if (!offsets[Game.client].environment) return { timeOfDay: 0 };
const timeOfDay = Module + offsets[Game.client].environment.version[Game.build].timeOfDay;

const timeOfDayPattern = offsets[Game.client].environment.version[Game.build].timeOfDayPattern;
const enableTimeOfDay = timeOfDayPattern ? memory.find(timeOfDayPattern.toString('hex'), 0, -1, 1, '-x')[0] : 0;
return {
timeOfDay,
enableTimeOfDay,
};
};
}
Expand Down
10 changes: 10 additions & 0 deletions src/core/domain/environment/getNormalizedTimeOfDay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function GetNormalizedTimeOfDay(Game) {
return (hour, minutes) => {
if (Game.client === 'mop' ||
Game.client === 'draenor' ||
Game.client === 'legion') return (((3600 * hour) + (60 * minutes)) / 86400) * 1440;
return ((3600 * hour) + (60 * minutes)) / 86400;
};
}

module.exports = GetNormalizedTimeOfDay;
12 changes: 12 additions & 0 deletions src/core/domain/environment/setNormalizedTimeOfDay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

function SetNormalizedTimeOfDay(Memory) {
const timeOfDayBuffer = new Buffer(0x4);
return (environmentStruct, timeOfDay) => {
const timeOfDayPtr = environmentStruct.timeOfDay;
if (!timeOfDayPtr) return;
timeOfDayBuffer.writeFloatLE(timeOfDay);
Memory.writeData(timeOfDayPtr, timeOfDayBuffer, timeOfDayBuffer.byteLength);
};
}

module.exports = SetNormalizedTimeOfDay;
4 changes: 2 additions & 2 deletions src/core/domain/environment/setTimeOfday.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

function SetTimeOfday(Game, Memory, Offsets, Module) {
function SetTimeOfday(Memory, GetNormalizedTimeOfDay) {
const timeOfDayBuffer = new Buffer(0x4);
return (environmentStruct, { hour, minutes }) => {
const timeOfDayPtr = environmentStruct.timeOfDay;
if (!timeOfDayPtr) return;
const timeNormalized = ((3600 * hour) + (60 * minutes)) / 86400;
const timeNormalized = GetNormalizedTimeOfDay(hour, minutes);
timeOfDayBuffer.writeFloatLE(timeNormalized);
Memory.writeData(timeOfDayPtr, timeOfDayBuffer, timeOfDayBuffer.byteLength);
};
Expand Down
46 changes: 16 additions & 30 deletions src/core/domain/getCameraData.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ const clonedeep = require('lodash.clonedeep');
const cameraBufferSize = 0x48;
const cameraBuffer = new Buffer(cameraBufferSize);

function GetCameraData(Memory) {
const cameraRotBufferSize = 0xC;
const cameraRotBuffer = new Buffer(cameraRotBufferSize);

function GetCameraData(Offsets, Game, Memory) {
return (Pointer) => {
const camera = getCameraStruct();
const rotationPtr = Offsets[Game.client].CameraRot;
Memory.readData(Pointer, cameraBuffer, cameraBufferSize);
Memory.readData(Pointer + rotationPtr, cameraRotBuffer, cameraRotBufferSize);

camera.position.x = cameraBuffer.readFloatLE(0x8);
camera.position.y = cameraBuffer.readFloatLE(0xC);
Expand All @@ -21,28 +26,16 @@ function GetCameraData(Memory) {
camera.viewMatrix[0][1] = cameraBuffer.readFloatLE(0x18);
camera.viewMatrix[0][2] = cameraBuffer.readFloatLE(0x1C);

camera.viewMatrix[1][0] = cameraBuffer.readFloatLE(0x20);
camera.viewMatrix[1][1] = cameraBuffer.readFloatLE(0x24);
camera.viewMatrix[1][2] = cameraBuffer.readFloatLE(0x28);

camera.viewMatrix[2][0] = cameraBuffer.readFloatLE(0x2C);
camera.viewMatrix[2][1] = cameraBuffer.readFloatLE(0x30);
camera.viewMatrix[2][2] = cameraBuffer.readFloatLE(0x34);

/**
* First row of the View Matrix is the forward vector
*/
camera.yaw.x = camera.viewMatrix[0][0];
camera.yaw.y = camera.viewMatrix[0][1];
camera.yaw.z = camera.viewMatrix[0][2];
camera.forward.x = camera.viewMatrix[0][0];
camera.forward.y = camera.viewMatrix[0][1];
camera.forward.z = camera.viewMatrix[0][2];

camera.pitch.x = camera.viewMatrix[1][0];
camera.pitch.y = camera.viewMatrix[1][1];
camera.pitch.z = camera.viewMatrix[1][2];

camera.roll.x = camera.viewMatrix[2][0];
camera.roll.y = camera.viewMatrix[2][1];
camera.roll.z = camera.viewMatrix[2][2];
camera.yaw = cameraRotBuffer.readFloatLE(0);
camera.pitch = cameraRotBuffer.readFloatLE(4);
camera.roll = cameraRotBuffer.readFloatLE(8);

camera.Fov = cameraBuffer.readFloatLE(0x38);
camera.NearClip = cameraBuffer.readFloatLE(0x3C);
Expand All @@ -64,21 +57,14 @@ function getCameraStruct() {
y: 0,
z: 0,
},
yaw: {
x: 0,
y: 0,
z: 0,
},
pitch: {
x: 0,
y: 0,
z: 0,
},
roll: {
forward: {
x: 0,
y: 0,
z: 0,
},
yaw: 0,
pitch: 0,
roll: 0,
Fov: 0,
NearClip: 0,
FarClip: 0,
Expand Down
Loading

0 comments on commit eba4fed

Please sign in to comment.