[osg-users] OSG Architecture

2013-07-31 Thread Sujan Dasmahapatra
Hi,

Please tell me if my understanding is correct?If create a Geode called 
'room' and inherit a node from room called 'sofa'. So room-sofa. Then if we 
rotate room, would the sofa also rotate,?. But if we rotate sofa then room 
should not rotate.How can we establish an architecture like that?...Is it 
possible in OSG?..Please help.

... 

Thank you!

Cheers,
sujan

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53900#53900





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


[osg-users] Model not scene

2013-05-27 Thread Sujan Dasmahapatra
I am using OSG with QT..Made the OSG viewer in QWidget Layout as
QGridLayout. My model is vanished, not seen. Please tell me what I am doing
wrong.

For creatting the view in Qt my code is below


CSGroup* root = new CSGroup();
ViewerWidget* viewWidget = new
ViewerWidget(m_Modelling_Designs-m_TabWidget-widget(0), root, fileName) ;
QGridLayout *layoutForModel = new QGridLayout;
layoutForModel-addWidget(viewWidget);
m_Modelling_Designs-m_TabWidget-widget(0)-setLayout(layoutForModel);
viewWidget-show();


For adding model into scene snippet is below.
///
osg::ref_ptrosg::Node axes =
osgDB::readNodeFile(C:\\SUJAN_C_DRIVE\\OSG_DATA\\OpenSceneGraph-Data-3.0.0\\axes.osgt);
 scene-addChild( axes);

  gView = (CSGraphicsView*) (addViewWidget(
createCamera(0,0,-0.5,0.5), scene ));

  QGridLayout* grid = new QGridLayout;
  grid-addWidget( gView, 0, 0 );
   setLayout( grid );
///

Please help why my model is not appearing. Thanks in advance.

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


Re: [osg-users] Translate problem

2013-05-09 Thread Sujan Dasmahapatra
Dear Nick thanks a lot for your code snippet. I appreciate it. I am after
custom mouse event handling, I dont want TrackBallManipulator as I am more
interested to manage events from Qt.


On Thu, May 9, 2013 at 2:35 PM, Trajce Nikolov NICK 
trajce.nikolov.n...@gmail.com wrote:

 Hi Sujan,

 viewerWid-getView()-getCamera()-setViewMatrix(::osg::Matrix::translate(1000.5,
 0.0, 0.0));
 this code is wrong. Also, you have attached TrackballCameraManipulator so
 it will fight you against the translation you do.

 If you want to translate an object in the scene, then use
 osg::MatrixTransofrm as parent of your object and there set the
 translation. If you want to change the ViewMatrix, then set the inverse of
 your world translation, but also update the CameraManipulator, so something
 like:

 osg::Matrixd myMatrix = osg::Matrix::translate(1000.5, 0.0, 0.0);
 viewerWid-getView()-
 getCamera()-setViewMatrix(osg::Matrix::inverse(myMatrix));
 viewerWid-getView()-getCameraManipulator()-setByMatrix(myMatrix);

 If you are after custom mouse management, then I would inherit from
 TrackballcameraManipulator and override handle - look in the code od
 TrackballCameraManipulator::handle since it is the closest to your wish of
 mouse handling

 Hope this helps a bit

 Nick


 On Thu, May 9, 2013 at 4:09 AM, Sujan Dasmahapatra 
 sujan.dasmahapa...@gmail.com wrote:

 I am trying to translate my objects in scene, when the right mouse button
 is pressed. But it is not moving. Pls check the snippet.

 [code]
 //CSGraphicsView
 //.h
 class CSGraphicsView : public osgQt::GLWidget
 {
 Q_OBJECT
 public:
 CSGraphicsView(QWidget* parent=0);
  ~CSGraphicsView();
 virtual void mousePressEvent(QMouseEvent *e);
 virtual void mouseReleaseEvent(QMouseEvent *e);
  virtual void mouseMoveEvent(QMouseEvent *e);

 };

 #endif // GVIEW_H
 .cpp
 void CSGraphicsView::mousePressEvent(QMouseEvent *e)
 {
 if(e-button()==Qt::LeftButton)
 {
  QMessageBox msg;
 msg.setText(Left Mouse pressed);
 msg.exec();
  }
 else if(e-button()==Qt::RightButton)
 {
  //QMessageBox msg;
 //msg.setText(Right Mouse pressed);
 //msg.exec();

 ViewerWidget* viewerWid = qobject_castViewerWidget*(parent());
 viewerWid-getView()-getCamera()-setViewMatrix(::osg::Matrix::translate(1000.5,
 0.0, 0.0));
  }
 else if(e-button()==Qt::MiddleButton)
 {
  QMessageBox msg;
 msg.setText(Middle Mouse pressed);
 msg.exec();
  }
 else
 return;
 }


 
 //This is my ViewerWidget class

 class ViewerWidget : public QWidget, public osgViewer::CompositeViewer
 {
 Q_OBJECT
 public:
 ViewerWidget(osgViewer::ViewerBase::ThreadingModel
 threadingModel=osgViewer::CompositeViewer::SingleThreaded, osg::Group*
 scene=NULL);

 osgQt::GLWidget* addViewWidget( osg::Camera* camera, osg::Group* scene );

 osg::Camera* createCamera( int x, int y, int w, int h, const std::string
 name=, bool windowDecoration=false );

 virtual void paintEvent( QPaintEvent* event );

 osgViewer::View* getView();

 protected:

 QTimer _timer;

 osgQt::GraphicsWindowQt* gw;

 CSGraphicsView*  gView;

 osgViewer::View* view;
 };

 #endif // VIEWERWIDGET_H

 //viewerwidget.cpp

 ViewerWidget::ViewerWidget(osgViewer::ViewerBase::ThreadingModel
 threadingModel, osg::Group* scene) : QWidget()
 {
 setThreadingModel(threadingModel);

 gView = (CSGraphicsView*) (addViewWidget(
 createCamera(0,0,100,100), scene ));

 QGridLayout* grid = new QGridLayout;
 grid-addWidget( gView, 0, 0 );
  setLayout( grid );

 connect( _timer, SIGNAL(timeout()), this, SLOT(update()) );
 _timer.start( 10 );
 }

 osgQt::GLWidget* ViewerWidget::addViewWidget( osg::Camera* camera,
 osg::Group* scene )
 {
 view = new osgViewer::View;
 view-setCamera( camera );
 addView( view );
 view-setSceneData( scene );
  view-addEventHandler( new osgViewer::StatsHandler );
 view-setCameraManipulator( new osgGA::TrackballManipulator );
 osg::ref_ptrosgGA::StateSetManipulator statesetManipulator = new
 osgGA::StateSetManipulator(view-getCamera()-getStateSet());
  view-addEventHandler(statesetManipulator.get());
 gw = dynamic_castosgQt::GraphicsWindowQt* (
 camera-getGraphicsContext() );
 return gw ? gw-getGLWidget() : NULL;
 }


 osg::Camera* ViewerWidget::createCamera( int x, int y, int w, int h,
 const std::string name, bool windowDecoration )
 {
 gView = new CSGraphicsView(this);
 gView-setGeometry(x, y, w, h);
  osg::DisplaySettings* ds =
 osg::DisplaySettings::instance().get();
 osg::ref_ptrosg::GraphicsContext::Traits traits = new
 osg::GraphicsContext::Traits;

 traits-inheritedWindowData = new osgQt::GraphicsWindowQt::WindowData(
 gView );
 traits-windowName = name;
 traits-windowDecoration = windowDecoration;
 traits-x

[osg-users] Pan in OSG QT

2013-05-09 Thread Sujan Dasmahapatra
I am trying to implement my own pan functionality in osg scene using Qt.
Please tell me if it is right ?.But it's not happening.

Check my snippet.

void CSGraphicsView::mousePressEvent(QMouseEvent *e)
{
lastPos = e-pos();
}

void CSGraphicsView::mouseMoveEvent(QMouseEvent *e)
{
 float dx = (e-y() - lastPos.y());
 float dy = (e-x() - lastPos.x());



 const bool panFlag= ( e-buttons()  Qt::MidButton   );
 const bool rotateFlag = ( e-buttons()  Qt::LeftButton  );
 const bool zoomFlag   = ( e-buttons()  Qt::RightButton );


 if ( zoomFlag )
 {
 zoom( dy );
 }
 else if ( rotateFlag )
 {
 rotate( dx, dy );
 }
 else if ( panFlag )
 {
 pan( dx, dy );
 }

 viewer-frame();

 lastPos = e-pos();
}

void CSGraphicsView::pan( int dx, int dy )
{
viewer-getView()-getCamera()-setViewMatrix(osg::Matrix::translate(dx,dy,0));
}

//viewer is composite viewer osg
//getView() returns the osgViewer::View

//but my object is not moving what s wrong in this. please help.

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


[osg-users] for PAN problem

2013-05-09 Thread Sujan Dasmahapatra
I am trying to pan my model pls check the code snippet below.
viewer = composite view.
getTransform() will return a osg::PositionAttitudeTransform list.

But my object is moving in z direction as well inwards outwards. What am I
doing wrong please help. Thanks Sujan
void CSGraphicsView::pan( float dx, float dy )
{
osg::Vec3 transform =
viewer-getTransform()-getTrans().first()-getPosition();
transform += osg::Vec3(dx,dy,0.0f);
viewer-getTransform()-getTrans().first()-setPosition(transform);
}

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


Re: [osg-users] for PAN problem

2013-05-09 Thread Sujan Dasmahapatra
Nick I want to move the object a simple pan with mouse.


On Thu, May 9, 2013 at 5:32 PM, Trajce Nikolov NICK 
trajce.nikolov.n...@gmail.com wrote:

 Hi Sujan,

 what are you trying to do with your 'pan'? To move an object, or to move
 the camera (view) ?

 Nick


 On Thu, May 9, 2013 at 1:03 PM, Sujan Dasmahapatra 
 sujan.dasmahapa...@gmail.com wrote:

 I am trying to pan my model pls check the code snippet below.
 viewer = composite view.
 getTransform() will return a osg::PositionAttitudeTransform list.

 But my object is moving in z direction as well inwards outwards. What am
 I doing wrong please help. Thanks Sujan
  void CSGraphicsView::pan( float dx, float dy )
 {
 osg::Vec3 transform =
 viewer-getTransform()-getTrans().first()-getPosition();
  transform += osg::Vec3(dx,dy,0.0f);
 viewer-getTransform()-getTrans().first()-setPosition(transform);
 }

 --
 Thanks  Regards
 Sujan

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




 --
 trajce nikolov nick

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




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


Re: [osg-users] for PAN problem

2013-05-09 Thread Sujan Dasmahapatra
thanks a lot Nick let me try this way. thanks


On Thu, May 9, 2013 at 7:18 PM, Trajce Nikolov NICK 
trajce.nikolov.n...@gmail.com wrote:

 Hi Sujan,

 here is how I would do it:

 //Let load the model:
 osg::Node* model = osgDB:: readFile();

 // Create MatrixTransform on top of it
 osg::MatrixTransform* mxt = new osg::MatrixTransform;

 // create the scene
 mxt-addChild(model);
 viewer-setSceneData(mxt);


 Now, having it like this, by modifying the matrix in the MatrixTransofrm,
 you can move the loaded object in the scene as you are doing with
 onPan(double dx, double dy), and don;t touch the view matrix

 something like:
 void onPan(double dx, double dy)
 {
osg::MatrixTransform* mxt =
 dynamic_castosg::MatrixTransform*(viewer-getSceneData());
mxt-setMatrix(osg::Matrix::translate(1000+dx, 0, 0))
 }

 you get the idea? Hope it helps

 Nick


 On Thu, May 9, 2013 at 3:15 PM, Sujan Dasmahapatra 
 sujan.dasmahapa...@gmail.com wrote:

 Nick I want to move the object a simple pan with mouse.


 On Thu, May 9, 2013 at 5:32 PM, Trajce Nikolov NICK 
 trajce.nikolov.n...@gmail.com wrote:

 Hi Sujan,

 what are you trying to do with your 'pan'? To move an object, or to move
 the camera (view) ?

 Nick


 On Thu, May 9, 2013 at 1:03 PM, Sujan Dasmahapatra 
 sujan.dasmahapa...@gmail.com wrote:

 I am trying to pan my model pls check the code snippet below.
 viewer = composite view.
 getTransform() will return a osg::PositionAttitudeTransform list.

 But my object is moving in z direction as well inwards outwards. What
 am I doing wrong please help. Thanks Sujan
  void CSGraphicsView::pan( float dx, float dy )
 {
 osg::Vec3 transform =
 viewer-getTransform()-getTrans().first()-getPosition();
  transform += osg::Vec3(dx,dy,0.0f);
 viewer-getTransform()-getTrans().first()-setPosition(transform);
 }

 --
 Thanks  Regards
 Sujan

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org

 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




 --
 trajce nikolov nick

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




 --
 Thanks  Regards
 Sujan

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




 --
 trajce nikolov nick

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




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


[osg-users] switch off mouse press events

2013-05-08 Thread Sujan Dasmahapatra
In every example I see in the viewer that left mouse press and move cause
it to rotate 3d, middle mouse press move cause it to pan, and left mouse
press and move forward backward cause it zoom in and zoom out. How can I
override this events. For example I dont want anything to happen on my left
mouse. How can I achieve this?. Any help is highly appreciated. Thanks Sujan

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


Re: [osg-users] MousepressEvent not able to capture from osg::Viewer by Qt

2013-05-08 Thread Sujan Dasmahapatra
Thanks Robert. It is working fine...

On the left mouse press I am showing a message using QMessagBox. But on the
middle mouse press was having pan and right mouse press was having zoom in
zoom out. How can I retain those functionalities. With this these
functionalities are gone.

void CSGraphicsView::mousePressEvent(QMouseEvent *e)
{
if(e-button()==Qt::LeftButton)
{
QMessageBox msg;
msg.setText(Mouse pressed);
msg.exec();
}
}


On Wed, May 8, 2013 at 3:59 PM, Robert Milharcic 
robert.milhar...@ib-caddy.si wrote:

 On 8.5.2013 7:04, Sujan Dasmahapatra wrote:

 I am trying to implement a mouse press event with QT and OSG but unable
 to do it. Pls help.

 Below is my ViewerWidget class which is derived from QWidget and
 osg::CompositeViewer..In the constructor I got gView which is a
 osg::GLWidget, I am trying override mousePressEvent but when I click
 message not coming. What I am doing wrong pls help..

 [snip]


 osg::Camera* ViewerWidget::createCamera( int x, int y, int w, int h,
 const std::string name, bool windowDecoration )
 {
 osg::DisplaySettings* ds = osg::DisplaySettings::**
 instance().get();
 osg::ref_ptrosg::**GraphicsContext::Traits traits = new
 osg::GraphicsContext::Traits;
 traits-windowName = name;
 traits-windowDecoration = windowDecoration;
 traits-x = x;
 traits-y = y;
 traits-width = w;
 traits-height = h;
 traits-doubleBuffer = true;
 traits-alpha = ds-getMinimumNumAlphaBits();
 traits-stencil = ds-getMinimumNumStencilBits()**;
 traits-sampleBuffers = ds-getMultiSamples();
 traits-samples = ds-getNumMultiSamples();
 osg::ref_ptrosg::Camera camera = new osg::Camera;
 camera-setGraphicsContext( new 
 osgQt::GraphicsWindowQt(**traits.get())
 );
 camera-setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
 camera-setViewport( new osg::Viewport(0, 0, traits-width,
 traits-height) );
 camera-**setProjectionMatrixAsPerspecti**ve(
 30.0f, static_castdouble(traits-**
 width)/static_castdouble(**traits-height), 1.0f, 1.0f );
 return camera.release();
  }

  I don't know why this code didn't crash, I think it should. Anyway, you
 should create an instance of the CSGraphicsView somewhere within
 createCamera:

 CSGraphicsView* gView = new CSGraphicsView;
 gView-setGeometry(x, y, w, h);
 traits-inheritedWindowData = new osgQt::GraphicsWindowQt::**WindowData(
 gView );

 ...
 or you can pass an instance of the CSGraphicsView to the
 osgQt::GraphicsWindowQt constructor.


 Robert Milharcic
 __**_
 osg-users mailing list
 osg-users@lists.**openscenegraph.org osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.**org/listinfo.cgi/osg-users-**
 openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




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


Re: [osg-users] switch off mouse press events

2013-05-08 Thread Sujan Dasmahapatra
Thanks Trajce for your nice suggestions I am looking into it. Thanks a lot.


On Wed, May 8, 2013 at 4:40 PM, Trajce Nikolov NICK 
trajce.nikolov.n...@gmail.com wrote:

 Hi Sujan,

 what you are describing is the normal behavior of the Trackball
 CameraManipulator. There are many ways how you can change processing of
 mouse events. Either remove the CameraManipulator
 (view-getCamera()-setCameraManipulator(0)) or inherit from the one
 CameraMainpulator that most suit your needs and override the processing of
 the events (handle method). If you have some specifics about how to handle
 mouse and keyboard events then go for the later, I would guess

 Nick


 On Wed, May 8, 2013 at 10:05 AM, Sujan Dasmahapatra 
 sujan.dasmahapa...@gmail.com wrote:

 In every example I see in the viewer that left mouse press and move cause
 it to rotate 3d, middle mouse press move cause it to pan, and left mouse
 press and move forward backward cause it zoom in and zoom out. How can I
 override this events. For example I dont want anything to happen on my left
 mouse. How can I achieve this?. Any help is highly appreciated. Thanks Sujan

 --
 Thanks  Regards
 Sujan

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




 --
 trajce nikolov nick

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




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


Re: [osg-users] MousepressEvent not able to capture from osg::Viewer by Qt

2013-05-08 Thread Sujan Dasmahapatra
Thats right Robert. Thanks a lot for your suggestions I appreciate it.
Thanks Sujan


On Wed, May 8, 2013 at 5:40 PM, Robert Milharcic 
robert.milhar...@ib-caddy.si wrote:

  On 8.5.2013 10:16, Sujan Dasmahapatra wrote:

 Thanks Robert. It is working fine...

  On the left mouse press I am showing a message using QMessagBox. But on
 the middle mouse press was having pan and right mouse press was having zoom
 in zoom out. How can I retain those functionalities. With this these
 functionalities are gone.

  void CSGraphicsView::mousePressEvent(QMouseEvent *e)
 {
  if(e-button()==Qt::LeftButton)
  {
  QMessageBox msg;
  msg.setText(Mouse pressed);
  msg.exec();
  }
 }

  Call base class implementation in a case where you need to retain
 original functionality:

  void CSGraphicsView::mousePressEvent(QMouseEvent *e)
 {
  if(e-button()==Qt::LeftButton)
  {
  QMessageBox msg;
  msg.setText(Mouse pressed);
  msg.exec();
  }
 else
  GLWidget::mousePressEvent(e);
 }

 Also, calling frame on paintEvent might not be enough. You should also
 call frame on every user input, on all mouse and keyboard events for
 example... or you can mount a QTimer and make it call frame at some
 interval.

 Robert Milharcic

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




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


[osg-users] Translate problem

2013-05-08 Thread Sujan Dasmahapatra
I am trying to translate my objects in scene, when the right mouse button
is pressed. But it is not moving. Pls check the snippet.

[code]
//CSGraphicsView
//.h
class CSGraphicsView : public osgQt::GLWidget
{
Q_OBJECT
public:
CSGraphicsView(QWidget* parent=0);
~CSGraphicsView();
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);

};

#endif // GVIEW_H
.cpp
void CSGraphicsView::mousePressEvent(QMouseEvent *e)
{
if(e-button()==Qt::LeftButton)
{
QMessageBox msg;
msg.setText(Left Mouse pressed);
msg.exec();
}
else if(e-button()==Qt::RightButton)
{
//QMessageBox msg;
//msg.setText(Right Mouse pressed);
//msg.exec();

ViewerWidget* viewerWid = qobject_castViewerWidget*(parent());
viewerWid-getView()-getCamera()-setViewMatrix(::osg::Matrix::translate(1000.5,
0.0, 0.0));
}
else if(e-button()==Qt::MiddleButton)
{
QMessageBox msg;
msg.setText(Middle Mouse pressed);
msg.exec();
}
else
return;
}


//This is my ViewerWidget class

class ViewerWidget : public QWidget, public osgViewer::CompositeViewer
{
Q_OBJECT
public:
ViewerWidget(osgViewer::ViewerBase::ThreadingModel
threadingModel=osgViewer::CompositeViewer::SingleThreaded, osg::Group*
scene=NULL);

osgQt::GLWidget* addViewWidget( osg::Camera* camera, osg::Group* scene );

osg::Camera* createCamera( int x, int y, int w, int h, const std::string
name=, bool windowDecoration=false );

virtual void paintEvent( QPaintEvent* event );

osgViewer::View* getView();

protected:

QTimer _timer;

osgQt::GraphicsWindowQt* gw;

CSGraphicsView*  gView;

osgViewer::View* view;
};

#endif // VIEWERWIDGET_H

//viewerwidget.cpp

ViewerWidget::ViewerWidget(osgViewer::ViewerBase::ThreadingModel
threadingModel, osg::Group* scene) : QWidget()
{
setThreadingModel(threadingModel);

gView = (CSGraphicsView*) (addViewWidget(
createCamera(0,0,100,100), scene ));

QGridLayout* grid = new QGridLayout;
grid-addWidget( gView, 0, 0 );
setLayout( grid );

connect( _timer, SIGNAL(timeout()), this, SLOT(update()) );
_timer.start( 10 );
}

osgQt::GLWidget* ViewerWidget::addViewWidget( osg::Camera* camera,
osg::Group* scene )
{
view = new osgViewer::View;
view-setCamera( camera );
addView( view );
view-setSceneData( scene );
view-addEventHandler( new osgViewer::StatsHandler );
view-setCameraManipulator( new osgGA::TrackballManipulator );
osg::ref_ptrosgGA::StateSetManipulator statesetManipulator = new
osgGA::StateSetManipulator(view-getCamera()-getStateSet());
view-addEventHandler(statesetManipulator.get());
gw = dynamic_castosgQt::GraphicsWindowQt* (
camera-getGraphicsContext() );
return gw ? gw-getGLWidget() : NULL;
}


osg::Camera* ViewerWidget::createCamera( int x, int y, int w, int h, const
std::string name, bool windowDecoration )
{
gView = new CSGraphicsView(this);
gView-setGeometry(x, y, w, h);
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
osg::ref_ptrosg::GraphicsContext::Traits traits = new
osg::GraphicsContext::Traits;

traits-inheritedWindowData = new osgQt::GraphicsWindowQt::WindowData(
gView );
traits-windowName = name;
traits-windowDecoration = windowDecoration;
traits-x = x;
traits-y = y;
traits-width = w;
traits-height = h;
traits-doubleBuffer = true;
traits-alpha = ds-getMinimumNumAlphaBits();
traits-stencil = ds-getMinimumNumStencilBits();
traits-sampleBuffers = ds-getMultiSamples();
traits-samples = ds-getNumMultiSamples();

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext( new
osgQt::GraphicsWindowQt(traits.get()) );

camera-setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
camera-setViewport( new osg::Viewport(0, 0, traits-width,
traits-height) );
camera-setProjectionMatrixAsPerspective(
30.0f,
static_castdouble(traits-width)/static_castdouble(traits-height),
1.0f, 1.0f );
return camera.release();
 }



void ViewerWidget::paintEvent( QPaintEvent* event )
{
frame();
}


osgViewer::View* ViewerWidget::getView()
{
return view;
}


[/code]


Please tell me why is it not moving ??.I want to implement a rotate
functionality on right mouse press button, a pan function on middle mouse
press function and a zoom function on wheel event.   Any help is highly
appreciated. Thanks Sujan







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


Re: [osg-users] OSG Build with Visual Studio 2010

2013-05-07 Thread Sujan Dasmahapatra
Thanks Braden.


On Wed, May 8, 2013 at 3:26 AM, Braden Edmunds edmu...@reaction-eng.comwrote:

 Hi Sujan,

 Hopefully these steps can will help you build in both release and debug
 mode:

 1. Download the osg source
 2. Run Cmake (setup all paths: 3rd_party libs, Qt directory, etc)
 a. Make sure you select the Visual Studio 10 compiler
 b. Click Generate
 3. Locate the solution file (.sln) cmake generated for you and open it
 4. Build in both debug and release mode inside of Visual Studio (this will
 produce both osgQtd.dll and osgQt.dll and their corresponding .lib files.

 I hope that helps.

 Braden

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=53947#53947





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




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


[osg-users] MousepressEvent not able to capture from osg::Viewer by Qt

2013-05-07 Thread Sujan Dasmahapatra
I am trying to implement a mouse press event with QT and OSG but unable to
do it. Pls help.

Below is my ViewerWidget class which is derived from QWidget and
osg::CompositeViewer..In the constructor I got gView which is a
osg::GLWidget, I am trying override mousePressEvent but when I click
message not coming. What I am doing wrong pls help..

My gView pointer is of class CSGraphicsView as below
/
#ifndef GVIEW_H
#define GVIEW_H
#include osg\GraphicsContext
#include osgQt\GraphicsWindowQt
#include QtGui\qwidget.h
#include QtCore\qobject.h
#include QtGui\qmouseeventtransition.h
class CSGraphicsView : public osgQt::GLWidget
{
public:
CSGraphicsView(QWidget* parent=0);
~CSGraphicsView();

virtual void mousePressEvent(QMouseEvent *e);
};

#endif // GVIEW_H


//Implementations is
void CSGraphicsView::mousePressEvent(QMouseEvent *e)
{
QMessageBox msg;
msg.setText(Mouse pressed);
msg.exec();
}//But this msg is not coming when i am pressing mouse.
/

/
ViewerWidget::ViewerWidget(osgViewer::ViewerBase::ThreadingModel
threadingModel, osg::Group* scene) : QWidget()
{
setThreadingModel(threadingModel);

gView = static_castCSGraphicsView* (addViewWidget(
createCamera(0,0,100,100), scene ));

QGridLayout* grid = new QGridLayout;
grid-addWidget( gView, 0, 0 );
setLayout( grid );

connect( _timer, SIGNAL(timeout()), this, SLOT(update()) );
_timer.start( 10 );
}

osgQt::GLWidget* ViewerWidget::addViewWidget( osg::Camera* camera,
osg::Group* scene )
{
osgViewer::View* view = new osgViewer::View;
view-setCamera( camera );
addView( view );

view-setSceneData( scene );
view-addEventHandler( new osgViewer::StatsHandler );
view-setCameraManipulator( new osgGA::TrackballManipulator );

gw = dynamic_castosgQt::GraphicsWindowQt* (
camera-getGraphicsContext() );
return gw ? gw-getGLWidget() : NULL;
}


osg::Camera* ViewerWidget::createCamera( int x, int y, int w, int h, const
std::string name, bool windowDecoration )
{
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
osg::ref_ptrosg::GraphicsContext::Traits traits = new
osg::GraphicsContext::Traits;
traits-windowName = name;
traits-windowDecoration = windowDecoration;
traits-x = x;
traits-y = y;
traits-width = w;
traits-height = h;
traits-doubleBuffer = true;
traits-alpha = ds-getMinimumNumAlphaBits();
traits-stencil = ds-getMinimumNumStencilBits();
traits-sampleBuffers = ds-getMultiSamples();
traits-samples = ds-getNumMultiSamples();

osg::ref_ptrosg::Camera camera = new osg::Camera;
camera-setGraphicsContext( new
osgQt::GraphicsWindowQt(traits.get()) );

camera-setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
camera-setViewport( new osg::Viewport(0, 0, traits-width,
traits-height) );
camera-setProjectionMatrixAsPerspective(
30.0f,
static_castdouble(traits-width)/static_castdouble(traits-height),
1.0f, 1.0f );
return camera.release();
 }



void ViewerWidget::paintEvent( QPaintEvent* event )
{
frame();
}
/
-- 
Thanks  Regards
Sujan
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] OSG with Qt

2013-05-06 Thread Sujan Dasmahapatra
I am trying to build osgViewerQt example. Error is coming as osgQt run-time
error. I am building it is debug mode. But I dont find any osgQtd.lib, but
it is osgQt.lib Is it for release build??..I am using Visual studio 2010
and corresponding Qt version I have installed. Please suggest. Thank  Sujan


On Mon, May 6, 2013 at 4:51 PM, Robert Osfield robert.osfi...@gmail.comwrote:

 Have a look at the osgviewerQt example.
 On 6 May 2013 02:51, Sujan Dasmahapatra sujan.dasmahapa...@gmail.com
 wrote:

 Can I control OSG viewer by Qt events. Like mouse press, mouse move etc
 can be used with OSG viewer??..Any suggestions highly appreciated.

 --
 Regards
 Sujan

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


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




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


Re: [osg-users] OSG Build with Visual Studio 2010

2013-05-06 Thread Sujan Dasmahapatra
Thanks dear Robert. I got one more doubt how can we build OSG using cmake.
I am getting errors that it's not getting bcc32 compiler. Although I got
Visual C++ 2010 compile it should take that. And moreover I just installed
bcc32 5.5 also. Now it's giving error it's not able to run a simple test.
Please help.


On Mon, May 6, 2013 at 3:45 PM, Jan Ciger jan.ci...@gmail.com wrote:

 On Mon, May 6, 2013 at 11:16 AM, Sujan Dasmahapatra
 sujan.dasmahapa...@gmail.com wrote:
  I am trying to build osgViewerQt example. Error is coming as osgQt
 run-time
  error. I am building it is debug mode. But I dont find any osgQtd.lib,
 but
  it is osgQt.lib Is it for release build??..I am using Visual studio 2010
 and
  corresponding Qt version I have installed. Please suggest. Thank  Sujan

 That means that you have built OSG in release mode only. You must
 build both release  debug version of OSG if you want to build the
 examples (or your project) in Debug mode.

 Regards,

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




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


[osg-users] OSG with Qt

2013-05-05 Thread Sujan Dasmahapatra
Can I control OSG viewer by Qt events. Like mouse press, mouse move etc can
be used with OSG viewer??..Any suggestions highly appreciated.

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


Re: [osg-users] OSG Architecture

2013-05-03 Thread Sujan Dasmahapatra
Thanks a lot Michael.


On Fri, May 3, 2013 at 1:52 PM, michael kapelko korn...@gmail.com wrote:

 Hi.
 Simply add your Sofa to Room as a child, and that's it.

 2013/5/3 Sujan Dasmahapatra sujan.dasmahapa...@gmail.com

 I am newbie OSG user. Please help understanding my concept. I create a
 Geode node called 'Room'. Can we have another Geode node  called 'Sofa'
 derived from 'Room' so that when I rotate 'Room' my 'Sofa' should also
 rotate, but when I rotate 'Sofa' my 'Room' should not rotate. Can we
 establish an architecture like that?. Please help. Thanks Sujan

 --
 Regards
 Sujan

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



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




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


[osg-users] OSG Architecture

2013-05-02 Thread Sujan Dasmahapatra
I am newbie OSG user. Please help understanding my concept. I create a
Geode node called 'Room'. Can we have another Geode node  called 'Sofa'
derived from 'Room' so that when I rotate 'Room' my 'Sofa' should also
rotate, but when I rotate 'Sofa' my 'Room' should not rotate. Can we
establish an architecture like that?. Please help. Thanks Sujan

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