This commit is contained in:
2024-06-24 13:07:14 -04:00
parent 6e64e7b10c
commit c82663fdc2
5 changed files with 12 additions and 12 deletions

View File

@@ -68,6 +68,7 @@ public:
[[nodiscard]] GLfloat getGlobalFogDensity() const;
Camera* getActiveCamera();
Vector3 upVector = {0, 1, 0};
std::string name;
std::vector<VertexArray*> geometryList;
std::vector<Texture*> textureList;

View File

@@ -10,8 +10,7 @@ private:
///Speed.
float velocity;
public:
Vector3 upVector = {0.0f,1.0f,0.0f};
Moby(): Entity(), upVector(0, 1, 0){}
Moby(): Entity(){}
///Move
void move(Direction a, float speed);

View File

@@ -21,7 +21,7 @@ void Camera::render() {
glRotatef(getAngle().y,0.0f, 1.0f, 0.0f);
glRotatef(getAngle().z,0.0f, 0.0f, 1.0f);
glMultMatrixf(lookAt({position.x, position.y, position.z}, {position.x, position.y, engine->farPlane+position.z}, upVector).data());
glMultMatrixf(lookAt({position.x, position.y, position.z}, {position.x, position.y, engine->farPlane+position.z}, engine->world->upVector).data());
}
void Camera::post_render() {

View File

@@ -243,7 +243,7 @@ OBB Entity::getOBB() {
}
Vector3 Entity::getAngle() {
return angle;
return {Math::Degrees(Math::Radians(angle.x)), Math::Degrees(Math::Radians(angle.y)), Math::Degrees(Math::Radians(angle.z))};
}
void Entity::setAngle(const Vector3 &a) {
@@ -255,7 +255,7 @@ void Entity::setAngle(float pitch, float yaw, float roll) {
}
Direction Entity::getAngleDirection() {
Direction a = Vector3::Direction(angle);
Direction a = Vector3::Direction(getAngle());
//These two are reversed when moving things in the Re3D scene.
//-Z is forward.
a.x = -a.x;

View File

@@ -64,18 +64,18 @@ Direction Moby::bAngle() {
Direction Moby::rAngle() {
Direction f = fAngle();
Direction a;
a.x = f.x * upVector.z - f.z * upVector.y;
a.y = f.z * upVector.x - f.x * upVector.z;
a.z = f.x * upVector.y - f.y * upVector.x;
a.x = f.x * engine->world->upVector.z - f.z * engine->world->upVector.y;
a.y = f.z * engine->world->upVector.x - f.x * engine->world->upVector.z;
a.z = f.x * engine->world->upVector.y - f.y * engine->world->upVector.x;
return a;
}
Direction Moby::lAngle() {
Direction f = fAngle();
Direction a;
a.x = -(f.y * upVector.z - f.z * upVector.y);
a.y = (f.z * upVector.x - f.x * upVector.z);
a.z = -(f.x * upVector.y - f.y * upVector.x);
a.x = -(f.y * engine->world->upVector.z - f.z * engine->world->upVector.y);
a.y = (f.z * engine->world->upVector.x - f.x * engine->world->upVector.z);
a.z = -(f.x * engine->world->upVector.y - f.y * engine->world->upVector.x);
return a;
}
@@ -105,4 +105,4 @@ void Moby::setVelocityAngle(const Vector3 &a) {
void Moby::setVelocityAngle(float pitch, float yaw, float roll) {
velAngle = {pitch, yaw, roll};
}
}