Re: [osg-users] Conceptual questions about Cameras in general, and Slave Cameras

2010-10-07 Thread Fred Smith
Hi Robert,

Thanks.
It also works if I just give it the master camera's GraphicsContext, too, which 
is a little bit easier to do.

Fred

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





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


Re: [osg-users] Conceptual questions about Cameras in general, and Slave Cameras

2010-10-06 Thread Fred Smith
This is starting to sink in. Cameras declared in the scene graph are mostly 
fine for me now.

I still have an issue with the Slave camera approach. I'm doing Render to 
texture right now. I would like to give it a go with a Slave camera.

I don't have to define a graphics context for cameras rendering to a FBO if 
they are declared in the scene graph: they just render to their attached color 
buffer.

But one needs to be provided for a slave camera, even though I, too, attach a 
color buffer. Why? I understand this is necessary for PBuffer or direct frame 
buffer rendering, but not with a FBO.
How do I build a graphics context just doing render to texture (FBO+Texture), 
or render to image (FBO+Image)?

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





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


Re: [osg-users] Conceptual questions about Cameras in general, and Slave Cameras

2010-10-06 Thread Robert Osfield
Hi Fred,

For a slave render to texture Camera you simply assign the same
GraphicsWindow/GraphicsContext from the main window. The osgdistortion
example illustrates this in action.

Robert.

On Wed, Oct 6, 2010 at 12:58 PM, Fred Smith osgfo...@tevs.eu wrote:
 This is starting to sink in. Cameras declared in the scene graph are mostly 
 fine for me now.

 I still have an issue with the Slave camera approach. I'm doing Render to 
 texture right now. I would like to give it a go with a Slave camera.

 I don't have to define a graphics context for cameras rendering to a FBO if 
 they are declared in the scene graph: they just render to their attached 
 color buffer.

 But one needs to be provided for a slave camera, even though I, too, attach a 
 color buffer. Why? I understand this is necessary for PBuffer or direct frame 
 buffer rendering, but not with a FBO.
 How do I build a graphics context just doing render to texture (FBO+Texture), 
 or render to image (FBO+Image)?

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





 ___
 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] Conceptual questions about Cameras in general, and Slave Cameras

2010-10-04 Thread Robert Osfield
HI Fred,

On Sun, Oct 3, 2010 at 5:46 PM, Fred Smith osgfo...@tevs.eu wrote:
 1) In the following message:
...

 So why would I want to define a custom scene graph for a slave camera, and 
 how do I do that anyway?

For HUD's and render to texture techniques like distortion correction
are great uses of slave Camera that has it's own scene graph, in both
these cases you also change the ReferenceFrame to be ABSOLUTE_RF so
that the slave also ignores the parents projection and view matrix
settings as well as the the view's scene graph.  Have a look at the
osghud and osgdistortion examples to see this in action.

 2) I am not used to doing this (usually I just create a Camera and add it to 
 a View, the Camera is never referenced anywhere else), but I understand that, 
 as per their osg::Node object model inheritance, Cameras can be added to 
 scene graphs, I guess to position them physically in the 3D space.
 When physically present in the scene graph, how are they being rendered, are 
 they just processed as a regular osg::Group, or is there something else I am 
 missing?

Paul has answered this so I won't dive in.

The only thing I'd add it's conceptually useful to not try and mix
Camera's in the scene graph and Camera's attached to the View(er).
Camera's in the scene graph should be seen as being specific to that
scene i.e. a reflection effect, and overlay a shadow etc.  While
Camera (a master or slave) is about render the view of the scene,
being in stereo, on a powerwall, with distortion correction or just a
plain single window.


 3) osg::Camera indirectly derives from osg::Group. This means I can add child 
 nodes to a Camera. I might sound stupid here but I've never done that. Could 
 you describe to me a usage scenario? If my camera is moving in a car, my car 
 is most likely going to have a top-level group, and my camera will be 
 declared as a leaf node in there... but won't have child nodes. When would a 
 camera have child nodes? Spectacles in front of the field of view? Just want 
 to know if I'm missing something here too.

Paul's already tackled this.

 4) Following up on question #3. I am a bit confused about the ReferenceFrame 
 member of osg::Camera, which is a member inherited from osg::Transform.
 I read somewhere that it is possible to make the Slave camera independent 
 from its master camera by setting its ReferenceFrame (inherited from 
 osg::Transform) to ABSOLUTE_RF. Right?

I believe I've already answered this above :-)

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


Re: [osg-users] Conceptual questions about Cameras in general, and Slave Cameras

2010-10-04 Thread Fred Smith

robertosfield wrote:
 
 The only thing I'd add it's conceptually useful to not try and mix
 Camera's in the scene graph and Camera's attached to the View(er).
 Camera's in the scene graph should be seen as being specific to that
 scene i.e. a reflection effect, and overlay a shadow etc.  While
 Camera (a master or slave) is about render the view of the scene,
 being in stereo, on a powerwall, with distortion correction or just a
 plain single window.
 


I'm still a bit confused about what happens when you have a Camera inside a 
scene graph, how a Camera node behaves graph transformation wise, and the 
rendering story of both Cameras - the top level one, and the one inside the 
graph.

osg::Camera's computeLocalToWorld/computeWorldToLocal implement osg::Transform 
by using their view matrix, exactly like a MatrixTransform node.

Imagine I have the following situation:


Code:
Viewer
+- ViewerView
   +- View
  +- Camera1 (view matrix = identity)
 +- Geode representing a cow
 +- Camera2 (view matrix = identity, RELATIVE_RF)
