MCPcopy Create free account
hub / github.com/RenderKit/embree / loadTransformNode

Method loadTransformNode

tutorials/common/scenegraph/xml_loader.cpp:1549–1590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1547 }
1548
1549 Ref<SceneGraph::Node> XMLLoader::loadTransformNode(const Ref<XML>& xml)
1550 {
1551 /* parse number of time steps to use for instanced geometry */
1552 int time_steps = 1;
1553 std::string str_time_steps = xml->parm("time_steps");
1554 if (str_time_steps != "") time_steps = max(1,std::stoi(str_time_steps));
1555
1556 bool quaternion = false;
1557 AffineSpace3ff space;
1558 avector<AffineSpace3ff> spaces(time_steps);
1559 size_t j = 0;
1560 for (size_t i=0; i<time_steps; i++) {
1561 AffineSpace3ff space;
1562 if (xml->children[i]->name == "AffineSpace") {
1563 space = (AffineSpace3ff) load<AffineSpace3fa>(xml->children[i]);
1564 spaces[j++] = space;
1565 }
1566 else if (xml->children[i]->name == "Quaternion") {
1567 space = loadQuaternion(xml->children[i]);
1568 quaternion = true;
1569 spaces[j++] = space;
1570 }
1571 else {
1572 THROW_RUNTIME_ERROR(xml->loc.str()+": unknown transformation representation");
1573 }
1574 }
1575 assert(j == time_steps);
1576
1577 if (xml->size() == time_steps+1) {
1578 auto node = new SceneGraph::TransformNode(spaces,loadNode(xml->children[time_steps]));
1579 node->spaces.quaternion = quaternion;
1580 return node;
1581 }
1582
1583 Ref<SceneGraph::GroupNode> group = new SceneGraph::GroupNode;
1584 for (size_t i=time_steps; i<xml->size(); i++)
1585 group->add(loadNode(xml->children[i]));
1586
1587 auto node = new SceneGraph::TransformNode(spaces,group.dynamicCast<SceneGraph::Node>());
1588 node->spaces.quaternion = quaternion;
1589 return node;
1590 }
1591
1592 Ref<SceneGraph::Node> XMLLoader::loadMultiTransformNode(const Ref<XML>& xml)
1593 {

Callers

nothing calls this directly

Calls 5

parmMethod · 0.80
maxFunction · 0.50
strMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected