Re: [osg-users] osg-users Digest, Vol 42, Issue 19

2010-12-10 Thread Torben Dannhauer
Hi delta,

Would it be possible to sign with your real name so everyone can address you 
correctly? :)

What kind of task would you like to solve with TBB?

OSG uses Openthreads for all multithreading issues.

Thank you!

Cheers,
Torben

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





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


[osg-users] [Qt]GraphicWindowEmbedded

2010-12-10 Thread Mat Zanis
Hi,

I have a problem concerning osg integration in Qt. I took the example of 
osgViewerQt as a base and implemented it in my project. When I execute frame 
function into my Qt lib there is no problem, I get my video into my widget. But 
if I call it from the graphic engine of my project ( compiled as a .dll and 
launched into a QThread ) it crashes when I execute the frame. I can set the 
viewer event handlers, call realize() function but it don't execute the frame 
properly.

But if I set up a window with setUpViewInWindow() function into the game 
engine, I can execute the viewer frame from the game engine without any crash. 
I think it's a graphic context problem but I can't put the finger on what is 
the origin of this issue.

Moreover, I found another curious problem maybe relative to the other problem I 
encounter. If, in the QtViewer, I don't set the threading model to SingleThread 
(like it is said into the osgViewerQt example), and I launch the frame from Qt, 
it crashes just like in my other problem (into the frame of ViewerBase, at 
bottom of the function, into the - renderingTraversals() function, at line 
(*itr)-runOperations()). I try using other threading model but in vain.

Is someone understanding what happen and try to guide me to a solution ?

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





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


[osg-users] Visual C++ CLR Windows Forms app using OpenSceneGraph

2010-12-10 Thread Andreas Blassnig
Hi,

i work with osg for about 3 month now using it with win32 console apps and mfc. 
now i want to use an osg visualization window in a windows forms project as a 
small window in the main window. I am thinking of a panel or a picture box to 
define the rect for the visualization surface, but in the moment i have no idea 
how it will get to run. if anyone has any ideas or an example solution it would 
help me very much!

Thank you!

Cheers,
Andreas

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





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


[osg-users] Question about camera autoComputeHomePosition

2010-12-10 Thread Werner Modenbach
I have a question about above function.

In my application on initialization I call:
   getCamera()-setViewport(new osg::Viewport(0, 0, width(), height()));
   getCamera()-setProjectionMatrixAsPerspective(20.0f,
  
static_castdouble(width())/static_castdouble(height()),
  0.001f, 1.0f);
   getCameraManipulator()-setAutoComputeHomePosition(true);

This sequence makes my scene to be automatically scaled to fill the window.
When changing the angle from 20.0 to some larger value the scene just apears 
smaller and vice versa.
What I expected is the calculation of the camera/eye distance comes out 
different so the scene is filling the window again.
Obviously there is a misunderstanding from my side.

I came to the problem when trying to calculate and set a distance manually for 
having the bounding box center plane of the scene to appear in original 
size.  The distance should be 

d = widthMM / (2.0 * tan (alfa/2.0))

widthMM = window width in mm
alfa = viewing angle used in setProjectionMatrixAsPerspective converted to 
radians.
This calculation really shows my scene always in the same size, unfortunately 
not the correct one. Again I don't understand things here.
I think there is a general misunderstanding from my side.

Thanks for any hints.

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


Re: [osg-users] How to set camera focal length

2010-12-10 Thread Mourad Boufarguine
Hi Igor,


 But i still can't set up the position and rotation of the viewer's camera.


 this-_viewer.getCamera()-setReferenceFrame(::osg::Transform::ABSOLUTE_RF);
 this-_viewer.getCamera()-setViewMatrix(::osg::Matrix::translate(0.5, 0.3,
 0.1));

 this does nothing.

 My guess is becase i also have to call:

 ::osg::ref_ptr ::osgGA::KeySwitchMatrixManipulator keyswitchManipulator =
 new ::osgGA::KeySwitchMatrixManipulator;

 keyswitchManipulator-addMatrixManipulator( '1', Trackball, new
 ::osgGA::TrackballManipulator() );

 this-_viewer.setCameraManipulator( keyswitchManipulator.get() );

 or the offscreen capture doesn't render the scene, just an empty
 background. It looks like viewer needs a camera manipulator or it won't
 render the scene.


 Is it at all possible to move the camera programmatically after a camera
 manipulator has been set for the viewer? Or can i avoid creating a camera
 manipulator?