+- Geode representing a teapot




When I call viewer-frame() here, will Camera1 render the teapot, or will 
Camera1 stop rendering the graph when meeting Camera2?
Similarily, when viewer-frame() is called, will Camera2 do its rendering, for 
instance, if it is configured to render to a texture?
If Camera2 is configured to render to the main frame buffer, just like Camera1, 
what will happen?

Now imagine Camera2 has a different, non-identity view matrix. When I call 
viewer-frame() this time, the teapot will be positioned differently relatively 
to Camera1, exactly as if Camera2 was a MatrixTransform (not Group) node, right?
So Camera2 did its rendering with the teapot in front of it, and Camera1 
rendered the teapot taking into account the transformation defined by the view 
matrix of Camera2. Right?

Cheers,
Fred

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





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


[osg-users] Conceptual questions about Cameras in general, and Slave Cameras

2010-10-03 Thread Fred Smith
Hi,

Just curious about how cameras work in general. I would appreciate some 
clarification. I basically have four questions.

1) In the following message:

http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg14619.html

it is said that a Slave camera can have its own scene graph.

It is my understanding that the reason to be of Slave cameras are that they are 
dependent on their View's master camera, and (almost obviously) point to the 
same scene graph. The usages I can see for them are for:

- 3D vision. The left eye is the master camera of the View, and the right eye 
is a slave camera.
- the rear view mirror in a car.
- Google StreetView-style car cameras, looking left/right/forward/backward/up 
and down.

Again, in these situations, the slave camera obviously has the same scene graph 
as the master camera.

So why would I want to define a custom scene graph for a slave camera, and how 
do I do that anyway?

2) I am not used to doing this (usually I just create a Camera and add it to a 
View, the Camera is never referenced anywhere else), but I understand that, as 
per their osg::Node object model inheritance, Cameras can be added to scene 
graphs, I guess to position them physically in the 3D space.
When physically present in the scene graph, how are they being rendered, are 
they just processed as a regular osg::Group, or is there something else I am 
missing?

3) osg::Camera indirectly derives from osg::Group. This means I can add child 
nodes to a Camera. I might sound stupid here but I've never done that. Could 
you describe to me a usage scenario? If my camera is moving in a car, my car is 
most likely going to have a top-level group, and my camera will be declared as 
a leaf node in there... but won't have child nodes. When would a camera have 
child nodes? Spectacles in front of the field of view? Just want to know if I'm 
missing something here too.

4) Following up on question #3. I am a bit confused about the ReferenceFrame 
member of osg::Camera, which is a member inherited from osg::Transform.
I read somewhere that it is possible to make the Slave camera independent from 
its master camera by setting its ReferenceFrame (inherited from osg::Transform) 
to ABSOLUTE_RF. Right?
But in this case, regarding my question #3, if I *do* have renderable child 
nodes like Geodes below my slave Camera, and this slave Camera is declared 
somewhere in my scene graph, these child nodes will no longer be relatively 
positioned in the tree, since the ReferenceFrame of my camera is ABSOLUTE_RF.
It seems to me that ReferenceFrame will in this situation serve a dual purpose 
for Camera: define the absolute/relative relationship to the master camera AND 
define the relationship of child nodes in the scene graph. This is a bit 
confusing. Since master/slave is a view-only concept, not a scene graph 
concept, I would have put the RELATIVE_RF/ABSOLUTE_RF master/slave somewhere 
else, in osg::View, per slave Camera.

Thank you!

Cheers,
Fred

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





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


Re: [osg-users] Conceptual questions about Cameras in general, and Slave Cameras

2010-10-03 Thread Paul Martz

On 10/3/2010 10:46 AM, Fred Smith wrote:

So why would I want to define a custom scene graph for a slave camera,


The decorator pattern is certainly one example. You'd use two slave Cameras to 
view the same scene two ways using a decorator node.



  and how do I do that anyway?


Camera::addChild( root.get() ).


2) I am not used to doing this (usually I just create a Camera and add it to a 
View, the Camera is never referenced anywhere else), but I understand that, as 
per their osg::Node object model inheritance, Cameras can be added to scene 
graphs, I guess to position them physically in the 3D space.
When physically present in the scene graph, how are they being rendered, are 
they just processed as a regular osg::Group, or is there something else I am 
missing?


During cull, Cameras insert a RenderStage into the render graph. See 
CullVisitor::apply(Camera), and RenderStage, in the osgUtil library. All of the 
Camera's child state and Drawables are listed under that RenderStage. Take a 
look at RenderStage::draw(). This gets executed during draw for every Camera in 
your scene graph, it's where the child Drawables and state are rendered / applied.



3) osg::Camera indirectly derives from osg::Group. This means I can add child 
nodes to a Camera. I might sound stupid here but I've never done that. Could 
you describe to me a usage scenario? If my camera is moving in a car, my car is 
most likely going to have a top-level group, and my camera will be declared as 
a leaf node in there... but won't have child nodes. When would a camera have 
child nodes? Spectacles in front of the field of view? Just want to know if I'm 
missing something here too.


I'd like to correct you: if you have done any OSG rendering at all, you _have_ 
added child nodes to a Camera. When you call Viewer::setSceneData(), you are 
adding a child subgraph to the Viewer's Camera. The Camera's view and projection 
matrices control how its children appear. In your car example, the whole scene 
is a child of the Camera, and you modify the Camera's view matrix in sync with 
the vehicle motion.


Not sure about your last question; perhaps the info above will answer it for 
you, or give you enough info to ask it more clearly.


--
  -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