diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-12-27 21:37:29 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2012-12-27 21:37:29 (GMT) |
commit | 347dc9532a342a3f9a93f2f3f7baf3057e0920b8 (patch) | |
tree | b3a678ec9e4b0ee0315b9bfd76a1dc89bcedae0c /src | |
parent | 7b8da7c5b88714f8b4892c83703c16b19a6cb80d (diff) | |
download | uscxml-347dc9532a342a3f9a93f2f3f7baf3057e0920b8.zip uscxml-347dc9532a342a3f9a93f2f3f7baf3057e0920b8.tar.gz uscxml-347dc9532a342a3f9a93f2f3f7baf3057e0920b8.tar.bz2 |
Support for rad, deg and % in rotation
Diffstat (limited to 'src')
-rw-r--r-- | src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp index 5c3dfef..2712be3 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp @@ -147,18 +147,43 @@ void OSGInvoker::processRotation(const Arabica::DOM::Node<std::string>& element) assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::Node* node = _nodes[element.getParentNode()]; - double x = 0, y = 0, z = 0, angle = 0; - if (HAS_ATTR(element, "x")) - x = strTo<float>(ATTR(element, "x")); - if (HAS_ATTR(element, "y")) - y = strTo<float>(ATTR(element, "y")); - if (HAS_ATTR(element, "z")) - z = strTo<float>(ATTR(element, "z")); - if (HAS_ATTR(element, "angle")) - z = strTo<float>(ATTR(element, "angle")); + double pitch = 0, roll = 0, yaw = 0; + if (HAS_ATTR(element, "pitch")) { + NumAttr pitchAttr = NumAttr(ATTR(element, "pitch")); + if (boost::iequals(pitchAttr.unit, "deg")) { + pitch = osg::DegreesToRadians(strTo<float>(pitchAttr.value)); + } else if (boost::iequals(pitchAttr.unit, "%")) { + pitch = osg::DegreesToRadians((strTo<float>(pitchAttr.value) * 360) / 100); + } else { + pitch = strTo<float>(pitchAttr.value); + } + } + if (HAS_ATTR(element, "roll")) { + NumAttr rollAttr = NumAttr(ATTR(element, "roll")); + if (boost::iequals(rollAttr.unit, "deg")) { + roll = osg::DegreesToRadians(strTo<float>(rollAttr.value)); + } else if (boost::iequals(rollAttr.unit, "%")) { + roll = osg::DegreesToRadians((strTo<float>(rollAttr.value) * 360) / 100); + } else { + roll = strTo<float>(rollAttr.value); + } + } + if (HAS_ATTR(element, "yaw")) { + NumAttr yawAttr = NumAttr(ATTR(element, "yaw")); + if (boost::iequals(yawAttr.unit, "deg")) { + yaw = osg::DegreesToRadians(strTo<float>(yawAttr.value)); + } else if (boost::iequals(yawAttr.unit, "%")) { + yaw = osg::DegreesToRadians((strTo<float>(yawAttr.value) * 360) / 100); + } else { + yaw = strTo<float>(yawAttr.value); + } + } osg::Matrix rotation; - rotation.makeRotate(angle, x, y, z); + rotation.makeRotate(roll, osg::Vec3(0,1,0), // roll + pitch, osg::Vec3(1,0,0) , // pitch + yaw, osg::Vec3(0,0,1) ); // heading + osg::MatrixTransform* transform = new osg::MatrixTransform(); transform->setMatrix(rotation); |