summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-12-27 21:37:29 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2012-12-27 21:37:29 (GMT)
commit347dc9532a342a3f9a93f2f3f7baf3057e0920b8 (patch)
treeb3a678ec9e4b0ee0315b9bfd76a1dc89bcedae0c
parent7b8da7c5b88714f8b4892c83703c16b19a6cb80d (diff)
downloaduscxml-347dc9532a342a3f9a93f2f3f7baf3057e0920b8.zip
uscxml-347dc9532a342a3f9a93f2f3f7baf3057e0920b8.tar.gz
uscxml-347dc9532a342a3f9a93f2f3f7baf3057e0920b8.tar.bz2
Support for rad, deg and % in rotation
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp45
-rw-r--r--test/samples/uscxml/test-scenegraph.scxml2
2 files changed, 36 insertions, 11 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);
diff --git a/test/samples/uscxml/test-scenegraph.scxml b/test/samples/uscxml/test-scenegraph.scxml
index e159fdd..25e13ed 100644
--- a/test/samples/uscxml/test-scenegraph.scxml
+++ b/test/samples/uscxml/test-scenegraph.scxml
@@ -16,7 +16,7 @@
</scenegraph:translation>
</scenegraph:viewport>
<scenegraph:viewport x="0" y="50%" width="50%" height="50%" id="scene3">
- <scenegraph:rotation angle="2.0" x="100" y="1" z="1">
+ <scenegraph:rotation pitch="100deg" roll="3.15149rad" yaw="10deg">
<scenegraph:node src="http://cs.iupui.edu/~aharris/webDesign/vrml/tree.wrl" />
</scenegraph:rotation>
</scenegraph:viewport>