Well, it seems like the cameramanipulator is causing this. To define
manually a view matrix for the camera viewer, you need eigther not to use a
camera manipulator or to set the second parameter of
Viewer::setCameraManipulator (resetPosition)  to false.

Be aware that in case you don't define a camera manipulator, calling
Viewer::run() will automatically add a TrackballManipulator. In this case,
just replace the Vewer::run() call by the rendering loop :

while(!viewer.done())
{
viewer.frame();
}

Another possible issue is the view matrix itself. If you don't see the
scene, it is generally due to a wrong view Matrix.

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


[osg-users] Problim finding font

2010-12-10 Thread Alex (software)
Hi folks,
I have a strange problem with loading. On my normal machine everything works 
find. Fonts are found where they are. (Linux  2.6.34.7-0.5-desktop openSUSE 
11.3 (x86_64))

Hoever it does not work on the following machine Linux 2.6.26-1-686 Debian 
Lenny.

The error is the following:

Warning: Could not find plugin to read objects from file 
./../share/OpenWalnut/fonts/LiberationMono-Bold.ttf.

The fonts are exactly where the program tries to find them.

Any idea why the fonts are found on one machine and not on the other?

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


Re: [osg-users] Problim finding font

2010-12-10 Thread Werner Modenbach
Are you sure, freetype is installed on the other machine?

Am Freitag, 10. Dezember 2010, 12:54:28 schrieb Alex (software):
 Hi folks,
 I have a strange problem with loading. On my normal machine everything
 works find. Fonts are found where they are. (Linux  2.6.34.7-0.5-desktop
 openSUSE 11.3 (x86_64))
 
 Hoever it does not work on the following machine Linux 2.6.26-1-686 Debian
 Lenny.
 
 The error is the following:
 
 Warning: Could not find plugin to read objects from file
 ./../share/OpenWalnut/fonts/LiberationMono-Bold.ttf.
 
 The fonts are exactly where the program tries to find them.
 
 Any idea why the fonts are found on one machine and not on the other?
 
 Thanks,
 Alex
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


-- 
TEXION Software Solutions

TEXION GmbH -  Rotter Bruch 26a  -  D 52068 Aachen - HRB 14999 Aachen
Fon: +49 241 475757-0, Fax: +49 241 475757-29, web: http://www.texion.eu

Geschäftsführer/Managing Director: Werner Modenbach
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Problim finding font

2010-12-10 Thread Alberto Luaces
Alex (software) writes:

 Hi folks,
 I have a strange problem with loading. On my normal machine everything works 
 find. Fonts are found where they are. (Linux  2.6.34.7-0.5-desktop openSUSE 
 11.3 (x86_64))

 Hoever it does not work on the following machine Linux 2.6.26-1-686 Debian 
 Lenny.

 The error is the following:

 Warning: Could not find plugin to read objects from file 
 ./../share/OpenWalnut/fonts/LiberationMono-Bold.ttf.

 The fonts are exactly where the program tries to find them.

 Any idea why the fonts are found on one machine and not on the other?

You can find out inspecting the output of strace:

strace -e trace=access your_program

-- 
Alberto

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


Re: [osg-users] Advice on Shader usage and osgShadow

2010-12-10 Thread Werner Modenbach
Hi!

Hmmm... I haven't looked at ViewDependentShadow so far.
I'm a little confused now.
How are things workingh together?
I have a ShadowScene and set the ShaderTechnique with my own class derived 
from SoftShadowMap.
I wrote virtual methods for createShaders and createUniforms for support of my 
shaders.
ShaderTechnique is having its shaders and now I see ViewDependentShadow is 
also having a different set of shaders. When is ViewDependentShadow coming 
into the game?

Many  :-(

Can anyone give me some explanation please?

Thanks in advance

- Werner - 

Am Donnerstag, 9. Dezember 2010, 15:18:15 schrieb Jean-Sébastien Guay:
 Hello Werner,
 
  Actually I'd like to be more flexible in the use of the ShaderTechnic and
  I ask myself if it is possible to use the standard ShadowTechnics and
  attach my Shaders to my user scene child somehow.
 
 There is no problem with this, we do it ourselves.
 
 The only thing to be aware of is that anytime you have a shader on a
 child node somewhere in your graph, if you want it to have shadows then
 you need to use the same shadow mapping code as the ShadowTechnique's
 shaders. So it may be easier to do as the ViewDependentShadow classes
 do: separate the main shader and the shadow shader (for both stages,
 vertex and fragment), and just have some function in your code that when
 creating a new osg::Program, will add the user's shaders plus the shadow
 shaders. The user's shaders would just have to call the function(s)
 defined in the shadow shaders at the appropriate time.
 
 Otherwise you can of course copy-paste the shadow shader code into your
 own shaders instead, but that is error-prone and if you decide you want
 to change something (like filter the shadows, or whatever) you have to
 change it in many places.
 
 Hope this helps,
 
 J-S
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] TexGen for screen coordinates.

2010-12-10 Thread Chris Denham
I've been trying to apply a 2d texture to an object where I want the UVs to 
correspond to screen position. A bit like using EYE_LINEAR texgen, but with the 
texture projected 'orthographically' through the screen.
What I want would in effect be like applying the texture so it always spans the 
window, but without applying the perspective of the camera. I guess, a bit like 
using the texture as a stencil.

I've tried using EYE_LINEAR, and that very nearly does what I want, but I want 
to remove the effect of perspective on the way the texcoords are calculated.

In other words, I think I want calculated texture UV's to be something like:
texcoord.x = (worldPosition * (projectionMatrix * modelViewMatrix)).x
texcoord.y = (worldPosition * (projectionMatrix * modelViewMatrix)).y

What's the best way to implement this without using stencil buffer or shaders?
Is there a way to do it by adjusting the texture matrix object to remove the 
perspective projection?
Or would it be better to recalculate texCoords on geometries prior to each 
frame?

Hope this makes some kind of sense.
 
Cheers,
Chris Denham

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





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


Re: [osg-users] rain/snow accumulation on the screen

2010-12-10 Thread Arif Yetkin Sarı
Hi all, I am also looking into this issue like Nik.

the needs are:
1.Rain drops must appear on the screen when in fps (car driving) camera mode
2.They dont need to move, but their numbers will increase in time and make it 
difficult to see the environment.
3.When activated a wiper will rotate on the screen, clearing the raindrops as 
it touches them.

similarly snow will accumulate on the windshield and wiper will clean them too.

Can this be done with osg particle classes? What kind of new functionality may 
be needed if particle system is not enough to handle these tasks ?
Or what specific features of osg can accomplish such tasks?

Thanks in advance for any hints.

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





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


Re: [osg-users] Problim finding font

2010-12-10 Thread Alex (software)
Hi Werner,
it seems to be installed: I can find libfreetype6 in version 2.3.7. On the 
other machine it is 2.3.12. Maybe this is the problem I will have to check this.

Cheers,
Alex

- original message 

Subject: Re: [osg-users] Problim finding font
Sent: Fri, 10 Dec 2010
From: Werner Modenbachwerner.modenb...@texion.eu

 Are you sure, freetype is installed on the other machine?
 
 Am Freitag, 10. Dezember 2010, 12:54:28 schrieb Alex (software):
  Hi folks,
  I have a strange problem with loading. On my normal machine everything
  works find. Fonts are found where they are. (Linux  2.6.34.7-0.5-desktop
  openSUSE 11.3 (x86_64))
  
  Hoever it does not work on the following machine Linux 2.6.26-1-686
 Debian
  Lenny.
  
  The error is the following:
  
  Warning: Could not find plugin to read objects from file
  ./../share/OpenWalnut/fonts/LiberationMono-Bold.ttf.
  
  The fonts are exactly where the program tries to find them.
  
  Any idea why the fonts are found on one machine and not on the other?
  
  Thanks,
  Alex
  ___
  osg-users mailing list
  osg-users@lists.openscenegraph.org
  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 
 
 -- 
 TEXION Software Solutions
 
 TEXION GmbH -  Rotter Bruch 26a  -  D 52068 Aachen - HRB 14999 Aachen
 Fon: +49 241 475757-0, Fax: +49 241 475757-29, web: http://www.texion.eu
 
 Geschäftsführer/Managing Director: Werner Modenbach
 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
 

--- original message end 

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


Re: [osg-users] Advice on Shader usage and osgShadow

2010-12-10 Thread Jean-Sébastien Guay

Hi Werner,


