Re: [osg-users] kdtree example

2008-06-08 Thread Guy
Hello,

 Maybe it's arrogant of me to mention anything, but anyway...

 

 I don't know what kd-tree is, only guessing from your discussion, but
if as Adrian says the performance is a combination of building, and
traversing the tree, I think these sections should be implemented in
generic classes so their implementation could be easily replaced later.
Like the callbacks mechanism for example.

 

Guy.

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Adrian
Egli OpenSceneGraph (3D)
Sent: Friday, June 06, 2008 4:55 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] kdtree example

 

Hi all, 

once we have a working version of kd-Tree, we can start a contest :-)
there exist hunderds of heuristics, tricks for traversing, and so on.
Performance of kd-Tree traversing depends not only the method of
traversing, the performance depends much more on the build strategy than
on the traversing. of course both are important, kd-Tree build and the
software enginiering tricks for fast traversing. 

:-) in my first kd-tree traversing algorithme, basic kd-tree i had about
27s, after some optimisation i could do same thing in less than one
second. but i know some kd-tree based raytracing algorithme working much
much faster :-)  

/adrian 

2008/6/6 Robert Osfield [EMAIL PROTECTED]:

Hi Paul,


On Fri, Jun 6, 2008 at 3:20 PM, Paul Melis [EMAIL PROTECTED] wrote:
 As it is still work in progress you might have this on your list
already,
 but changing the traversal to use a while loop with a stack rather
than use
 recursive calls on traverse() should increase intersection performance
quite
 a bit.

Use a local stack rather than recursive is something I'm already
considering.  The current build code uses recursion, and the intersect
traversal I'll implement initially with recursion for simplicity.
Once these are both working sweetly I'll implement the alternative non
recursive.

Robert.

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




-- 

Adrian Egli 

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


Re: [osg-users] OpenGL commands

2008-06-08 Thread Hugo Juarez CorrĂ¡
Hi Robert,

Thanks for you response. A few years ago we develop a GUI design
project based on openGL to create buttons, widgets, edit box etc. Our
window system is based on inheriting Producer. We have a class inside
our project to render 3d objects using OSG and we have a separate
project using OSG to render and manipulate our visual database.

Since OSG dropped Producer we got stuck in the version 1.2 because we
have to many ties to Producer and we have decided to drop it and use
osgViewer instead to render our window system but we do not want to
redesign all our gui objects.

We have studied that this can be done using a Wrapper and calling the
function DrawImplementation. We would like to know the best way
to port our project to OSG 2, and consequently, the best way to implement
osgViewer on our system.

Thanks,
Hugo.

 Message: 7
 Date: Thu, 5 Jun 2008 08:36:09 +0100
 From: Robert Osfield [EMAIL PROTECTED]
 Subject: Re: [osg-users] OpenGL commands
 To: OpenSceneGraph Users osg-users@lists.openscenegraph.org

 Hi Hugo,

 Using a Camera DrawCallback would be one way, or implementing your own
 GraphicsOperation that is attached to the GraphicsWindow.

 Could you explain a bit more about what you are trying to do.  It
 almost sounds like you want to do just OpenGL rendering, no OSG
 rendering at all.

 Robert.

 On Wed, Jun 4, 2008 at 10:09 PM, Hugo Juarez Corr? [EMAIL PROTECTED] wrote:
 Hi All,

 Can I use OpenGL commands directly on osgViewer (without a wrapper)??
 I don't want create an object that inherits osg::Drawable to render my
 OpenGL commands.
 I would like use osgViewer just to render my OpenGL commands, is it possible?

 Thanks in advance,
 Hugo.
 ___
 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] Add A Window

2008-06-08 Thread GuiYe
  
 
Hello,Robert.
Thanks for your reversion.I'm so happy that I can add a new window in 
realtime.But there is a new problem :how to destroy the new window.I find that 
stopThreading can't destroy the window.Thanks.
 
Waiting for you good news.

//
//
#include osgDB/ReadFile
#include osgUtil/Optimizer
#include osgViewer/Viewer
#include osgGA/MatrixManipulator
#include osgGA/TrackballManipulator
#include osgGA/StateSetManipulator
#include iostream
#include osg/Node
#include osg/Geode
#include osg/Geometry
#include osgViewer/Viewer
class MyWindowHandler:public osgGA::GUIEventHandler 
{
public:
 MyWindowHandler():
   OneOrTwo(false)
   {}
   ~MyWindowHandler(){}
   bool handle(const osgGA::GUIEventAdapter ea, osgGA::GUIActionAdapter aa)
   {
osgViewer::Viewer* viewer = dynamic_castosgViewer::Viewer*(aa) ;
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
 {
  if(ea.getKey()==osgGA::GUIEventAdapter::KEY_F1)
  {
   OneOrTwo = !OneOrTwo ;
   viewer-stopThreading();
   if(OneOrTwo)
   {
int xoffset = 40;
int yoffset = 40;
viewer-stopThreading() ;
viewer-startThreading() ;
//{
// osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
// traits-x = xoffset + 0;
// traits-y = yoffset + 0;
// traits-width = 600;
// traits-height = 480;
// traits-windowDecoration = true;
// traits-doubleBuffer = true;
// traits-sharedContext = 0;
// osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());
// osg::ref_ptrosg::Camera camera = new osg::Camera;
// camera-setGraphicsContext(gc.get());
// camera-setViewport(new osg::Viewport(0,0, traits-width, 
traits-height));
// GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
// camera-setDrawBuffer(buffer);
// camera-setReadBuffer(buffer);
// viewer-addSlave(camera.get(), osg::Matrixd::translate(1.0,0.0,0.0), 
osg::Matrixd());
//}
{
 osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
 traits-x = xoffset + 600;
 traits-y = yoffset + 0;
 traits-width = 600;
 traits-height = 480;
 traits-windowDecoration = true;
 traits-doubleBuffer = true;
 traits-sharedContext = 0;
 osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());
 osg::ref_ptrosg::Camera camera = new osg::Camera;
 camera-setGraphicsContext(gc.get());
 camera-setViewport(new osg::Viewport(0,0, traits-width, 
traits-height));
 GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
 camera-setDrawBuffer(buffer);
 camera-setReadBuffer(buffer);
 viewer-addSlave(camera.get(), osg::Matrixd::translate(-1.0,0.0,0.0), 
osg::Matrixd());
}
//viewer-setSceneData(osgDB::readNodeFile(cow.osg));
  viewer-realize() ;
   }
   return true ;
  }
  return false ;
 }
 break ;
default:
 return false ;
}
   }
public:
 bool OneOrTwo ;
};
int main( int argc, char **argv )
{
 osg::ArgumentParser arguments(argc,argv);
 osg::ref_ptrosg::Node loadedModel = osgDB::readNodeFiles(arguments);
 if (!loadedModel) loadedModel = osgDB::readNodeFile(cow.osg);
 if (!loadedModel) 
 {
  std::cout  arguments.getApplicationName() : No data loaded  std::endl;
  return 1;
 }
 osgViewer::Viewer viewer;
 int xoffset = 40;
 int yoffset = 40;
 //viewer.stopThreading() ;
 //viewer.startThreading() ;
 viewer.addEventHandler(new MyWindowHandler()) ;
 {
  osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
  traits-x = xoffset + 0;
  traits-y = yoffset + 0;
  traits-width = 600;
  traits-height = 480;
  traits-windowDecoration = true;
  traits-doubleBuffer = true;
  traits-sharedContext = 0;
  osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext(traits.get());
  osg::ref_ptrosg::Camera camera = new osg::Camera;
  camera-setGraphicsContext(gc.get());
  camera-setViewport(new osg::Viewport(0,0, traits-width, traits-height));
  GLenum buffer = traits-doubleBuffer ? GL_BACK : GL_FRONT;
  camera-setDrawBuffer(buffer);
  camera-setReadBuffer(buffer);
  viewer.addSlave(camera.get(), osg::Matrixd::translate(1.0,0.0,0.0), 
osg::Matrixd());
 }
 viewer.setSceneData(loadedModel.get());
 viewer.realize();
 //}
 return viewer.run();
}

 
 
 Hi GuiYe,

At present the addSlave doesn't automatically tell the viewer to
realize windows, reset up threading and rendering support, which is
why you code isn't working.

What you need to do in you event handling is to call
viewer.stopThreading() first, create you new window/associated
view/camera then realize the new window and then call startTheading().

Robert.


___