[osg-users] Flipping the normals

2007-08-28 Thread Michele Bosi
Hello,
I've a relatively easy task to accomplish, that is to render a mesh both
from inside and outside.
To do this i put the mesh under two different Geodes, in one i set the front
face to clock wise on the other I set the front face to counter clock
wise turning on the backface culling (or putting the object into a single
Geode turning off the backface culling). The problem is that in one case
(when I render the interior of the mesh) the polygons are not lit since
the normals are (of course) not flipped, that is they remain oriented
outward.
My question is: how can I flip the normals? should I create two distinct
meshes, one with the original normals and the other with inverted normals
(modifying manually the normal buffers, and doubling the memory usage) or
there is a more elegant way to do that, for example a node/state like
GL_PLEASE_FLIP_MY_NORMALS that can take care of this task automatically?
Cheers,
Mike
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Flipping the normals

2007-08-28 Thread Mike Wittman
Hi Mike,

 

Take a look at OpenGL's two-sided lighting support via
glLightModel/GL_LIGHT_MODEL_TWO_SIDE (and exposed in OSG with
osg::LightModel).  I think that's the more elegant solution your looking
for.

 

 

Mike Wittman

[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 

___

Seismic Micro-Technology, Inc.

8584 Katy Freeway, Suite 400 / Houston, Texas 77024

Tel.  +1 (713) 464-6188

Fax. +1 (713) 464-6440

Web:  www.seismicmicro.com
blocked::blocked::http://www.seismicmicro.com 

___

Seismic through Simulation with KINGDOM, (RC)2, and SURE! - CONTACT US
TODAY for more information.

 



From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michele
Bosi
Sent: Tuesday, August 28, 2007 4:45 PM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] Flipping the normals

 

Hello,
I've a relatively easy task to accomplish, that is to render a mesh both
from inside and outside. 
To do this i put the mesh under two different Geodes, in one i set the
front face to clock wise on the other I set the front face to counter
clock wise turning on the backface culling (or putting the object into
a single Geode turning off the backface culling). The problem is that in
one case (when I render the interior of the mesh) the polygons are not
lit since the normals are (of course) not flipped, that is they remain
oriented outward. 
My question is: how can I flip the normals? should I create two distinct
meshes, one with the original normals and the other with inverted
normals (modifying manually the normal buffers, and doubling the memory
usage) or there is a more elegant way to do that, for example a
node/state like GL_PLEASE_FLIP_MY_NORMALS that can take care of this
task automatically? 
Cheers,
Mike

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


Re: [osg-users] Flipping the normals

2007-08-28 Thread Gerrick Bivins
Sounds like you want something like:

osg::ref_ptrosg::LightModel lightModel = new osg::LightModel;
lightModel-setTwoSided(true);
myTwoSidedGeode-getOrCreateStateSet()-setAttribuiteAndModes(lightModel.get
()*);*
**
Might not be the exact syntax but pretty close.


On 8/28/07, Michele Bosi [EMAIL PROTECTED] wrote:

 Hello,
 I've a relatively easy task to accomplish, that is to render a mesh both
 from inside and outside.
 To do this i put the mesh under two different Geodes, in one i set the
 front face to clock wise on the other I set the front face to counter
 clock wise turning on the backface culling (or putting the object into a
 single Geode turning off the backface culling). The problem is that in one
 case (when I render the interior of the mesh) the polygons are not lit
 since the normals are (of course) not flipped, that is they remain oriented
 outward.
 My question is: how can I flip the normals? should I create two distinct
 meshes, one with the original normals and the other with inverted normals
 (modifying manually the normal buffers, and doubling the memory usage) or
 there is a more elegant way to do that, for example a node/state like
 GL_PLEASE_FLIP_MY_NORMALS that can take care of this task automatically?
 Cheers,
 Mike

 ___
 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] Flipping the normals

2007-08-28 Thread Michele Bosi
Thanks very much guys, osg::LightModel/GL_LIGHT_MODEL_TWO_SIDE seems
exactly what I needed.
Thankyou,
Mike
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Flipping the normals

2007-08-28 Thread Paul Martz
 Thanks very much guys, 
 osg::LightModel/GL_LIGHT_MODEL_TWO_SIDE seems exactly what I needed.
 Thankyou,
 Mike

In case it's not obvious, with two-sided lighting you do not need to
re-parent your mesh to two Geodes with different face culling. You should be
able to use a single Geode, face culling disabled, and two-sided lighting
enabled.
   -Paul

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


Re: [osg-users] Flipping the normals

2007-08-28 Thread Michele Bosi
Thanks Paul,
just wanted o add that I am very glad that when it comes to render
states OSG remains so close to OpenGL and doesn't abstract too much
from it, as this case proves, this lets users to reuse their prior
knowledge of OpenGL and makes the library really flexible,
long life to OSG! :)
Mike
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org