I'm a little confused now.
How are things workingh together?
I have a ShadowScene and set the ShaderTechnique with my own class derived
from SoftShadowMap.
I wrote virtual methods for createShaders and createUniforms for support of my
shaders.
ShaderTechnique is having its shaders and now I see ViewDependentShadow is
also having a different set of shaders. When is ViewDependentShadow coming
into the game?


Yes, it seems you're confused indeed :-) Let's go back to basics and 
work from there.


You use osgShadow by adding a ShadowedScene in your scene graph, and 
setting a ShadowTechnique on that ShadowedScene. SoftShadowMap is one 
possible shadow technique, and the ViewDependentShadow ones are others 
(StandardShadowMap, MinimalShadowMap*, LightSpacePerspectiveShadowMap, 
etc.).


I was just using those shadow techniques as an example because you 
hadn't mentioned which one you were using, just that you had subclassed 
an existing one...


But what I said still applies. The general idea is that you can attach 
shaders (actually an osg::Program containing shaders) at any node in 
your graph, and the osg::Program will be inherited downwards like any 
state. The ShadowTechnique activates its own shaders at the 
ShadowedScene level. So if no other nodes below the ShadowedScene have 
an osg::Program, the one from the ShadowTechnique will apply to the 
whole subgraph. But if a node below the ShadowedScene has its own 
osg::Program, it will override the one from above for its own subgraph 
(subject to the same rules of state inheritance as any other 
StateAttribute, for example use of PROTECTED and OVERRIDE...).


But the important part is, if you want your nodes below the 
ShadowedScene to have their own shaders AND have shadows, they need to 
do the shadow lookup the same way as the shaders that your 
ShadowTechnique has. This will generally be in 2 parts, vertex and 
fragment shader:


If your ShadowTechnique's Program has a vertex shader (some do, some 
don't), it will generally calculate texture coordinates for the shadow 
map's texture unit. You need to do this in your own vertex shader too.


If your ShadowTechnique's Program has a fragment shader (most do), it 
will generally do a texture lookup in the shadow map's texture unit and 
decide whether to use only ambient or full lighting depending on the 
result of this lookup (whether the fragment is in shadow or not).


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Advice on Shader usage and osgShadow

2010-12-10 Thread Werner Modenbach
Hi J-S,

Thank you very much! This was an excellent overview. GREAT !!!

Just one little last question:
If I understand right whatever ShadowTechnique is used the result when 
reaching my scenes user root node (child of ShadowScene) there will be the 
shadow texture which I can use in always the same way.
Since the shader code of StandardShadowMap seems to be very complete I could 
cut and paste it, do my extensions in there and add the program to the 
StateSet of my node.
This should work in a flexible way with any Shadowtechnique used?

- Werner -

Am Freitag, 10. Dezember 2010, 14:50:37 schrieb Jean-Sébastien Guay:
 Hi Werner,
 
  I'm a little confused now.
  How are things workingh together?
  I have a ShadowScene and set the ShaderTechnique with my own class
  derived from SoftShadowMap.
  I wrote virtual methods for createShaders and createUniforms for support
  of my shaders.
  ShaderTechnique is having its shaders and now I see ViewDependentShadow
  is also having a different set of shaders. When is ViewDependentShadow
  coming into the game?
 
 Yes, it seems you're confused indeed :-) Let's go back to basics and
 work from there.
 
 You use osgShadow by adding a ShadowedScene in your scene graph, and
 setting a ShadowTechnique on that ShadowedScene. SoftShadowMap is one
 possible shadow technique, and the ViewDependentShadow ones are others
 (StandardShadowMap, MinimalShadowMap*, LightSpacePerspectiveShadowMap,
 etc.).
 
 I was just using those shadow techniques as an example because you
 hadn't mentioned which one you were using, just that you had subclassed
 an existing one...
 
 But what I said still applies. The general idea is that you can attach
 shaders (actually an osg::Program containing shaders) at any node in
 your graph, and the osg::Program will be inherited downwards like any
 state. The ShadowTechnique activates its own shaders at the
 ShadowedScene level. So if no other nodes below the ShadowedScene have
 an osg::Program, the one from the ShadowTechnique will apply to the
 whole subgraph. But if a node below the ShadowedScene has its own
 osg::Program, it will override the one from above for its own subgraph
 (subject to the same rules of state inheritance as any other
 StateAttribute, for example use of PROTECTED and OVERRIDE...).
 
 But the important part is, if you want your nodes below the
 ShadowedScene to have their own shaders AND have shadows, they need to
 do the shadow lookup the same way as the shaders that your
 ShadowTechnique has. This will generally be in 2 parts, vertex and
 fragment shader:
 
 If your ShadowTechnique's Program has a vertex shader (some do, some
 don't), it will generally calculate texture coordinates for the shadow
 map's texture unit. You need to do this in your own vertex shader too.
 
 If your ShadowTechnique's Program has a fragment shader (most do), it
 will generally do a texture lookup in the shadow map's texture unit and
 decide whether to use only ambient or full lighting depending on the
 result of this lookup (whether the fragment is in shadow or not).
 
 Hope this helps,
 
 J-S


