Re: [osg-users] Translate problem

2013-05-09 Thread Trajce Nikolov NICK
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 = 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();
 

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


Re: [osg-users] Extrude Geometry

2013-05-09 Thread Robert Osfield
Hi Braden,

I can't see a way for us to directly help you as the problem is in your own
code, the code snippet your've provided doesn't appear to tally with the
error message you've reported so we are really far more in the dark than
you.

The only thing I can say is that in general it should be fine to modify
geometry during the update or event traversals like you are doing, but if
you viewer is running mulit-threaded (the osgViewer will run multi-thread
if you have multi-cores by default) then you'll need to tell the OSG that
those objects you are modifying are dynamically modified by setting their
DataVariance to DYNAMIC, i.e. geometry-setDataVariance(osg::DYNAMIC); as
this will tell the draw traversal not to let the next frame to commence
till this dynamic objects has been rendered.

Robert.


On 7 May 2013 20:14, Braden Edmunds edmu...@reaction-eng.com wrote:

 I've roughly followed the osgmanipulator.cpp example to create
 osgManipulator::Translate1DDragger objects and link them to my custom
 geometry items and everything works fine. I'm encountering a problem when I
 try to update a geometry item inside of the traverse method. The following
 code is where it breaks:


 Code:

 void DraggerContainer::traverse(osg::NodeVisitor nv)
 {
  //setup
 

 //
 osg::Vec3 trans = _dragger-getMatrix().getTrans();

 _dragger-setMatrix(
 osg::Matrix::rotate(osg::inDegrees(degrees),rotationAxis)
 * osg::Matrix::scale(scaleFactor)
 * osg::Matrix::translate(trans)); //re-position the draggable item

 if(prev_trans.length() != trans.length())
 {
 UpdateGeometry(trans); // --- Breaks after this returns
 }

 osg::Group::traverse(nv);
 }




 The error is vector iterator not incrementable  vector line 99, but this
 error is only produced after running through functions in viewer.dll and
 osg.dll.

 I'm wondering if this is the correct way to extrude geometry on the fly,
 and if adding nodes during the traverse call will cause an iterator to
 become invalid.

 Thanks in advance,

 Braden


 [/code]

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





 ___
 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


Re: [osg-users] PointSprite Texture orientation

2013-05-09 Thread Robert Osfield
Hi Daniel,

For the osgParticle::PreciptiationEffect I used quads rather than point
sprites as point sprites are just appropriate for circular points or cases
where it's OK for the texture to be screen aligned.

With modern graphics cards I'd just pass a point to the vertex shader and
have a geometry shader generate a quad with the appropriate geometry and
texture coordinates.

Robert.


On 8 May 2013 14:02, Daniel Schmid daniel.sch...@swiss-simtec.ch wrote:

 Hi all

 I use pointsprites to simulate precipitation (rain/snow). The
 implementation is completed and works very well.

 Now the end user decided to rotate the viewport about 90 degrees. The
 problem is now that the pointsprite texture coordinates to not take into
 accout the rotated viewport and the raindrops (small lines) are transversly
 and are not oriented in their falling direction.

 I tried to set a TexGen object in the stateset but what arguments do I
 have to set?

 Thank you!

 Cheers,
 Daniel

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





 ___
 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


Re: [osg-users] OcclusionQueryNode and Depth Splitting

2013-05-09 Thread Robert Osfield
Hi Pablo,

You are the first person to report trying to combine z portioning and
occlusion query, so while it might be possible you might be the first to
try :-)

The only way I can think of it working would be to doing the occlusion
query work per partition, as the occlusion query has to be in the same
depth range as the objects you are querying against - you can't go changing
the projection matrix in between.

Robert.


