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

add dock notations to module

parent 9142facf
No related branches found
No related tags found
No related merge requests found
......@@ -46,13 +46,16 @@ node_ptr find_node_with_rofi_object(const std::vector<node_ptr> &nodes, objectba
glm::quat get_connector_face_rotation(glm::vec3 local_direction)
{
ASSUMPTION(glm::length(local_direction) == 1.0f);
// if (rofi::vec_to_enum(local_direction) == rofi::side::z_neg)
// return glm::angleAxis(glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));
return glm::rotation(rofi::enum_to_vec(rofi::side::z_neg), local_direction);
}
glm::quat get_shared_voxel_face_rotation(glm::vec3 local_direction)
{
ASSUMPTION(glm::length(local_direction) == 1.0f);
return glm::rotation(rofi::enum_to_vec(rofi::side::z_neg), -local_direction);
return glm::rotation(rofi::enum_to_vec(rofi::side::z_neg), -local_direction); //* glm::angleAxis(glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f));
}
bool face_each_other(node_ptr fst_node, node_ptr snd_node, glm::vec3 axis)
......
......@@ -85,7 +85,7 @@ void Scene::createScene()
/* ADD CAMERA */
auto camera_node = addCameraNode(60.0f, glm::vec3(0.0f, 0.0f, 5.0f), glm::vec3(0.0f, 0.0f, 0.0f));
auto rot = glm::angleAxis(glm::radians(45.0f), glm::vec3(0.0f, 1.0f, 0.0f));
auto rot = glm::angleAxis(glm::radians(-45.0f), glm::vec3(0.0f, 1.0f, 0.0f));
camera_node->translatePosVec(glm::toMat4(rot));
camera_node->rotateRotationQuat(rot);
auto rot2 = glm::angleAxis(glm::radians(-20.0f), camera_node->getRotationAxisXLocal());
......
......@@ -23,9 +23,13 @@ class Module
std::string name;
std::string type;
// uint64_t module_id;
std::map<uint64_t, objectbase_ptr> component_ids;
std::map<connector_ptr, std::string> connector_docks;
void makeNodeTree();
void setConnectorDocks();
Module(const Module &other);
Module(const Module &&other);
......@@ -45,6 +49,11 @@ public:
const std::string &getName() const { return name; }
const std::string &getType() const { return type; }
const std::map<uint64_t, objectbase_ptr> &getComponentIDs() const { return component_ids; }
const std::map<connector_ptr, std::string> &getConnectorDocks() const { return connector_docks; }
const objectbase_ptr &getComponentByID(uint64_t id) const { return component_ids.at(id); }
const std::string &getConnectorDock(connector_ptr connector) const { return connector_docks.at(connector); }
};
}
......
......@@ -11,6 +11,40 @@ void Module::makeNodeTree()
node->addChild(connector->getNode());
}
void Module::setConnectorDocks() // TO DO: change if connector placement gets changed
{
if (type != "universal")
return;
using enum side;
std::string dock;
auto a_pos = glm::vec3(0.0f);
for (const auto &connector : parts->getConnections())
{
if (connector->getType(false) == connector_type::shared_rotation)
continue;
auto con_side = connector->getVoxelSide().first;
auto voxel_pos = connector->getConnection().first.lock()->getNode()->getPositionLocal();
switch(con_side)
{
case x_neg:
dock = voxel_pos == a_pos ? "A+X" : "B+X";
break;
case x_pos:
dock = voxel_pos == a_pos ? "A-X" : "B-X";
break;
case z_neg:
dock = voxel_pos == a_pos ? "A-Z" : "B-Z";
break;
default:
ASSUMPTION(false);
}
connector_docks.emplace(connector, dock);
}
}
Module::Module(const Module &other)
{
node = Node::copy_deep(other.node);
......@@ -18,6 +52,7 @@ Module::Module(const Module &other)
name = other.name;
type = other.type;
component_ids = other.component_ids;
setConnectorDocks();
}
Module::Module(const Module &&other)
{
......@@ -26,6 +61,7 @@ Module::Module(const Module &&other)
name = std::move(other.name);
type = std::move(other.type);
component_ids = std::move(other.component_ids);
setConnectorDocks();
}
Module& Module::operator=(const Module &other)
{
......@@ -34,6 +70,7 @@ Module& Module::operator=(const Module &other)
name = other.name;
type = other.type;
component_ids = other.component_ids;
setConnectorDocks();
return *this;
}
......@@ -44,6 +81,7 @@ Module& Module::operator=(const Module &&other)
name = std::move(other.name);
type = std::move(other.type);
component_ids = std::move(other.component_ids);
setConnectorDocks();
return *this;
}
......@@ -53,6 +91,7 @@ Module::Module(voxel_graph_ptr _parts, std::string &_name, std::string &_type, s
{
ASSUMPTION(!_parts->getVoxels().empty() || !_parts->getConnections().empty());
makeNodeTree();
setConnectorDocks();
}
Module::Module(voxel_graph_ptr _parts, std::string &&_name, std::string &&_type, std::map<uint64_t, objectbase_ptr> &&_component_ids)
......@@ -60,6 +99,7 @@ Module::Module(voxel_graph_ptr _parts, std::string &&_name, std::string &&_type,
{
ASSUMPTION(!_parts->getVoxels().empty() || !_parts->getConnections().empty());
makeNodeTree();
setConnectorDocks();
}
module_ptr Module::copy(const module_ptr other_module)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment