| 229 | } |
| 230 | |
| 231 | void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const IfcGeom::Element& parent){ |
| 232 | //we open the visual scene tag if it's not. |
| 233 | if (!scene_opened) { |
| 234 | openVisualScene(scene_id); |
| 235 | scene_opened = true; |
| 236 | } |
| 237 | |
| 238 | const IfcGeom::Transformation& parent_trsf = parent.transformation(); |
| 239 | |
| 240 | auto transformation_towrite = parent_trsf.data()->ccomponents(); |
| 241 | |
| 242 | // If this is not the first parent, get the relative placement |
| 243 | if (parentNodes.size() > 0) { |
| 244 | // @todo check order |
| 245 | transformation_towrite = matrixStack.top().ccomponents() * transformation_towrite; |
| 246 | } |
| 247 | |
| 248 | const auto& posmatrix = transformation_towrite; |
| 249 | |
| 250 | double matrix_array[4][4] = { |
| 251 | { (double)posmatrix(0,0), (double)posmatrix(0,1), (double)posmatrix(0,2), (double)posmatrix(0,3) }, |
| 252 | { (double)posmatrix(1,0), (double)posmatrix(1,1), (double)posmatrix(1,2), (double)posmatrix(1,3) }, |
| 253 | { (double)posmatrix(2,0), (double)posmatrix(2,1), (double)posmatrix(2,2), (double)posmatrix(2,3) }, |
| 254 | { (double)posmatrix(3,0), (double)posmatrix(3,1), (double)posmatrix(3,2), (double)posmatrix(3,3) } |
| 255 | }; |
| 256 | |
| 257 | std::string name = serializer->object_id(&parent); |
| 258 | collada_id(name); |
| 259 | |
| 260 | COLLADASW::Node *current_node; |
| 261 | current_node = new COLLADASW::Node(mSW); |
| 262 | current_node->setNodeId(name); |
| 263 | /// @todo redundant information using ID as both ID and Name, maybe omit Name or allow specifying what would be used as the name |
| 264 | current_node->setNodeName(name); |
| 265 | current_node->setType(COLLADASW::Node::NODE); |
| 266 | current_node->start(); |
| 267 | current_node->addMatrix(matrix_array); |
| 268 | |
| 269 | // Add the node to the parent stack |
| 270 | matrixStack.push(ifcopenshell::geometry::taxonomy::matrix4(parent_trsf.data()->ccomponents().inverse())); |
| 271 | parentNodes.push(current_node); |
| 272 | serializer->parentStackId.push(parent.id()); |
| 273 | } |
| 274 | |
| 275 | void ColladaSerializer::ColladaExporter::ColladaScene::closeParent() |
| 276 | { |