Some AABB stuff

This commit is contained in:
2024-01-11 10:00:54 -05:00
parent 9f3098a026
commit e205c581eb
4 changed files with 12 additions and 9 deletions

View File

@@ -1,9 +1,9 @@
#pragma once
#include <types/entity.h>
#include "animation/scriptedMove.h"
#include "J3ML/LinearAlgebra/Vector3.h"
#include <types/animation/scriptedMove.h>
#include <J3ML/LinearAlgebra/Vector3.h>
#include <types/vertex.h>
//Movable Object.
class Moby : public Entity {
@@ -15,6 +15,8 @@ public:
LinearAlgebra::Vector3 angle = {0,0,0}; //Pitch Yaw Roll, The orientation of the entity in the world,
LinearAlgebra::Vector3 velAngle = {0,0,0}; //The angle of an entities velocity.
LinearAlgebra::Vector3 Velocity;
VertexArray geometry;
VertexArray boundingBox;
LinearAlgebra::Vector3 upVector = {0.0f,1.0f,0.0f};
ScriptedMove sMove;
void move(LinearAlgebra::Vector3 a, float speed);

View File

@@ -2,6 +2,7 @@
#include <iostream>
#include <cmath>
#include <types/collision/axisAlignedBoundingBox.h>
#include "moby.h"
#include "entityList.h"
#include "../engine/engine.h"
@@ -12,7 +13,6 @@ public:
uint8_t health;
uint8_t state;
LinearAlgebra::Vector3 cameraTarget;//The point where the 3rd-person camera will want to look at.
VertexArray geometry;
//Each type of entity will have an "update" function and a "render" function.
//These will be declared in each type of entity and not in the base entity because
//It'll be different for each one.
@@ -30,8 +30,6 @@ public:
}
void update(float elapsed) override {}
//if (engine->tickCount >=10)
//std::cout << "Player* Hopefully: " << scriptedMove.parent->position.x;
void pre_render() override {
// PLACEHOLDER LOL.
// William continues to load assets on the first frame.
@@ -42,6 +40,7 @@ public:
}
//Rotate
this->angle.y += 200.0*engine->frameDelta;
boundingBox = BoundingBox::calculateAABB(&geometry);
}
void render() override {
glColor3f(0.75,0.75,0.75);

View File

@@ -1,11 +1,10 @@
#pragma once
#include <types/entity.h>
#include <types/vertex.h>
#include <types/moby.h>
class Skybox : public Entity {
class Skybox : public Moby {
public:
VertexArray geometry;
void pre_render() override;

View File

@@ -1,5 +1,8 @@
#include <types/collision/axisAlignedBoundingBox.h>
#include <limits>
//This won't work correctly if you don't also rotate vArray by the rotation of the moby.
//TODO
VertexArray BoundingBox::calculateAABB(VertexArray* vArray) {
VertexArray output;
float minX = std::numeric_limits<float>::max();