-- 
TEXION Software Solutions

TEXION GmbH -  Rotter Bruch 26a  -  D 52068 Aachen - HRB 14999 Aachen
Fon: +49 241 475757-0, Fax: +49 241 475757-29, web: http://www.texion.eu

Geschäftsführer/Managing Director: Werner Modenbach
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Problem with Multiple Cameras drawing in the same viewport.

2010-12-10 Thread George Bekos
Hello all,

I am new to OSG and I am having trouble implementing something in my 
scenegraph. Because my graph is a little complicated I will give you a simpler 
version of it focusing on the main concept. I have a scene with a model. This 
model consists of 3 submeshes. For each submesh I do three passes. These passes 
are the exact same for all submeshes. Here is the desired rendering order:
FirstMesh-pass1, FirstMesh-pass2, FirstMesh-pass3, SecondMesh-pass1, 
SecondMesh-pass2, ... etc
Any other rendering order won't work. (this is how the algorithm works)

Because the statesets and a lot of other nodes are the same I want to share 
them between my passes. Because of this, at the start of my graph I place 3 
osg::Cameras with different culling masks. And then I set different node mask 
to each of my submeshes. So, each camera will draw a different submesh. 

What I get is a very strange effect. Looks like it is something wrong with the 
depth buffer.  (keep in mind that depth test is enabled and depth writes are 
on). Looks like having multiple cameras drawing at the same viewport somehow 
does not work. Do I miss something? Most likely I just misuse the osg::Cameras 
or I don't really understand their concept. Looking the diagram and the code it 
is easy to figure out what exactly I want to do. Do you have any suggestion 
around this problem? Thanks a lot for your time.

Cheers,
George

PS: In the source code Imagine that the osg::Group named 'secondaryRoot' is a 
black box containing my 3 passes/renderbins

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




Attachments: 
http://forum.openscenegraph.org//files/main_146.cpp
http://forum.openscenegraph.org//files/diagram_985.png


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


Re: [osg-users] Advice on Shader usage and osgShadow

2010-12-10 Thread Jean-Sébastien Guay

Hi Werner,


If I understand right whatever ShadowTechnique is used the result when
reaching my scenes user root node (child of ShadowScene) there will be the
shadow texture which I can use in always the same way.
Since the shader code of StandardShadowMap seems to be very complete I could
cut and paste it, do my extensions in there and add the program to the
StateSet of my node.
This should work in a flexible way with any Shadowtechnique used?


Instead, if you've subclassed from SoftShadowMap, I'd start from that 
shader and work from there. You can experiment of course.


But yes, what you say is true, since the ShadowTechnique binds the 
shadow map texture at the ShadowedScene level (same as the osg::Program 
containing the shadow mapping shader(s)), you can use that texture unit 
at any node below the ShadowedScene (as long as another node doesn't 
bind another texture in the shadow map's texture unit! - again the 
StateAttribute inheritance rules apply).


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to set camera focal length

2010-12-10 Thread Igor Galochkin
just found where the problem is:
Viewer.cpp, line 1023:  inside viewer.updateTraversals

  if (_cameraManipulator.valid())
{
setFusionDistance( getCameraManipulator()-getFusionDistanceMode(),
getCameraManipulator()-getFusionDistanceValue() );

_camera-setViewMatrix(_cameraManipulator-getInverseMatrix());
}

So, at each frame the camera's matrix is overwritten by a new matrix which is 
taken from MatrixManipulator.

I still wonder why viewer doesn't render anything at all (black image) if no 
MatrixManipulator is set.

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





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


[osg-users] texture coordinate specification

2010-12-10 Thread Sajjadul Islam
Hi forum,

I was going through the example osggameoflife and pondered over  the texture 
specification part to visulize  the game.

I used to know that the texture coordinate s,t,q all has to be between 0.0 and 
1.0.

At one part of the example the texture coordinate has been specified as 
foollows:

tcoords-push_back(0,0,0);
tcoords-push_back(width,0,0);
tcoords-push_back(width,0,height);
tcoords-push_back(0,0,height);

The width and height returns values more than 1 , like 128 X 128

Would be nice to have some explanation.


Thank you!

Cheers,
Sajjadul

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





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


Re: [osg-users] How to set camera focal length

2010-12-10 Thread Jean-Sébastien Guay

Hello Igor,


So, at each frame the camera's matrix is overwritten by a new matrix which is 
taken from MatrixManipulator.


In the past few hours two people on this list told you that if you 
wanted to use your own view matrix you needed to set no camera 
manipulator... (Paul Martz and Mourad Boufarguine) Was that not clear 
enough?


Go back to read their posts please. They're telling you exactly what you 
just found...



I still wonder why viewer doesn't render anything at all (black image) if no 
MatrixManipulator is set.


Most likely your view matrix calculation has an error.

If you really think something is wrong, make a small example that 
demonstrates this with the least possible code and we can have a look, 
but otherwise these are things that are used by hundreds of people and 
projects around the world so it's unlikely there's a bug concerning this.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] texture coordinate specification

2010-12-10 Thread Jean-Sébastien Guay

Hi Sajjdul,


I used to know that the texture coordinate s,t,q all has to be between 0.0 and 
1.0.


No, it does not have to be between 0.0 and 1.0. It can be any value.

For Texture1D/2D/3D, what happens outside the 0.0 to 1.0 range is 
specified by the wrap mode (texture-setWrap(...)). You can set it to 
REPEAT, CLAMP, CLAMP_TO_BORDER, CLAMP_TO_EDGE or MIRROR. See the OpenGL 
spec for what each wrap mode does.


For TextureRectangle, the rules are different. The texture coordinates 
are defined in image units, so if you want a 128x128 texture to be fully 
visible on a quad, you need the texture coordinates to span the 0.0 to 
128.0 range in both directions. Outside the image size range, the 
wrapping mode applies like for TextureXD.


I expect the osggameoflife example uses TextureRectangle with 128x128 
textures...


Check an OpenGL book for more details, this is not really specific to 
OSG but is true for any OpenGL-based app.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] change model dynamically

2010-12-10 Thread lucie lemonnier
Hi,

I want to change the 3D model dynamically at the runtime.
I have inatialize my node  at : 
_model = new osg::Node();
_model = osgDB::readNodeFile(model1.osg);

and when I do a particular action, I would like that the 3D model changes, I 
write this : 
_model = osgDB::readNodeFile(model2.osg);
But it doesn't work!
Would you have an idea?

Thank you!

Cheers,
lucie

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





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


Re: [osg-users] change model dynamically

2010-12-10 Thread Vincent Bourdier
Hi Lucie,

I think this is a simple C++ issue.

First you create _model which is a pointer on a node.
Then you make a new node and set _model to store its adress.
Next, you load a new node and set _model to store it again. So the first
thing is, you don't need to do _model = new osg::Node();

So now _model is a pointer to a memory area where model1.osg is loaded.
Let's assume that you make something like view-setSceneData(_model).

Now, the view root node, which is also a pointeur, contain the same adress
than _model, where model1.osg is loaded.

Last, when you load a new model and set _model to store this new adress, you
are not modifying the viewer root node.

You should do a viewer-setSceneData(osgDB::readNodeFile(model2.osg)); or
maybe a group-replaceChild(_model,osgDB::readNodeFile(model2.osg));

Don't hesitate to take a piece of paper to draw some memory allocation and
pointers to understand what is really done.

I hope this will help you.

Regards,
Vincent.


2010/12/10 lucie lemonnier lucielemonn...@hotmail.fr

 Hi,

 I want to change the 3D model dynamically at the runtime.
 I have inatialize my node  at :
 _model = new osg::Node();
 _model = osgDB::readNodeFile(model1.osg);

 and when I do a particular action, I would like that the 3D model changes,
 I write this :
 _model = osgDB::readNodeFile(model2.osg);
 But it doesn't work!
 Would you have an idea?

 Thank you!

 Cheers,
 lucie

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





 ___
 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] How to set camera focal length

2010-12-10 Thread Igor Galochkin

Skylark wrote:
 
 Most likely your view matrix calculation has an error.
 


Yes, just found out the view matrix was wrong and the image was black because 
the camera was inside some object or something, and i first thought i am 
reading from a wrong buffer.

Sorry guys for bothering you with such simple stuff.

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





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


Re: [osg-users] Geometry and setUseDisplayList(false)

2010-12-10 Thread Stephan Maximilian Huber
Am 10.12.10 16:32, schrieb Gabriel Nützi:
 Hi everybody
 
 I have a quite strange problem, I am a newbie, and probably it is a simple 
 setting, which I do not know:
 
 I have subclassed from osg:Geometry and  have set up in this class my Mesh 
 which I want to render... the thing works fine, except, that when I use 
 setUseDisplayList(false), (because I update my vertices every rendering loop 
 in this viewer loop)  , my mesh is rendered, but it seems that there is a 
 somehow ,depending on the camera position, a bounding volume and the mesh 
 gets sometimes  not rendered looks like  it is culled somehow...

if you update your geometry, you must update its boundingbox. just call
dirtyBound() on your geometry, implement computeBound() in your subclass
or provide a maximum boundingbox with setInitialBound() when creating
your object.

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


Re: [osg-users] How to set camera focal length

2010-12-10 Thread Jean-Sébastien Guay

Hi Igor,


Yes, just found out the view matrix was wrong and the image was black because 
the camera was inside some object or something, and i first thought i am 
reading from a wrong buffer.


Glad to know you found the problem.


Sorry guys for bothering you with such simple stuff.


It's not bothering with simple stuff that's the problem, we're here to 
help, but you have to read the replies in full to be able to profit from 
what we're saying. I really got the impression that you had ignored 
Paul's and Mourad's answers and gone to search for the answer yourself...


Don't hesitate to ask questions, we're always glad to help.

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] Making sure that reflection texture only draws if mirror is visible.

2010-12-10 Thread Frank Sullivan
Greetings,

I have some mirrors in my scene, which use RTT for reflections. I'd like to 
make sure that, if the mirror isn't visible, the RTT pass doesn't happen. A 
simple frustum check should be fine. If the mirror is in the scene camera's 
frustum, it would be okay to render the reflection texture even if the mirror 
itself is occluded.

So what I have right now is a MatrixTransform node that is the parent of the 
whole mirror object sub-tree. I give this MatrixTransform a call callback, 
which renders the reflection texture before traversing to draw the mirror 
itself. 

What I'd like to do is add a frustum test here, so I can avoid doing the 
reflection RTT if the child sub-tree isn't even viewable by the camera. Is this 
possible?

Thanks,
Frank

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





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


Re: [osg-users] Making sure that reflection texture only draws if mirror is visible.

2010-12-10 Thread Jean-Sébastien Guay

Hi Frank,


What I'd like to do is add a frustum test here, so I can avoid doing the 
reflection RTT if the child sub-tree isn't even viewable by the camera. Is this 
possible?


In your cull callback you can cast the osg::NodeVisitor to a 
osgUtil::CullVisitor, and I think you can then call isCulled(node) to 
see if the node your callback is on would be culled or not (given the 
current settings of the CullVisitor, so whether culling is enabled, uses 
drawables or primitives, small feature culling etc.).


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Making sure that reflection texture only draws if mirror is visible.

2010-12-10 Thread Frank Sullivan
Oh, nice, thanks!

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





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


Re: [osg-users] Question about camera autoComputeHomePosition

2010-12-10 Thread Steven Powers
I think you misunderstand how the projection matrix works

setProjectionMatrixAsPerspective is defined with the parameters (vFov, aspect, 
near, far)

vFov sets the vertical field of view of the perspective meaning you will have a 
wider viewing angle the larger the value gets.

aspectRatio is used to determine the horizontal FOV

near defines the near clipping plane

far defines the far clipping plane

Increasing the vFOV will make items in the scene appear shorter away but their 
distance from the camera will remain unchanged. 

Cheers,
Steven

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





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


Re: [osg-users] rain/snow accumulation on the screen

2010-12-10 Thread Steven Powers
I'm going to preface my comment by saying I've never done an effect like this 
before. I am, however, interested in how this could be accomplished.

