[osg-users] Distance point to geometry

2012-01-16 Thread Vincent Bourdier

Hi all,

Looking in the archives I didn't get any interesting answer so here is 
the question :


Is there any way using OSG to compute the distance between a graph and a 
point ?

(not just with the vertices but also with edges and the triangles)

I could implement my own visitor to traverse all element (vertex, ege 
and face) but I'm looking for something more optimized or more easy to 
do in a few days if possible...


Thanks.

Regards,
Vincent.

--


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


Re: [osg-users] Frame syncing over multiple contexts

2012-01-16 Thread Robert Osfield
Hi Anna,

This should work out of the box - the two windows should be rendering
and synchronised.  How are you setting up your viewer and graphics
contexts?

A a general note, if you are using a single graphics card for best
performance one usually tries to use a single graphics window and have
two cameras or more share this context.  Is there a reason why you
need two separate windows rather than a single window with two views?

Robert.

On 14 January 2012 21:21, Anna Sokol annaso...@gmail.com wrote:
 Hi,

 I am trying to figure out how to keep multiple graphics contexts in frame
 sync.

 My operating system is Windows XP SP3.
 My graphics is NVidia Quadro NVS 290 with the latest driver 276.42.
 I'm using OpenSceneGraph 3.0.1 compiled with Visual C++ 2005 for win32.

 I have vsync on in the driver and in Traits, also I am using a
 CullDrawThreadPerContext as the threading model.
 I have 2 graphics windows with separate contexts showing the same scene with
 a left and right view on one display.
 I have the scene moving across both windows so that I can see if its
 properly syncing.
 It sometimes visibly looks to be a number of frames out of sync (i.e. one of
 the rendered context is dragging behind).
 What could be causing this? In the threads? Or down in the graphics card?
 Is there any specific settings I should set to make the rendered contexts
 stay in frame sync?


 Regards,
 Anna Sokol
 _
 Once we accept our limits, we go beyond them.  -- Albert Einstein

 ___
 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] Place axes at corner

2012-01-16 Thread Robert Osfield
Hi Clement,

On 16 January 2012 06:14,  clement@csiro.au wrote:
   I have created axes to display on viewer, but I have no idea to place it at 
 the bottom corner of the view.  Anyone know how to location the corner of the 
 view?  Many thanks.

Have a look at the osghud example.

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


Re: [osg-users] osgvolume opacity settings

2012-01-16 Thread Robert Osfield
Hi Clement,

On 16 January 2012 06:21,  clement@csiro.au wrote:
   My application is using osgvolume to display CT data.  There is class 
 called CompositeProperty and there are three property classes 
 (AlphaFuncProperty, SampleDensityProperty and TransparencyProperty) as well.  
 I would like to know more details of those classes and how to apply on 
 osgvolume.  I did to follow the example to use those classes, but when I 
 changed the value of SampleDensityProperty from 0.05 to 0.5.  Some CT data 
 are disappear, so I would like to know more how to control property values.  
 Many thanks.

AlphaFuncProperty is equivalent to glAlphaFunc and sets the alpha
value below which fragments will be discarded

TransparencyProperty is an alpha value multiplier that you can use to
make your volume more transparent.

SampleDensityProperty controls the size of the step during the ray
tracing through the volume, the lower the value
the more samples, the higher the value the less the samples.  If you
use a value of 0.5 you'll only get 3 samples which clearly won't be
enough!

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


Re: [osg-users] Help:Is there a way for a single fragment to know its index during per-fragment operation?

2012-01-16 Thread Sergey Polischuk
Hi

If that makes any difference, by default coordinates contained in gl_FragCoord 
point to pixel center, so for leftmost-bottom pixel you will get (0.5, 0.5). If 
you need integer value you'll get correct result with 
ivec2(floor(gl_FragCoord.xy))

Cheers

