Develop into master #9

Merged
SemvdH merged 126 commits from develop into main 2021-06-18 15:56:41 +00:00
5 changed files with 32 additions and 14 deletions
Showing only changes of commit a6fa9514df - Show all commits

View File

@@ -23,5 +23,7 @@ namespace entities
this->rotation.y += rotation.y; this->rotation.y += rotation.y;
this->rotation.z += rotation.z; this->rotation.z += rotation.z;
} }
} }

View File

@@ -40,7 +40,7 @@ namespace entities
inline glm::vec3 GetPosition() const { return position; } inline glm::vec3 GetPosition() const { return position; }
inline void SetPosition(const ::glm::vec3& position) { this->position = position; } inline void SetPosition(const ::glm::vec3& position) { this->position = position; }
inline glm::vec3 GetRotation() const { return rotation; } inline glm::vec3 GetRotation() const { return rotation; }
inline void SetRotation(const ::glm::vec3& rotation) { this->rotation = rotation; } void SetRotation(const ::glm::vec3& rotation) { this->rotation = rotation; }
inline float GetScale() const { return scale; } inline float GetScale() const { return scale; }
inline void SetScale(const float scale) { this->scale = scale; } inline void SetScale(const float scale) { this->scale = scale; }
}; };

View File

@@ -7,11 +7,10 @@
#include"../renderEngine/loader.h" #include"../renderEngine/loader.h"
namespace entities namespace entities
{ {
float movement_speed; int movement_speed, down_speed, side_speed;
float down_speed;
float side_speed;
bool is_playing; bool is_playing;
MainCharacter::MainCharacter(const models::TexturedModel& model, const glm::vec3& position, MainCharacter::MainCharacter(const models::TexturedModel& model, const glm::vec3& position,
const glm::vec3& rotation, float scale, const collision::Box& bounding_box) const glm::vec3& rotation, float scale, const collision::Box& bounding_box)
: CollisionEntity(model, position, rotation, scale, bounding_box) : CollisionEntity(model, position, rotation, scale, bounding_box)
@@ -25,11 +24,12 @@ namespace entities
computervision::HandDetectRegion* reg_up = regions.at(1); computervision::HandDetectRegion* reg_up = regions.at(1);
computervision::HandDetectRegion* reg_right = regions.at(2); computervision::HandDetectRegion* reg_right = regions.at(2);
if (is_playing) { double delta_time = UpdateDelta();
movement_speed = -0.5f; //Forward speed adjustment, bee is moving at a standard speedrate
down_speed = -1.0f; //Down speed adjustment, downspeed is difference between down_speed and UP_SPEED
side_speed = 0; //Side speed adjustment
if (is_playing) {
movement_speed = -15; //Forward speed adjustment, bee is moving at a standard speedrate
down_speed = -50; //Down speed adjustment, downspeed is difference between down_speed and UP_SPEED
side_speed = 0; //Side speed adjustment
//For gameplay with use of keyboard keys: W, A, S, D //For gameplay with use of keyboard keys: W, A, S, D
//W: Go forward //W: Go forward
//A: Go left //A: Go left
@@ -37,10 +37,12 @@ namespace entities
//D: Go right //D: Go right
//TODO Implement CV actions //TODO Implement CV actions
//top right //top right
SetRotation(glm::vec3(0, 90, 0));
if (reg_up->IsHandPresent() && reg_left->IsHandPresent()) if (reg_up->IsHandPresent() && reg_left->IsHandPresent())
{ {
side_speed += SIDE_SPEED; side_speed += SIDE_SPEED;
down_speed += UP_SPEED; down_speed += UP_SPEED/2;
SetRotation(glm::vec3(10, 90, 0));
} }
//right //right
if (reg_left->IsHandPresent()) if (reg_left->IsHandPresent())
@@ -50,8 +52,9 @@ namespace entities
//top left //top left
if (reg_up->IsHandPresent() && reg_right->IsHandPresent()) if (reg_up->IsHandPresent() && reg_right->IsHandPresent())
{ {
down_speed += UP_SPEED; down_speed += UP_SPEED/2;
side_speed -= SIDE_SPEED; side_speed -= SIDE_SPEED;
SetRotation(glm::vec3(10, 90, 0));
} }
//left //left
if (reg_right->IsHandPresent()) if (reg_right->IsHandPresent())
@@ -65,7 +68,8 @@ namespace entities
SetRotation(glm::vec3(10, 90, 0)); SetRotation(glm::vec3(10, 90, 0));
} }
} }
IncreasePosition(glm::vec3(side_speed, down_speed, movement_speed)); IncreasePosition(glm::vec3(side_speed*delta_time, down_speed*delta_time, movement_speed*delta_time));
std::cout << "delta time char: "<< delta_time << std::endl;
//Use only for binding bee to house, such that it doesn't go outside of the room. //Use only for binding bee to house, such that it doesn't go outside of the room.
//TODO delete when boundingbox is implemented! //TODO delete when boundingbox is implemented!
@@ -87,4 +91,14 @@ namespace entities
is_playing = false; is_playing = false;
std::cout << "collision" << std::endl; std::cout << "collision" << std::endl;
} }
double MainCharacter::UpdateDelta()
{
double current_time = glfwGetTime();
static double last_frame_time = current_time;
double delt_time = current_time - last_frame_time;
last_frame_time = current_time;
return delt_time;
}
} }

View File

@@ -10,8 +10,8 @@ namespace entities
* This class contains the information about the player model * This class contains the information about the player model
*/ */
class MainCharacter : public CollisionEntity { class MainCharacter : public CollisionEntity {
const float SIDE_SPEED = 0.8f; //Standard movement speed for left/right movement const int SIDE_SPEED = 40; //Standard movement speed for left/right movement
const float UP_SPEED = 2.0f; //Standard movement speed for up movement const int UP_SPEED = 100; //Standard movement speed for up movement
public: public:
/* /*
* @brief: Constructor for the main character model * @brief: Constructor for the main character model
@@ -35,5 +35,7 @@ namespace entities
void Move(std::vector<computervision::HandDetectRegion*> regions); void Move(std::vector<computervision::HandDetectRegion*> regions);
void OnCollide(const collision::Collision& collision) override; void OnCollide(const collision::Collision& collision) override;
double UpdateDelta();
}; };
} }

View File

@@ -62,7 +62,7 @@ namespace scene
score = 0; score = 0;
} }
/** /**
* temporary!!!! * temporary?
* just to make some bounding boxes * just to make some bounding boxes
*/ */
collision::Box create_bounding_box(glm::vec3 size, glm::vec3 pos, int scale) { collision::Box create_bounding_box(glm::vec3 size, glm::vec3 pos, int scale) {