Skip to content
Snippets Groups Projects
Commit f7a08bfb authored by Martin Štourač's avatar Martin Štourač
Browse files

applied name conv. to control, ebo, frame

parent 2ab7fc66
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,11 @@ public:
void setStep(float dt);
float getSpeed() const { return speed; }
void setSpeed(float new_speed);
void setSpeed(float _speed);
void teleport(glm::vec3 new_position) { bound_frame->setPosVec(new_position); }
void keyboard_move(const std::unordered_set<std::string> &pressed_keys);
void keyboardMove(const std::unordered_set<std::string> &pressed_keys);
void forward();
void backward();
void left();
......
......@@ -12,10 +12,11 @@ class EBO
public:
EBO();
~EBO();
void Bind();
void Unbind();
void Delete();
void SendData(std::vector<unsigned int> const &indices);
void bind();
void unbind();
void deleteBuffer();
void sendData(std::vector<unsigned int> const &indices);
};
......
......@@ -12,48 +12,48 @@
class Frame
{
glm::vec3 positionVec;
glm::quat rotationQuat;
glm::vec3 scaleVec;
glm::vec3 position_vec;
glm::quat rotation_quat;
glm::vec3 scale_vec;
public:
Frame(glm::vec3 position = glm::vec3(0, 0, 0),
glm::vec3 rotation = glm::vec3(0, 0, 0),
glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f))
: positionVec{position}, scaleVec(scale)
Frame(glm::vec3 _position_vec = glm::vec3(0, 0, 0),
glm::vec3 rotation_vec = glm::vec3(0, 0, 0),
glm::vec3 _scale_vec = glm::vec3(1.0f, 1.0f, 1.0f))
: position_vec{_position_vec}, scale_vec{_scale_vec}
{
setRotationQuat(rotation);
setRotationQuat(rotation_vec);
}
Frame(glm::vec3 position,
glm::quat rotation,
glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f))
: positionVec{position}, rotationQuat{glm::normalize(rotation)}, scaleVec(scale) {}
Frame(glm::vec3 _position_vec,
glm::quat _rotation_quat,
glm::vec3 _scale_vec = glm::vec3(1.0f, 1.0f, 1.0f))
: position_vec{_position_vec}, rotation_quat{glm::normalize(_rotation_quat)}, scale_vec(_scale_vec) {}
glm::vec3 getPosition() const { return positionVec; }
glm::quat getRotation() const { return rotationQuat; }
glm::vec3 getScale() const { return scaleVec; }
glm::vec3 getPosition() const { return position_vec; }
glm::quat getRotation() const { return rotation_quat; }
glm::vec3 getScale() const { return scale_vec; }
glm::vec3 getRotationAxisX() const { return glm::normalize(glm::column(glm::toMat3(rotationQuat), 0)); }
glm::vec3 getRotationAxisY() const { return glm::normalize(glm::column(glm::toMat3(rotationQuat), 1)); }
glm::vec3 getRotationAxisZ() const { return glm::normalize(glm::column(glm::toMat3(rotationQuat), 2)); }
glm::vec3 getRotationAxisX() const { return glm::normalize(glm::column(glm::toMat3(rotation_quat), 0)); }
glm::vec3 getRotationAxisY() const { return glm::normalize(glm::column(glm::toMat3(rotation_quat), 1)); }
glm::vec3 getRotationAxisZ() const { return glm::normalize(glm::column(glm::toMat3(rotation_quat), 2)); }
glm::mat4 getTranslationMat() const { return glm::translate(glm::mat4(1.0f), positionVec); }
glm::mat4 getRotationMat() const { return glm::toMat4(rotationQuat); }
glm::mat4 getScaleMat() const { return glm::scale(glm::mat4(1.0f), scaleVec); }
glm::mat4 getTranslationMat() const { return glm::translate(glm::mat4(1.0f), position_vec); }
glm::mat4 getRotationMat() const { return glm::toMat4(rotation_quat); }
glm::mat4 getScaleMat() const { return glm::scale(glm::mat4(1.0f), scale_vec); }
glm::mat4 getModelMat() const { return getTranslationMat() * getRotationMat() * getScaleMat(); }
glm::mat4 getViewMat() const { return glm::inverse(getModelMat()); }
void setPosVec(glm::vec3 new_position) { positionVec = new_position; }
void translatePosVec(glm::vec3 direction) { positionVec += direction; }
void setRotationQuat(glm::vec3 new_rotation) { rotationQuat = glm::normalize(glm::tquat(glm::radians(new_rotation))); }
void setRotationQuat(glm::quat new_rotation) { rotationQuat = glm::normalize(new_rotation); }
void rotateRotationQuat(glm::vec3 rotation) { rotationQuat = glm::normalize(glm::tquat(glm::radians(rotation)) * rotationQuat); }
void rotateRotationQuat(glm::quat rotation) { rotationQuat = glm::normalize(rotation * rotationQuat); }
void setScale(glm::vec3 new_scale) { scaleVec = new_scale; }
void setPosVec(glm::vec3 _position_vec) { position_vec = _position_vec; }
void translatePosVec(glm::vec3 direction) { position_vec += direction; }
void setRotationQuat(glm::vec3 rotation_vec) { rotation_quat = glm::normalize(glm::tquat(glm::radians(rotation_vec))); }
void setRotationQuat(glm::quat _rotation_quat) { rotation_quat = glm::normalize(_rotation_quat); }
void rotateRotationQuat(glm::vec3 added_rotation) { rotation_quat = glm::normalize(glm::tquat(glm::radians(added_rotation)) * rotation_quat); }
void rotateRotationQuat(glm::quat added_rotation) { rotation_quat = glm::normalize(added_rotation * rotation_quat); }
void setScale(glm::vec3 _scale_vec) { scale_vec = _scale_vec; }
void normalizeQuat() { rotationQuat = glm::normalize(rotationQuat); }
void normalizeQuat() { rotation_quat = glm::normalize(rotation_quat); }
};
#endif
\ No newline at end of file
......@@ -4,9 +4,9 @@ void Controller::setStep(float dt)
{
step = speed * dt;
}
void Controller::setSpeed(float new_speed)
void Controller::setSpeed(float _speed)
{
speed = new_speed;
speed = _speed;
}
void Controller::setup(float dt, frame_ptr frame)
......@@ -15,7 +15,7 @@ void Controller::setup(float dt, frame_ptr frame)
setStep(dt);
}
void Controller::keyboard_move(const std::unordered_set<std::string> &pressed_keys)
void Controller::keyboardMove(const std::unordered_set<std::string> &pressed_keys)
{
if (pressed_keys.contains("W"))
forward();
......
......@@ -10,23 +10,23 @@ EBO::EBO()
EBO::~EBO()
{
Delete();
deleteBuffer();
}
void EBO::Bind()
void EBO::bind()
{
ASSUMPTION(ID != 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
ASSUMPTION(glGetError() == GL_NO_ERROR);
}
void EBO::Unbind()
void EBO::unbind()
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
ASSUMPTION(glGetError() == GL_NO_ERROR);
}
void EBO::Delete()
void EBO::deleteBuffer()
{
if (ID != 0)
{
......@@ -36,7 +36,7 @@ void EBO::Delete()
}
}
void EBO::SendData(std::vector<unsigned int> const &indices)
void EBO::sendData(std::vector<unsigned int> const &indices)
{
ASSUMPTION(ID != 0);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned int), &indices.front(), GL_STATIC_DRAW);
......
......@@ -63,8 +63,8 @@ void VAO::BindNormals()
void VAO::BindIndices()
{
_EBO = std::make_shared<EBO>();
_EBO->Bind();
_EBO->SendData(indices);
_EBO->bind();
_EBO->sendData(indices);
}
void VAO::BindBuffers()
......
......@@ -328,13 +328,13 @@ void Simulator::process_input()
for (auto &controller : obj_controls)
{
controller->setup(timer().dt(), selection->getFrame());
controller->keyboard_move(keyboard().down());
controller->keyboardMove(keyboard().down());
}
}
else
{
cam_controls[active_camera_type]->setStep(timer().dt());
cam_controls[active_camera_type]->keyboard_move(keyboard().down());
cam_controls[active_camera_type]->keyboardMove(keyboard().down());
}
int fill_mode = keyboard().down().contains("X") ? GL_LINE : GL_FILL; // MTO DO: put elsewhere
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment