Re: [osg-users] osgWidget for drawing control panels

2013-09-12 Thread Alberto Luaces
Alberto Luaces writes:

 Hi,

 I am in the process of creating a control panel for a simulator, using
 osgWidget for drawing the controls.

 I want to draw a turning knob, but it is not very clear how to specify
 the origin for the rotation of the widget.  By default, all the widgets
 rotate over (0, 0), that is, their bottom-left corner.

 Has anyone developed a widget similar to a compass or a speedometer with
 osgWidget?

This is what I eventually got — subclassing the window and overwriting
the transform to fit my needs:

--8---cut here---start-8---
class window_pivot_center: public osgWidget::Box
{
public:
  window_pivot_center(const std::string name): osgWidget::Box(name)
  {}

  void update()
  {
osgWidget::Box::update();

osgWidget::point_type w, h;

w = getWidth();
h = getHeight();

osg::Matrix t = osg::Matrix::translate(-w/2, -h/2, 0);
osg::Matrix r = osg::Matrix::rotate(osg::DegreesToRadians(getRotate()), 0, 
0, 1);
osg::Matrix tinv = osg::Matrix::translate(w/2, h/2, 0);

osgWidget::Point p = getPosition();
osg::Matrix pos = osg::Matrix::translate(p[0], p[1], 0);

setMatrix(t * r * tinv * pos);

  }
};
--8---cut here---end---8---


-- 
Alberto

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgWidget for drawing control panels

2013-09-10 Thread Alberto Luaces
Hi,

I am in the process of creating a control panel for a simulator, using
osgWidget for drawing the controls.

I want to draw a turning knob, but it is not very clear how to specify
the origin for the rotation of the widget.  By default, all the widgets
rotate over (0, 0), that is, their bottom-left corner.

Has anyone developed a widget similar to a compass or a speedometer with
osgWidget?

Thanks,

-- 
Alberto

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org