On 8 May 2013 22:21, Pablo Carneiro Elias pablo.c...@gmail.com wrote:

 Hi all,

 I am facing a problem when trying to use the occlusion query node while
 implementing Z splitting for rendering large scenes.

 I know osg has z splitting but I had to implement by my self since I have
 a separated frustum and projection system (projection matrices are placed
 within osg camera).

 I am currently trying this:

 1) I made a pausable occlusion query node that can be paused and its
 current passed state reamains unchanged.

 2) I render the whole scene using a very large frustum (represeting the
 sum of all partitions, i.e the original large frustum).

 3) I pause all OQN by using a visitor.

 4) Render the scene using the partitions and the pre-set occlusion state
 that was paused while rendering the partitions.

 It is not working not even for a single object.. it blinks non-stop...

 Does anyone has any suggestion?

 Does Openscenegraph currently supports Z-Splitting along with OQNodes?

 Thanks!

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





 ___
 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


[osg-users] Some OSG Windows functionality not available in Linux?

2013-05-09 Thread Nav Joseph
Hi,

Posting this on behalf of a colleague:

I have built OSG3.0.1 in /usr/local directory. But I found that few of the 
files were missing in /usr/local/include/osgShadow directory which are already 
there in the windows equivalent.
NOTE: - I have a windows based application (contains OSG and OSGEarth) that I 
need to port to Linux.
These files are:
1. ViewDependentShadowMap
2. ShadowSettings
In addition to this, ShadowedScene file in /usr/local/include/osgShadow also 
appeared to be different, as it was not having setShadowSettings method in it.
My questions are:-
1. Did I miss some flag while building OSG or are these files absent in the 
LINUX variant of OSG?
2. How to go about it if these files are absent by default in the LINUX variant?
I guess, copying missing OSG files from windows to Linux will not serve my 
purpose. Please advise.

Thanks in advance!
Cheers,
Nav


Nav or Joseph? You can call me Nav :-)

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





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


Re: [osg-users] Some OSG Windows functionality not available in Linux?

2013-05-09 Thread Robert Osfield
Hi Nav,

The OSG is almost indendtical for all platforms and your certainly
shouldn't see any differences in osgShadow which has no platform specific
files or features.

The question has to be how did you end up with different versions of the
OSG on Windows vs Linux, only you can answer this one.  Have a look at the
include/osg/Version file to see the version that you actually have
installed.

Robert.


On 9 May 2013 11:18, Nav Joseph nk...@tatapowersed.com wrote:

 Hi,

 Posting this on behalf of a colleague:

 I have built OSG3.0.1 in /usr/local directory. But I found that few of the
 files were missing in /usr/local/include/osgShadow directory which are
 already there in the windows equivalent.
 NOTE: - I have a windows based application (contains OSG and OSGEarth)
 that I need to port to Linux.
 These files are:
 1. ViewDependentShadowMap
 2. ShadowSettings
 In addition to this, ShadowedScene file in /usr/local/include/osgShadow
 also appeared to be different, as it was not having setShadowSettings
 method in it.
 My questions are:-
 1. Did I miss some flag while building OSG or are these files absent in
 the LINUX variant of OSG?
 2. How to go about it if these files are absent by default in the LINUX
 variant?
 I guess, copying missing OSG files from windows to Linux will not serve my
 purpose. Please advise.

 Thanks in advance!
 Cheers,
 Nav

 
 Nav or Joseph? You can call me Nav :-)

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





 ___
 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


[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] Some OSG Windows functionality not available in Linux?

2013-05-09 Thread Nav Joseph
Oh thanks for that. He checked and saw that the Linux version was 3.0.1 and the 
windows version was 3.1.4. I guess he got one of the nightly builds, because 
3.0.1 is the latest stable release.


Nav or Joseph? You can call me Nav :-)

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





___
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 Trajce Nikolov NICK
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


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 Trajce Nikolov NICK
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


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


Re: [osg-users] OcclusionQueryNode and Depth Splitting

2013-05-09 Thread Pablo Carneiro Elias
Yes Robert,

but the main problem is that many times an occlusor will be in a different 
partition than the occluded object. And thats the main problem I think.. 
Objects in different distant partitions will be culled out by the current 
partition