14.01.2012, 23:57, Sebastian Messerschmidt sebastian.messerschm...@gmx.de:
 Hi Shuiying,

 The fragments coordinates(or index as you call it) can be accessed via
 gl_FragCoord. This will give unnormalized device coordinates (i.e.
 [0,xRes] [0,yRes]) which are also called window relative coordinates
 If you pass your screen resolution as uniform vec2 you can normalize
 them to device coordinates easily.

 cheers
 Sebastian

  Hello,

  In fragment shader, I would like to chage the fragment colour
  according to the fragment's index. Here index means integer number
  pair(x,y), where 0xxRes, 0yyRes, provided that viewPort has xRes *
  yRes pixels.

  Is there a way to achieve that?

  Thank you in advance!

  Shuiying
  ___
  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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Distance point to geometry

2012-01-16 Thread Robert Osfield
Hi Vincent,

I'm not clear on what you are after, but I can say that there isn't
anything close to resembling what you are talking about in the OSG so
you'll need to roll your own visitor.

Robert

On 16 January 2012 08:36, Vincent Bourdier vincent.bourd...@gmail.com wrote:
 Hi all,

 Looking in the archives I didn't get any interesting answer so here is the
 question :

 Is there any way using OSG to compute the distance between a graph and a
 point ?
 (not just with the vertices but also with edges and the triangles)

 I could implement my own visitor to traverse all element (vertex, ege and
 face) but I'm looking for something more optimized or more easy to do in a
 few days if possible...

 Thanks.

 Regards,
    Vincent.

 --


 ___
 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] Distance point to geometry

2012-01-16 Thread Vincent Bourdier

Hi Robert,

Sorry if I was not clear : I'm just looking for a way to compute the 
smallest distance between a point and a geometry, not just a point to 
vertex distance, but also a point to edge or point to face (orthogonal 
projection).

Due to the few days I have I think this won't be possible and safe...

Thanks.

Regards,
   Vincent.

Le 16/01/2012 10:26, Robert Osfield a écrit :

Hi Vincent,

I'm not clear on what you are after, but I can say that there isn't
anything close to resembling what you are talking about in the OSG so
you'll need to roll your own visitor.

Robert

On 16 January 2012 08:36, Vincent Bourdiervincent.bourd...@gmail.com  wrote:

Hi all,

Looking in the archives I didn't get any interesting answer so here is the
question :

Is there any way using OSG to compute the distance between a graph and a
point ?
(not just with the vertices but also with edges and the triangles)

I could implement my own visitor to traverse all element (vertex, ege and
face) but I'm looking for something more optimized or more easy to do in a
few days if possible...

Thanks.

Regards,
Vincent.

--


___
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] Distance point to geometry

2012-01-16 Thread Philipp Moeller
Vincent Bourdier vincent.bourd...@gmail.com writes:

 Hi Robert,

 Sorry if I was not clear : I'm just looking for a way to compute the
 smallest distance between a point and a geometry, not just a point to
 vertex distance, but also a point to edge or point to face (orthogonal
 projection).

That is a common problem in robotics and computational geometry. This
should get you started with a choice of algorithms that might suit you:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.46.8005rep=rep1type=pdf

Cheers,
Philipp Moeller

 Due to the few days I have I think this won't be possible and safe...

 Thanks.

 Regards,
Vincent.

 Le 16/01/2012 10:26, Robert Osfield a écrit :
 Hi Vincent,

 I'm not clear on what you are after, but I can say that there isn't
 anything close to resembling what you are talking about in the OSG so
 you'll need to roll your own visitor.

 Robert

 On 16 January 2012 08:36, Vincent Bourdiervincent.bourd...@gmail.com  
 wrote:
 Hi all,

 Looking in the archives I didn't get any interesting answer so here is the
 question :

 Is there any way using OSG to compute the distance between a graph and a
 point ?
 (not just with the vertices but also with edges and the triangles)

 I could implement my own visitor to traverse all element (vertex, ege and
 face) but I'm looking for something more optimized or more easy to do in a
 few days if possible...

 Thanks.

 Regards,
 Vincent.

 --


 ___
 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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Sergey Polischuk
Hi all

