diff --git a/src/edit/src/editor.cpp b/src/edit/src/editor.cpp index b339c03641b5eb7fd282e9e9123775b5aaad9ec1..893e7eddfb69479beda21a73b98b0609dec4178d 100644 --- a/src/edit/src/editor.cpp +++ b/src/edit/src/editor.cpp @@ -1197,13 +1197,13 @@ void Editor::generatePad(std::size_t &width, std::size_t &height) float x_pos = static_cast<float>(x); float y_pos = static_cast<float>(y); - auto open_con_node = Node::create(glm::vec3(x_pos, y_pos, 0.0f), get_connector_face_rotation(glm::vec3(0.0f, 0.0f, -1.0f))); + auto open_con_node = Node::create(glm::vec3(x_pos, y_pos, -0.5f), get_connector_face_rotation(glm::vec3(0.0f, 0.0f, -1.0f))); open_con_node->rotateRotationQuat(glm::rotation(open_con_node->getRotationAxisXLocal(), glm::vec3(0.0f, 1.0f, 0.0f))); auto open_connector = module_type_voxel_graphs[pad]->addConnector(open_con_node, connector_type::open); addConnectorMesh(open_con_node, connector_type::fixed); open_con_node->addObject(open_connector); - auto pad_board_node = Node::create(glm::vec3(x_pos, y_pos, 0.5f), glm::angleAxis(glm::radians(90.0f), glm::vec3(-1.0f, 0.0f, 0.0f))); + auto pad_board_node = Node::create(glm::vec3(x_pos, y_pos, 0.0f), glm::angleAxis(glm::radians(90.0f), glm::vec3(-1.0f, 0.0f, 0.0f))); auto pad_board = module_type_voxel_graphs[pad]->addPadBoard(pad_board_node); scene->addMesh(pad_board_node, pad_board_mesh); pad_board_node->addObject(pad_board); diff --git a/src/filein/src/module_loader.cpp b/src/filein/src/module_loader.cpp index af1b500e46035078848997f0462dbdc8e0707ac0..829c38f5a5de0efa894b1e37dd4d15d0e6422a78 100644 --- a/src/filein/src/module_loader.cpp +++ b/src/filein/src/module_loader.cpp @@ -747,11 +747,11 @@ voxel_graph_ptr import_pad(const boost::json::array &components_array, const boo float x_pos = static_cast<float>(x); float y_pos = static_cast<float>(y); - auto open_con_node = Node::create(glm::vec3(x_pos, y_pos, 0.0f), get_connector_face_rotation(glm::vec3(0.0f, 0.0f, -1.0f))); + auto open_con_node = Node::create(glm::vec3(x_pos, y_pos, -0.5f), get_connector_face_rotation(glm::vec3(0.0f, 0.0f, -1.0f))); open_con_node->rotateRotationQuat(glm::rotation(open_con_node->getRotationAxisXLocal(), glm::vec3(0.0f, 1.0f, 0.0f))); auto open_connector = vg->addConnector(open_con_node, connector_type::open); - auto pad_board_node = Node::create(glm::vec3(x_pos, y_pos, 0.5f), glm::angleAxis(glm::radians(90.0f), glm::vec3(-1.0f, 0.0f, 0.0f))); + auto pad_board_node = Node::create(glm::vec3(x_pos, y_pos, 0.0f), glm::angleAxis(glm::radians(90.0f), glm::vec3(-1.0f, 0.0f, 0.0f))); auto pad_board = vg->addPadBoard(pad_board_node); vg->join(open_connector, pad_board, enum_to_vec(side::y_pos)); diff --git a/src/filein/src/rofiworld_loader.cpp b/src/filein/src/rofiworld_loader.cpp index 060e3c82cfa8829e213908ce1c53f2865986c9be..f0b98099ee83a22d5f95fd8eaa2d3230146bba45 100644 --- a/src/filein/src/rofiworld_loader.cpp +++ b/src/filein/src/rofiworld_loader.cpp @@ -427,12 +427,12 @@ module_ptr import_pad(const uint64_t width, const uint64_t height) float x_pos = static_cast<float>(x); float y_pos = static_cast<float>(y); - auto open_con_node = Node::create(glm::vec3(x_pos, y_pos, 0.0f), get_connector_face_rotation(glm::vec3(0.0f, 0.0f, -1.0f))); + auto open_con_node = Node::create(glm::vec3(x_pos, y_pos, -0.5f), get_connector_face_rotation(glm::vec3(0.0f, 0.0f, -1.0f))); open_con_node->rotateRotationQuat(glm::rotation(open_con_node->getRotationAxisXLocal(), glm::vec3(0.0f, 1.0f, 0.0f))); auto open_connector = vg->addConnector(open_con_node, connector_type::open); component_ids.emplace(open_connector, id_counter); - auto pad_board_node = Node::create(glm::vec3(x_pos, y_pos, 0.5f), glm::angleAxis(glm::radians(90.0f), glm::vec3(-1.0f, 0.0f, 0.0f))); + auto pad_board_node = Node::create(glm::vec3(x_pos, y_pos, 0.0f), glm::angleAxis(glm::radians(90.0f), glm::vec3(-1.0f, 0.0f, 0.0f))); auto pad_board = vg->addPadBoard(pad_board_node); vg->join(open_connector, pad_board, enum_to_vec(side::y_pos)); @@ -503,12 +503,19 @@ void import_spaceJoint_joint(rofiworld_ptr rofiworld, const module_ptr module, c const auto editor_rotation_mat = convert_to_editor_import_coordinates(rofi_rotation_mat); - // TO DO rotate somehow + const auto root_connector = std::dynamic_pointer_cast<rofi::Connector>(module->getComponentByID(0)); + ASSUMPTION(root_connector); - // const auto root_connector = std::dynamic_pointer_cast<rofi::Connector>(module->getComponentByID(0)); - // ASSUMPTION(root_connector); - // rofiworld->rebuildNodeTree(module, root_connector->getNode()); - // root_connector->getNode()->setRotationQuat(editor_rotation_mat); + auto node = root_connector->getNode(); + glm::mat4 mat = editor_rotation_mat; + while (!node->getParent().expired()) + { + mat = mat * glm::inverse(node->getModelMatLocal()); + node = node->getParent().lock(); + } + + rofiworld->rebuildNodeTree(module, module->getNode()); + module->getNode()->setRotationQuat(mat); }