Adding in the wiper effect adds a particularly difficult layer of complexity to 
an effect like this. 

I would still suggest using a shader to do this effect. You would have to 
update the wiper's position as a uniform value per frame. You can then choose 
to apply the raindrop texture to pixels on one side of the wiper and then dont 
apply the texture to pixels on the other side of the wiper.

You can also do this if your procedurally creating the raindrops on the fly.

Cheers,
Steven

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





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


Re: [osg-users] TexGen for screen coordinates.

2010-12-10 Thread Paul Martz

On 12/10/2010 5:21 AM, Chris Denham wrote:

I've been trying to apply a 2d texture to an object where I want the UVs to 
correspond to screen position. A bit like using EYE_LINEAR texgen, but with the 
texture projected 'orthographically' through the screen.
What I want would in effect be like applying the texture so it always spans the 
window, but without applying the perspective of the camera. I guess, a bit like 
using the texture as a stencil.

I've tried using EYE_LINEAR, and that very nearly does what I want, but I want 
to remove the effect of perspective on the way the texcoords are calculated.

In other words, I think I want calculated texture UV's to be something like:
texcoord.x = (worldPosition * (projectionMatrix * modelViewMatrix)).x
texcoord.y = (worldPosition * (projectionMatrix * modelViewMatrix)).y

What's the best way to implement this without using stencil buffer or shaders?
Is there a way to do it by adjusting the texture matrix object to remove the 
perspective projection?
Or would it be better to recalculate texCoords on geometries prior to each 
frame?

Hope this makes some kind of sense.


With those restrictions, it seems like the texture matrix is your only path to a 
solution, though I couldn't type it here off the top of my head. It would take 
some dev time to get it right.


What you want to do would be trivial with a shader. Is there a reason why you've 
ruled out use of shaders for this problem?


--
  -Paul Martz  Skew Matrix Software
   http://www.skew-matrix.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] TexGen for screen coordinates.

2010-12-10 Thread Chris Denham

Paul Martz wrote:
 On 12/10/2010 5:21 AM, Chris Denham wrote:
 
  I've been trying to apply a 2d texture to an object where I want the UVs to 
  correspond to screen position. A bit like using EYE_LINEAR texgen, but with 
  the texture projected 'orthographically' through the screen.
  What I want would in effect be like applying the texture so it always spans 
  the window, but without applying the perspective of the camera. I guess, a 
  bit like using the texture as a stencil.
  
  I've tried using EYE_LINEAR, and that very nearly does what I want, but I 
  want to remove the effect of perspective on the way the texcoords are 
  calculated.
  
  In other words, I think I want calculated texture UV's to be something like:
  texcoord.x = (worldPosition * (projectionMatrix * modelViewMatrix)).x
  texcoord.y = (worldPosition * (projectionMatrix * modelViewMatrix)).y
  
  What's the best way to implement this without using stencil buffer or 
  shaders?
  Is there a way to do it by adjusting the texture matrix object to remove 
  the perspective projection?
  Or would it be better to recalculate texCoords on geometries prior to each 
  frame?
  
  Hope this makes some kind of sense.
  
 
 With those restrictions, it seems like the texture matrix is your only path 
 to a 
 solution, though I couldn't type it here off the top of my head. It would 
 take 
 some dev time to get it right.
 
 What you want to do would be trivial with a shader. Is there a reason why 
 you've 
 ruled out use of shaders for this problem?
 
 -- 
 -Paul Martz  Skew Matrix Software
 http://www.skew-matrix.com/
 


Thanks Paul,
I may use a shader if it comes down to it, but I was trying (if possible) to 
get a solution that works on Joe Public's bargin basement laptop that probably 
has poor (if any) shader support.

I have experimented with texmat object to get the projection right, but I can't 
seem to get the matrix right (probably cos of my flakey maths). Maybe I'll post 
a cut down example an someone can see if they spot the problem.

I've had some success with recalculating the texcoords on geometries and 
assigning them with UVs based on screen coords. It's very nearly what I want 
but I'm getting some odd distortions due to uv interpolation (I think). 
Possibly a result of the texture mapping perspective correction, though I tried 
switching that off with GL_PERSPECTIVE_CORRECTION_HINT = GL_FASTEST to no avail 
 :( 

Ho hum maybe as you say, a shader is the answer, well, if I can make it 
fail tidy on old craptops.

Cheers
Chris.

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





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