I'm gonna add my 5 cents on this topic. I was having similar problems in app 
which recreates viewer in runtime (there are preview window and viewer created 
when widget shows up), using osg version 3.0(?). In my case problem was not 
only with textures - i was getting corrupted vertex arrays after viewer 
re-creation. I tried some voodoo magic with osgDB::Registry and caching 
settings, tried to clear gl objects with osg::deleteAllGLObjects() 
osg::flushAllDeletedGLObjects() etc, but without any luck. I've had different 
graphics context ids after viewer recreation. In my case problem was solved 
when using vertex buffer objects instead of display lists, i didnt dig any 
further after that. IIRC problem was showing itself only on windows, but i cant 
say for sure now.

Cheers

14.01.2012, 14:58, Robert Osfield robert.osfi...@gmail.com:
 Hi Chris,

 On 14 January 2012 09:30, Chris Denham c.m.den...@gmail.com wrote:

  Hi Robert,
  To answer your question about how I manage the graphics contexts.
  I just create a new one for the window handle provided by each instance of 
 my browser plugin e.g

  Code:
  traits-inheritedWindowData = new WindowData(hWnd);
  gc = osg::GraphicsContext::createGraphicsContext(traits);

 After gc is assigned check the value of gc-getState()-getContextID()
 for each of the contexts created.  In theory for multiple contexts
 they should read 0,1,2,etc.

 Robert.
 ___
 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] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Chris Denham
Hi Robert,
Yep, I can confirm the return value of  gc-getState()-getContextID() is 
increasing as you describe for each brower plugin instance created.
Does that mean I should be ok sharing scengraph between viewers?
It certainly seems ok now I've disabled the unref images after apply flag on 
the textures.
Chris Denham.


robertosfield wrote:
 Hi Chris,
 
 On 14 January 2012 09:30, Chris Denham  wrote:
 
  Hi Robert,
  To answer your question about how I manage the graphics contexts.
  I just create a new one for the window handle provided by each instance of 
  my browser plugin e.g
  
  Code:
  traits-inheritedWindowData = new WindowData(hWnd);
  gc = osg::GraphicsContext::createGraphicsContext(traits);
  
 
 After gc is assigned check the value of gc-getState()-getContextID()
 for each of the contexts created.  In theory for multiple contexts
 they should read 0,1,2,etc.
 
 Robert.
 ___
 osg-users mailing list
 
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
  --
 Post generated by Mail2Forum


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





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


Re: [osg-users] OSG website unresponsive

2012-01-16 Thread Mathieu MARACHE
Hi Reobert,
openscenegraph is a user I created, there is no osg project on github :-)
--
Mathieu



On 13 January 2012 20:16, Robert Osfield robert.osfi...@gmail.com wrote:
 HI Mathieu,

 On 13 January 2012 17:29, Mathieu MARACHE math...@marache.com wrote:
 Sure, I'll create the mirror for
 http://www.openscenegraph.org/svn/VirtualPlanetBuilder, add it to the
 openscenegraph I created on github, and transfer the ownership of the
 project when you want to do the transition from svn to git.

 I'd be inclined to suggest that creating a new project for
 VirtualPlanetBuilder would be more appropriate than nesting t within
 osg.  I'll lean a bit more about git and github and if I get brave
 I'll create a VPB project and see if I can import from svn.  I don't
 think that a mirror of existing svn won't be required as I can
 probably just move wholesale across.

 Robert.
 ___
 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] Frame syncing over multiple contexts

2012-01-16 Thread Laurens Voerman

Hi Anna, Robbert,
I think the bufferswaps on window are by default not synchronized, a 
call to
wglJoinSwapGroupNV(HDC hdc, GLuint group) is needed to make different 
windows synchronize.

the osg lib has the code to make the call, just set
traits-swapGroupEnabled = true;
before
createGraphicsContext(traits);


Output should look like: (set OSG_NOTIFY_LEVEL=INFO)
GraphicsCostEstimator::calibrate(..)
GraphicsWindowWin32::setSyncToVBlank on
GraphicsWindowWin32::wglJoinSwapGroupNV (0) returned 1
GraphicsWindowWin32::wglBindSwapBarrierNV (0, 0) returned 0

the wglBindSwapBarrierNV  fails if you don't have a gsync card (hardware 
connection card for multiple graphics cards)


Still, as Robbert says, a single graphics window is likely to perform 
better, and is of course automatically in sync. But I

suppose you don't want fullscreen with stereo mode VERTICAL_SPLIT.

Laurens.

On 1/16/2012 10:17 AM, Robert Osfield wrote:

Hi Anna,

This should work out of the box - the two windows should be rendering
and synchronised.  How are you setting up your viewer and graphics
contexts?

A a general note, if you are using a single graphics card for best
performance one usually tries to use a single graphics window and have
two cameras or more share this context.  Is there a reason why you
need two separate windows rather than a single window with two views?

Robert.

On 14 January 2012 21:21, Anna Sokolannaso...@gmail.com  wrote:

Hi,

I am trying to figure out how to keep multiple graphics contexts in frame
sync.

My operating system is Windows XP SP3.
My graphics is NVidia Quadro NVS 290 with the latest driver 276.42.
I'm using OpenSceneGraph 3.0.1 compiled with Visual C++ 2005 for win32.

I have vsync on in the driver and in Traits, also I am using a
CullDrawThreadPerContext as the threading model.
I have 2 graphics windows with separate contexts showing the same scene with
a left and right view on one display.
I have the scene moving across both windows so that I can see if its
properly syncing.
It sometimes visibly looks to be a number of frames out of sync (i.e. one of
the rendered context is dragging behind).
What could be causing this? In the threads? Or down in the graphics card?
Is there any specific settings I should set to make the rendered contexts
stay in frame sync?


Regards,
Anna Sokol
_
Once we accept our limits, we go beyond them.  -- Albert Einstein

___
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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Chris Denham
Hi Hybr,
Corrupted vertex arrays? Do you mean the OpenSceneGraph geometry data, or a 
problem with the OGL compiled display list? I've not seen that, and I hope I 
don't. ;-)
I'll keep an eye out for trouble though.
Cheers,
Chris.


hybr wrote:
 Hi all
 
 I'm gonna add my 5 cents on this topic. I was having similar problems in app 
 which recreates viewer in runtime (there are preview window and viewer 
 created when widget shows up), using osg version 3.0(?). In my case problem 
 was not only with textures - i was getting corrupted vertex arrays after 
 viewer re-creation. I tried some voodoo magic with osgDB::Registry and 
 caching settings, tried to clear gl objects with osg::deleteAllGLObjects() 
 osg::flushAllDeletedGLObjects() etc, but without any luck. I've had different 
 graphics context ids after viewer recreation. In my case problem was solved 
 when using vertex buffer objects instead of display lists, i didnt dig any 
 further after that. IIRC problem was showing itself only on windows, but i 
 cant say for sure now.
 
 Cheers
 
 


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





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


Re: [osg-users] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Sergey Polischuk
I've destroyed complete scene with viewer and graphics context, and recreated 
it all with reading new models from files with disabled cache etc. On first run 
all was ok, and on next runs mesh would look all distorted (some vertices of 
mesh randomly displaced etc). Dont know if it problem with display lists or 
geometry data arrays in osg, but display lists should be brand new each time, 
because i've deleted all opengl objects before shutting down graphics context, 
and new context have different id, also object cache disabled, cleared and 
model reloaded each time from file, so there shouldn't be problem with osg data 
arrays. I have no idea what goes wrong.

Cheers

16.01.2012, 14:52, Chris Denham c.m.den...@gmail.com:
 Hi Hybr,
 Corrupted vertex arrays? Do you mean the OpenSceneGraph geometry data, or a 
 problem with the OGL compiled display list? I've not seen that, and I hope I 
 don't. ;-)
 I'll keep an eye out for trouble though.
 Cheers,
 Chris.

 hybr wrote:

  Hi all

  I'm gonna add my 5 cents on this topic. I was having similar problems in 
 app which recreates viewer in runtime (there are preview window and viewer 
 created when widget shows up), using osg version 3.0(?). In my case problem 
 was not only with textures - i was getting corrupted vertex arrays after 
 viewer re-creation. I tried some voodoo magic with osgDB::Registry and 
 caching settings, tried to clear gl objects with osg::deleteAllGLObjects() 
 osg::flushAllDeletedGLObjects() etc, but without any luck. I've had 
 different graphics context ids after viewer recreation. In my case problem 
 was solved when using vertex buffer objects instead of display lists, i 
 didnt dig any further after that. IIRC problem was showing itself only on 
 windows, but i cant say for sure now.

  Cheers

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

 ___
 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] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Robert Osfield
Hi Chris,

On 16 January 2012 10:39, Chris Denham c.m.den...@gmail.com wrote:
 Yep, I can confirm the return value of  gc-getState()-getContextID() is 
 increasing as you describe for each brower plugin instance created.
 Does that mean I should be ok sharing scengraph between viewers?

It should be OK.  osgViewer hasn't been designed for using of multiple
viewers running in a parallel, but is designed for scene graphs to be
shared between multiple contexts, so as long as the ContextID's a
mapped correctly, as it sounds like they are.

 It certainly seems ok now I've disabled the unref images after apply flag on 
 the textures.

If this is the case then the max number of contexts that the unref
scheme is using is obviously not high enough.  osgViewer will look at
the number of contexts that are active and then using this as a limit.
 Is it that you are creating one viewer and context then drawing
frames, then later creating a new context and draw more frames. In the
later case I can certainly see that if the first frames draw will
release the osg::Image resources assigned to osg::Texture if they are
set up to unref the images, so disabling the unref of images makes
sense.

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


Re: [osg-users] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Robert Osfield
Hi Sergey,

2012/1/16 Sergey Polischuk pol...@yandex.ru:
 I've destroyed complete scene with viewer and graphics context, and recreated 
 it all with reading new models from files with disabled cache etc. On first 
 run all was ok, and on next runs mesh would look all distorted (some vertices 
 of mesh randomly displaced etc). Dont know if it problem with display lists 
 or geometry data arrays in osg, but display lists should be brand new each 
 time, because i've deleted all opengl objects before shutting down graphics 
 context, and new context have different id, also object cache disabled, 
 cleared and model reloaded each time from file, so there shouldn't be problem 
 with osg data arrays. I have no idea what goes wrong.

If you are bypassing much of osgViewer's context management then it's
possible to get the GL obejct caches that the OSG uses out of sync
with what you are doing.  osgViewer does a range of operations to
clean up contexts and make sure the the GL object caches that the OSG
uses are flushed.  If you are manually managing your own contexts then
you'll need to call releaseGLObjects() on your scene graph and call
osg::flushAllDeletedGLObjects(contextID) prior to closing the context,
if it this is outwith your control then calling
discardAllGLObjects(contextID) enables the discarding of all the GL
object caches.

In the OSG the GL object caches are used to avoid problems with
deleting OpenGL objects in other threads than the graphics contexts
ones - as scene graphs can be deleted in any thread you need to cache,
the cache is also used to enable reuse of OpenGL objects like texture
objects and vbo's where possible, this is something that is very
useful for paging performance.

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


[osg-users] Export a vertex animation

2012-01-16 Thread Angel
Hi, I'm Angel,

How I can export a vertex animation from 3d studio to load in osg?
... I usally exported in a ive file format ... maybe I should use a
different file format.

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


Re: [osg-users] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Sergey Polischuk
Hi, Robert

If it'll help to understand where problem might be - there are some details:
I dont use any opengl functions directly, so i think osg management of opengl 
objects should be ok.
Here some code i used to setup viewer on creation:
On viewer init :
graphicsWindow = new 
osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
viewer-getCamera()-setViewport(new 
osg::Viewport(0,0,width(),height()));
viewer-getCamera()-setGraphicsContext(graphicsWindow);
viewer-setThreadingModel(osgViewer::Viewer::SingleThreaded);

prior to destructing viewer i used next piece of code (which wasn't there 
initially, i added this when was trying to fight issue with model corruption, 
and it actually didnt make any difference):

unsigned id = 
m_Ui.viewer-getCamera()-getGraphicsContext()-getState()-getContextID();

m_Ui.viewer-m_GraphicsWindow-makeCurrent();

osg::deleteAllGLObjects(id);

osg::flushAllDeletedGLObjects(id);

osg::discardAllGLObjects(id);

osgDB::Registry::instance()-clearObjectCache();

osgDB::Registry::instance()-clearArchiveCache();

Scene recreated (without reusing old objects) each time new viewer created.

16.01.2012, 15:35, Robert Osfield robert.osfi...@gmail.com:
 Hi Sergey,

 2012/1/16 Sergey Polischuk pol...@yandex.ru:

  I've destroyed complete scene with viewer and graphics context, and 
 recreated it all with reading new models from files with disabled cache etc. 
 On first run all was ok, and on next runs mesh would look all distorted 
 (some vertices of mesh randomly displaced etc). Dont know if it problem with 
 display lists or geometry data arrays in osg, but display lists should be 
 brand new each time, because i've deleted all opengl objects before shutting 
 down graphics context, and new context have different id, also object cache 
 disabled, cleared and model reloaded each time from file, so there shouldn't 
 be problem with osg data arrays. I have no idea what goes wrong.

 If you are bypassing much of osgViewer's context management then it's
 possible to get the GL obejct caches that the OSG uses out of sync
 with what you are doing.  osgViewer does a range of operations to
 clean up contexts and make sure the the GL object caches that the OSG
 uses are flushed.  If you are manually managing your own contexts then
 you'll need to call releaseGLObjects() on your scene graph and call
 osg::flushAllDeletedGLObjects(contextID) prior to closing the context,
 if it this is outwith your control then calling
 discardAllGLObjects(contextID) enables the discarding of all the GL
 object caches.

 In the OSG the GL object caches are used to avoid problems with
 deleting OpenGL objects in other threads than the graphics contexts
 ones - as scene graphs can be deleted in any thread you need to cache,
 the cache is also used to enable reuse of OpenGL objects like texture
 objects and vbo's where possible, this is something that is very
 useful for paging performance.

 Robert.
 ___
 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] Distance point to geometry

2012-01-16 Thread Vincent Bourdier

Hi Robert,

Le 16/01/2012 10:53, Robert Osfield a écrit :

You'd implement a NearestGeometryIntersector that holds a point that
you test your osg::Geometry against, using a osg::TriangleFunctor like
the LineSegmentIntersector would allow you to simply the work down to
just a test of the point against a triangle.  To make things efficient
you'll need to build in testing against the bounding volumes against
the point to decide whether it's contains any points that could be
closer than the current closest distance detected.


Thanks for the idea I'll will start with that.
How could I implement the test against bounding volumes ?
Because it is a visitor, the intersect method will be called on each 
drawable if I understand it well.
Ho can I use the Intersector base to make a previous sort to keep only 
the nearest geometries or drawable base, before having the triangle 
functor traversing the datas ?


Thanks.

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


[osg-users] osgUtil::Optimizer and transparent objects

2012-01-16 Thread Sebastian Messerschmidt

Hello,

I've encountered a problem when using the OpenFlight plugin with 
preserveFace/preserveObject option not used.
If the perserveFace options is not used, the importer uses the Optimizer 
with the following options:


osgUtil::Optimizer::SHARE_DUPLICATE_STATE |
osgUtil::Optimizer::MERGE_GEOMETRY |
osgUtil::Optimizer::MERGE_GEODES |
osgUtil::Optimizer::TESSELLATE_GEOMETRY |
osgUtil::Optimizer::STATIC_OBJECT_DETECTION;


This unfortunately breaks the sorting of transparent objects, as in my 
example all forests (represented by simple quads/polygons) are put into 
one geode.
After digging into the optimizer, I realized, that it will not check if 
the statesets contain any transparency.
Would you consider this rather a bug in the Optimizer or more a 
mis-usage in the OpenFlight importer?


As the osgviewer doesn't disable depth writes for transparent objects, 
the problem is only visible if you use the transparent-bin with depth 
writes off, which leads me to another question:


Would it be wise to turn off depth writes for the transparent bin by 
default ( or a least make it configurable for the osgviewer)?



cheers
Sebastian

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


[osg-users] Help: LineSegmentIntersector operates in GPU or CPU?

2012-01-16 Thread wang shuiying

Hello,

I am really sorry to trouble you again with my naive questions. :-)
(1)Where does LineSegmentIntersector carry out its intersection? In GPU 
or CPU?
(2) How can I know which processes happen in GPU, which ones in CPU? 
(perhaps only draw traversal happens in GPU?)
(3)How can I check the rendering rates of my osg programm? Is it 
invariant during run time or does it remain constant?


Thank you very much in advance!

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


Re: [osg-users] Problem with corrupted textures when sharing instances of models loaded from IVE format.

2012-01-16 Thread Chris Denham
Hi Robert,


robertosfield wrote:
 Is it that you are creating one viewer and context then drawing
 frames, then later creating a new context and draw more frames. In the
 later case I can certainly see that if the first frames draw will
 release the osg::Image resources assigned to osg::Texture if they are
 set up to unref the images, so disabling the unref of images makes
 sense.
 


Yes, that's correct, other instances of the viewer may be created after an 
instance of the viewer has rendered a model, and those later instances may in 
turn need to render the same cached models. So, mystery solved I think. :-)

Thanks.
Chris Denham.

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





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


Re: [osg-users] Help: LineSegmentIntersector operates in GPU or CPU?

2012-01-16 Thread Philipp Moeller
wang shuiying shuiying.w...@fu-berlin.de writes:

 Hello,

 I am really sorry to trouble you again with my naive questions. :-)
 (1)Where does LineSegmentIntersector carry out its intersection? In
 GPU or CPU?

Looking at the implementation of operator() in
LineSegmentIntersection.cpp shows that it performs everything on the
CPU. I could only find a CUDA implementation for the 2D case.

 (2) How can I know which processes happen in GPU, which ones in CPU?
 (perhaps only draw traversal happens in GPU?)
 (3)How can I check the rendering rates of my osg programm? Is it
 invariant during run time or does it remain constant?

osg::Viewer has a osg::Stats property and also comes with
osgViewer::StatsHandler which can print timings as a HUD display.


 Thank you very much in advance!

 Shuiying
 ___
 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] geometry indexes?

2012-01-16 Thread Akilan Thangamani
Hi

Is there any easy way to find vertices's index for the shapes like Cone, Cube 
etc., in osg::shape?
Otherwise, should it be done thru graph note book only?

Thanks

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





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


Re: [osg-users] Distance point to geometry

2012-01-16 Thread Vincent Bourdier

Hi Robert,

Thanks for you help.
I think I can do something not so bad with that.

Regards,
Vincent.

Le 16/01/2012 20:04, Robert Osfield a écrit :

Hi Vincent,

On 16 January 2012 14:55, Vincent Bourdiervincent.bourd...@gmail.com  wrote:

Thanks for the idea I'll will start with that.
How could I implement the test against bounding volumes ?

Have a look how src/osgUtil/InteresectionVisitor.cpp interacts with
the osgUtil::Intersector that is assigned to it, and at the same time
see how LineSegmentIntersectio/PolytopeIntersection etc implements the
various functions that InversectionVisitor.cpp calls.



Because it is a visitor, the intersect method will be called on each
drawable if I understand it well.

It does a bit more than that.  The Intersection traversal has does
intersections tests against bounding spheres, does reprojection of the
intersector into the local coordinate frame beneath transforms.


Ho can I use the Intersector base to make a previous sort to keep only the
nearest geometries or drawable base, before having the triangle functor
traversing the datas ?

It's up to you how you want to manage this.

Robert.

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