orbit
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
|
||||
#include "utils/Renderer/Renderer.h"
|
||||
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
class RubiksCube {
|
||||
|
||||
public:
|
||||
@@ -34,12 +37,65 @@ class RubiksCube {
|
||||
for(int i = 0; i < blocks.size(); i++) {
|
||||
blocks.at(i) = Archimedes::Body(rt);
|
||||
blocks.at(i).moveTo(positions.at(i));
|
||||
blocks.at(i).scaleTo(0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Archimedes::Body> getBlocks() { return blocks; }
|
||||
|
||||
enum class Direction {
|
||||
X, Y, Z
|
||||
};
|
||||
|
||||
enum class Plate {
|
||||
Top = 1, Middle = 0, Bottom = -1
|
||||
};
|
||||
|
||||
void orbit(Archimedes::Body& body, glm::vec3 center, glm::vec3 direction, float radians) {
|
||||
glm::vec3 o = body.getPosition() - center;
|
||||
|
||||
direction = glm::normalize(glm::cross(glm::cross(o, direction), o));
|
||||
|
||||
body.setTransform(glm::rotate(body.getTransform(), radians, direction));
|
||||
}
|
||||
|
||||
std::vector<Archimedes::Body> selectPlate(Plate plate, Direction direction) {
|
||||
std::vector<Archimedes::Body> p;
|
||||
p.reserve(plate == Plate::Middle ? 8 : 9);
|
||||
switch(direction) {
|
||||
case Direction::X:
|
||||
for(auto& b : blocks) {
|
||||
|
||||
if(b.getPosition().x == (float)plate) {
|
||||
p.push_back(b);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Direction::Y:
|
||||
break;
|
||||
case Direction::Z:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void turn(Plate plate, Direction direction) {
|
||||
switch(direction) {
|
||||
case Direction::X:
|
||||
break;
|
||||
case Direction::Y:
|
||||
break;
|
||||
case Direction::Z:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void update() {}
|
||||
|
||||
private:
|
||||
std::vector<Archimedes::Body> blocks = std::vector<Archimedes::Body>(26);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user