Fix fAngle and bAngle being reversed.

This commit is contained in:
2024-01-25 07:18:11 -05:00
parent 59b7fedb86
commit 3fb9a87146
4 changed files with 21 additions and 25 deletions

View File

@@ -18,7 +18,8 @@ public:
ScriptedMove sMove;
virtual void hMove(LinearAlgebra::Vector3 a, float vel);
void vMove(float vel);
LinearAlgebra::Vector3 simulateMove(LinearAlgebra::Vector3 a, float speed);
LinearAlgebra::Vector3 simulateHMove(LinearAlgebra::Vector3 a, float speed);
LinearAlgebra::Vector3 simulateVMove(LinearAlgebra::Vector3 position, float speed);
void doSMove();
LinearAlgebra::Vector3 fAngle(); // forward angle
LinearAlgebra::Vector3 bAngle(); // back angle

View File

@@ -60,10 +60,10 @@ void Camera::freeCam() {
}
if (engine->window->keyDown(SCANCODE::LEFT)) {
this->angle.y +=75.0f*engine->frameDelta;
this->angle.y -=75.0f*engine->frameDelta;
}
if (engine->window->keyDown(SCANCODE::RIGHT)) {
this->angle.y -=75.0f*engine->frameDelta;
this->angle.y +=75.0f*engine->frameDelta;
}
if (engine->window->keyDown(SCANCODE::UP)) {
this->angle.x -=75.0f*engine->frameDelta;
@@ -120,10 +120,6 @@ Geometry::Frustum Camera::getFrustum() {
void Camera::hMove(LinearAlgebra::Vector3 a, float vel) {
if (cameraMode == CameraMode::FREECAM) {
position.z += (vel * engine->frameDelta) * a.x;
position.x += (vel * engine->frameDelta) * a.z;
position.y += (vel * engine->frameDelta) * a.y;
Moby::hMove(a,vel);
}
position.z += (vel*engine->frameDelta) * a.x;
position.x += (vel*engine->frameDelta) * a.z;
}

View File

@@ -1,7 +1,7 @@
#include <types/moby.h>
void Moby::hMove(LinearAlgebra::Vector3 a, float vel) {
position.z += (vel*engine->frameDelta) * a.x;
position.z -= (vel*engine->frameDelta) * a.x;
position.x += (vel*engine->frameDelta) * a.z;
}
@@ -10,33 +10,28 @@ void Moby::vMove(float vel) {
}
//Returns the position we'd be at *if* we did a movement.
LinearAlgebra::Vector3 Moby::simulateMove(LinearAlgebra::Vector3 a, float speed) {
LinearAlgebra::Vector3 Moby::simulateHMove(LinearAlgebra::Vector3 a, float vel) {
LinearAlgebra::Vector3 p;
p.z = this->position.z += (speed*engine->frameDelta) * a.x;
p.y = this->position.y += (speed*engine->frameDelta) * a.y;
p.x = this->position.x += (speed*engine->frameDelta) * a.z;
p.z -= (vel*engine->frameDelta) * a.x;
p.x += (vel*engine->frameDelta) * a.z;
return p;
}
LinearAlgebra::Vector3 Moby::fAngle()
{
LinearAlgebra::Vector3 a;
a.x = (cos(Math::Radians(this->angle.y)) * cos(Math::Radians(this->angle.x)));
a.x = -(cos(Math::Radians(this->angle.y)) * cos(Math::Radians(this->angle.x)));
a.y = -sin(Math::Radians(this->angle.x));
a.z = (sin(Math::Radians(this->angle.y)) * cos(Math::Radians(this->angle.x)));
a.z = -(sin(Math::Radians(this->angle.y)) * cos(Math::Radians(this->angle.x)));
return a;
}
LinearAlgebra::Vector3 Moby::bAngle()
{
LinearAlgebra::Vector3 a;
a.x = -(cos(Math::Radians(this->angle.y)) * cos(Math::Radians(this->angle.x)));
a.y = sin(Math::Radians(this->angle.x));
a.z = -(sin(Math::Radians(this->angle.y)) * cos(Math::Radians(this->angle.x)));
return a;
return -fAngle();
}
LinearAlgebra::Vector3 Moby::lAngle()
LinearAlgebra::Vector3 Moby::rAngle()
{
LinearAlgebra::Vector3 f = fAngle();
LinearAlgebra::Vector3 a;
@@ -46,7 +41,7 @@ LinearAlgebra::Vector3 Moby::lAngle()
return a;
}
LinearAlgebra::Vector3 Moby::rAngle()
LinearAlgebra::Vector3 Moby::lAngle()
{
LinearAlgebra::Vector3 f = fAngle();
LinearAlgebra::Vector3 a;
@@ -95,3 +90,7 @@ void Moby::doSMove() {
}
LinearAlgebra::Vector3 Moby::simulateVMove(LinearAlgebra::Vector3 position, float speed) {
return {position.x, position.y += (speed*engine->frameDelta), position.z};
}

View File

@@ -6,9 +6,9 @@ void Player::pre_render() {
velAngle = angle;
//hMove(LinearAlgebra::Vector3::Direction({0, velAngle.y, 0}), hVelocity);
//vMove(vVelocity);
this->angle.x += 96*engine->frameDelta;
this->angle.z += 96*engine->frameDelta;
this->angle.y += 96*engine->frameDelta;
//this->angle.x -= 96*engine->frameDelta;
this->angle.z -= 96*engine->frameDelta;
this->angle.y -= 96*engine->frameDelta;
}
void Player::render() {