Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -15,15 +15,17 @@ public:
|
||||
|
||||
///Move
|
||||
void move(Direction a, float speed);
|
||||
///Move in the direction a moby is facing.
|
||||
void move(float speed);
|
||||
|
||||
///Horizontal Move.
|
||||
virtual void hMove(Direction a, float speed);
|
||||
///Vertical Move.
|
||||
void vMove(float vel);
|
||||
///The position we would be at if we did a horizontal movement.
|
||||
Position simulateHMove(Direction a, float speed);
|
||||
Position projectedHorizontalMove(Direction a, float speed);
|
||||
///The position we would be at if we did a vertical movement.
|
||||
Position simulateVMove(float speed);
|
||||
Position projectedVerticalMove(float speed);
|
||||
float getVelocity();
|
||||
void setVelocity(float vel);
|
||||
void setVelocityAngle(const Vector3& a);
|
||||
@@ -38,5 +40,7 @@ public:
|
||||
Direction lAngle();
|
||||
/// Right angle
|
||||
Direction rAngle();
|
||||
|
||||
void vAngleMove(float speed);
|
||||
};
|
||||
|
||||
|
@@ -18,6 +18,7 @@ int main()
|
||||
Shader test("test", engine->workingDir + "/assets/shaders/defaultVertex.glsl", engine->workingDir + "/assets/shaders/defaultFragment.glsl");
|
||||
|
||||
auto* camera = new(FreeCam);
|
||||
camera->name = "Camera";
|
||||
camera->SetPos({0.0f, -2.0f, -5.0f});
|
||||
camera->SetParent(engine->world);
|
||||
engine->world->setActiveCamera(camera);
|
||||
|
@@ -1,28 +1,28 @@
|
||||
#include <freeCam.h>
|
||||
|
||||
void FreeCam::pre_render() {
|
||||
if (engine->window->isKeyDown(Keys::S))
|
||||
hMove(bAngle(), 4);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::W))
|
||||
hMove(fAngle(), 4);
|
||||
move(getAngleDirection(), 4);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::S))
|
||||
move(bAngle(), 4);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::A))
|
||||
hMove(lAngle(), 4);
|
||||
move(lAngle(), 4);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::D))
|
||||
hMove(rAngle(), 4);
|
||||
move(rAngle(), 4);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::Z))
|
||||
if (engine->window->isKeyDown(Keys::Space))
|
||||
vMove(4);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::X))
|
||||
if (engine->window->isKeyDown(Keys::LShift))
|
||||
vMove(-4);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::Q))
|
||||
if (engine->window->isKeyDown(Keys::LeftArrow))
|
||||
setAngle(getAngle().x, getAngle().y - 75.0f * engine->frameDelta, getAngle().z);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::E))
|
||||
if (engine->window->isKeyDown(Keys::RightArrow))
|
||||
setAngle(getAngle().x, getAngle().y + 75.0f * engine->frameDelta, getAngle().z);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::UpArrow))
|
||||
@@ -30,4 +30,11 @@ void FreeCam::pre_render() {
|
||||
|
||||
if (engine->window->isKeyDown(Keys::DownArrow))
|
||||
setAngle(getAngle().x + 75.0f * engine->frameDelta, getAngle().y, getAngle().z);
|
||||
}
|
||||
|
||||
if (engine->window->isKeyDown(Keys::Q))
|
||||
setAngle(getAngle().x, getAngle().y, getAngle().z - 75.0f * engine->frameDelta);
|
||||
|
||||
if (engine->window->isKeyDown(Keys::E))
|
||||
setAngle(getAngle().x, getAngle().y, getAngle().z + 75.0f * engine->frameDelta);
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include <Redacted3D/types/entity/camera.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
#include <Redacted3D/engine/utils/instanceOf.h>
|
||||
#include <jlog/jlog.hpp>
|
||||
|
||||
//inline LinearAlgebra::Vector3 Entity::GetPos() const
|
||||
//{ return LinearAlgebra::Vector3(coordinates[1]); }
|
||||
@@ -33,6 +34,7 @@ Vector3 Entity::GetPos() const {
|
||||
|
||||
void Entity::SetPos(const Vector3 &rhs) {
|
||||
position = rhs;
|
||||
DEBUG(std::format("Set position for entity '{}' to x={} y={} z={}", this->name, rhs.x, rhs.y, rhs.z));
|
||||
}
|
||||
|
||||
Entity::Entity() {
|
||||
@@ -253,5 +255,10 @@ void Entity::setAngle(float pitch, float yaw, float roll) {
|
||||
}
|
||||
|
||||
Direction Entity::getAngleDirection() {
|
||||
return Vector3::Direction(angle);
|
||||
Direction a = Vector3::Direction(angle);
|
||||
//These two are reversed when moving things in the Re3D scene.
|
||||
//-Z is forward.
|
||||
a.x = -a.x;
|
||||
a.z = -a.z;
|
||||
return a;
|
||||
}
|
||||
|
@@ -2,28 +2,52 @@
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
using namespace J3ML;
|
||||
|
||||
///Moves the moby horizontally only.
|
||||
void Moby::hMove(Direction a, float vel) {
|
||||
position.z -= (vel*engine->frameDelta) * a.x;
|
||||
position.x += (vel*engine->frameDelta) * a.z;
|
||||
}
|
||||
|
||||
///Moves the moby vertically only.
|
||||
void Moby::vMove(float vel) {
|
||||
position.y += (vel*engine->frameDelta);
|
||||
}
|
||||
|
||||
//TODO
|
||||
///Moves the moby in a given Direction Vector with a given speed.
|
||||
void Moby::move(Direction a, float speed) {
|
||||
position.x += a.z * (speed * engine->frameDelta);
|
||||
position.z -= a.x * (speed * engine->frameDelta);
|
||||
position.y += a.y * (speed * engine->frameDelta);
|
||||
}
|
||||
|
||||
///Moves the moby in the direction it's facing without having to pass it in.
|
||||
void Moby::move(float speed) {
|
||||
Direction a = getAngleDirection();
|
||||
position.x += a.z * (speed * engine->frameDelta);
|
||||
position.z -= a.x * (speed * engine->frameDelta);
|
||||
position.y += a.y * (speed * engine->frameDelta);
|
||||
}
|
||||
|
||||
///Moves the moby in the direction of it's velocity without having to pass it in.
|
||||
void Moby::vAngleMove(float speed) {
|
||||
Direction a = getVelocityAngleDirection();
|
||||
position.x += a.z * (speed * engine->frameDelta);
|
||||
position.z -= a.x * (speed * engine->frameDelta);
|
||||
position.y += a.y * (speed * engine->frameDelta);
|
||||
}
|
||||
|
||||
//Returns the position we'd be at *if* we did a movement.
|
||||
Direction Moby::simulateHMove(Vector3 a, float vel) {
|
||||
Direction Moby::projectedHorizontalMove(Vector3 a, float vel) {
|
||||
Position p;
|
||||
p.z -= (vel*engine->frameDelta) * a.x;
|
||||
p.x += (vel*engine->frameDelta) * a.z;
|
||||
return p;
|
||||
}
|
||||
|
||||
Position Moby::projectedVerticalMove(float speed) {
|
||||
return {position.x, position.y += (speed*engine->frameDelta), position.z};
|
||||
}
|
||||
|
||||
Direction Moby::fAngle()
|
||||
{
|
||||
Direction a;
|
||||
@@ -55,10 +79,6 @@ Direction Moby::lAngle() {
|
||||
return a;
|
||||
}
|
||||
|
||||
Position Moby::simulateVMove(float speed) {
|
||||
return {position.x, position.y += (speed*engine->frameDelta), position.z};
|
||||
}
|
||||
|
||||
float Moby::getVelocity() {
|
||||
return velocity;
|
||||
}
|
||||
@@ -68,7 +88,11 @@ void Moby::setVelocity(float vel) {
|
||||
}
|
||||
|
||||
Direction Moby::getVelocityAngleDirection() {
|
||||
return Vector3::Direction(velAngle);
|
||||
Direction a = Vector3::Direction(velAngle);
|
||||
///X and Z are reversed in the Re3D scene.
|
||||
a.x = -a.x;
|
||||
a.z = -a.z;
|
||||
return a;
|
||||
}
|
||||
|
||||
Vector3 Moby::getVelocityAngle() {
|
||||
|
Reference in New Issue
Block a user