Compare commits
1 Commits
ff5f262883
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 13f84fc9bc |
@@ -73,7 +73,7 @@ void Rubiks::onLoad() {
|
||||
|
||||
void Rubiks::run() {
|
||||
|
||||
static float scale = 1.0f, scalePrev = 1.0f;
|
||||
static float scale = 0.8f, scalePrev = 1.0f;
|
||||
|
||||
static glm::vec3 pos(0), rot(0);
|
||||
static glm::vec3 posPrev(0), rotPrev(0);
|
||||
@@ -98,6 +98,7 @@ void Rubiks::run() {
|
||||
camRotPrev = camRot;
|
||||
|
||||
for(auto& b : rubiksCube.getBlocks()) {
|
||||
b.scaleTo(scale);
|
||||
window->getRenderer()->draw(
|
||||
b.getMesh(),
|
||||
b.getTransform(),
|
||||
|
||||
@@ -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