I canĀ“t think of anything.. I thought about making an extra pass to calculate 
the occlusion query with a huge frustum, but the depth precision problem would 
not render distant objects properly...

:/
Still need something clever on this... if there is anything possible..

Any possible trick you might think of?

Thank for the reply Robert! 

Pablo

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





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


Re: [osg-users] OcclusionQueryNode and Depth Splitting

2013-05-09 Thread Robert Osfield
Hi Pablo,

I can't think of way of having occluder set up in different depth range to
the objects it's being occluded with jump through hoops with shaders that
would unify the depth used in the test to the same range.  This is really
down to handle though, you are so off the map of what is normally done you
are effectively out on your own.

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


Re: [osg-users] Extrude Geometry

2013-05-09 Thread Braden Edmunds
Hi Robert,

Thank you very much, setting the geometry to dynamic was the key.

Thanks,
Braden

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





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


Re: [osg-users] OcclusionQueryNode and Depth Splitting

2013-05-09 Thread Pablo Carneiro Elias
Thanks,

Agreed, I may have to implement something using CPU, like tests using 
occluder's shadow volume or something like that..

Anyway thanks again.

[]s Pablo

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





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


[osg-users] osgParticle::ExplosionEffect: assistance needed

2013-05-09 Thread Mike Metcalf
I have been exploring osgParticle::ExplosionEffect for use with our software 
and have run into a few things I haven't yet been able to figure out.

1) We use the Qt resource system to compile and link into our executable some 
of the binary resources we need, including some images. I have used this system 
to store a .png file as a resource and have been trying to use that png file as 
the texture for the particle effects in an ExplosionEffect. When I invoke 
myExplosion-setTextureFileName(:explosiontexture), the texture appears not 
to have been loaded. When I invoke it with an actual path to the same file 
sitting on my hard drive, it works without problem. So, can anyone tell me if 
the Qt Resource system's naming convention for referring to internal binary 
resources is in some way usable with the setTextureFileName interface in 
ExplosionEffects? 

2) The ExplosionEffect seems to be oriented with a z-up orientation. I am using 
OSGEarth and would like to have the explosions oriented at a local up axis, not 
a global z-up axis. I tried to add my explosions as a child of a 
MatrixTransform, but this seemed not to have the desired effect. Any tips or 
tricks on what my best options are?

Thanks in advance for any help you may provide!
-Mike

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





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


Re: [osg-users] Dinamic Line Drawing

2013-05-09 Thread Patrick Keenan
Hi,

This post was really helpful for me but I still couldn't add points on the fly 
either. A few edits made it happen so I'm attaching my M_OSG_line_strip class.

To use the class I have the following in my CreateScene()


Code:

osg::Vec3Array* line_pts = new osg::Vec3Array;
line_pts-push_back(osg::Vec3(100, 0, 0));
line_pts-push_back(osg::Vec3(0, 100, 500));
line_pts-push_back(osg::Vec3(100, 100, 100));


lines_test = new 
M_OSG_line_strip(osg::Matrix::rotate(osg::inDegrees(0.0f), 0.0f, 0.0f, 1.0f),

osg::Matrix::translate(0.0f, 0.0f, 0.0f),

osg::Matrix::rotate(osg::inDegrees(0.0f), 0.0f, 0.0f, 1.0f),

line_pts,

osg::Vec4(0.0f,1.0f,1.0f,1.0f)
);

tmp_root-addChild(lines_test-Get());




and to dynamically add a new line I have


Code:


void M_frame::OnTestBtnClick(wxCommandEvent WXUNUSED(event))
{
osg::Vec3f* new_pt = new  osg::Vec3f(4000.0f, 2000.0f, 0.0f); // works
lines_test-Add_new_point(new_pt); 
}




Seems to work great. Critique of the use of osg::ref_ptr is welcomed. 

Thanks, Patrick

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




Attachments: 
http://forum.openscenegraph.org//files/m_osg_line_strip_887.h
http://forum.openscenegraph.org//files/m_osg_line_strip_762.cpp


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