OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

wireframe darker wrt the surface color


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 350

PostPosted: Tue Mar 21, 2017 4:00 pm    Post subject:
wireframe darker wrt the surface color
Reply with quote

Hi All,
I implemented the wireframe feature as follows:

Code:
void addWireframe(osg::Group* root, osg::Node* scene)
{
   osg::ref_ptr<osg::Group> decorator = new osg::Group;
   decorator->setNodeMask(0x1);

   osg::StateSet* stateset = decorator->getOrCreateStateSet();

   osg::PolygonOffset* polyoffset = new osg::PolygonOffset;
   polyoffset->setFactor(2.0f);
   polyoffset->setUnits(2.0f);
   stateset->setAttributeAndModes(polyoffset, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);

   osg::PolygonMode* polymode = new osg::PolygonMode;
   polymode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
   stateset->setAttributeAndModes(polymode, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);

   osg::Material* material = new osg::Material;
   material->setColorMode(osg::Material::OFF); // switch glColor usage off
   // turn all lighting off
   material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.5, 0.5f, 0.5f, 1.0f));
   material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.5, 0.5f, 0.5f, 1.0f));
   material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0f, 0.0f, 1.0f));
   // except emission... in which we set the color we desire
   material->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4(0.7, 0.7f, 0.7f, 1.0f));
   stateset->setAttributeAndModes(material, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
   stateset->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);

   decorator->addChild(scene);
   root->addChild(decorator);
}


Now instead of having the wireframe of a fixed color, I would like to show it in a slightly darker color wrt the color of the related geometry. Is it possible? How?

Thanks in advance,
Gianni
Back to top
View user's profile Send private message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 350

PostPosted: Mon Mar 27, 2017 10:39 am    Post subject:
Reply with quote

The point is that if I simply use:

Code:
   osg::Material* material = new osg::Material;
   stateset->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);
   stateset->setAttributeAndModes(material, osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);


then, I get the wireframe of the same color of the surface but when I rotate the 3D object the wireframe disappears at a certain position.
Back to top
View user's profile Send private message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 350

PostPosted: Mon Mar 27, 2017 10:42 am    Post subject:
Reply with quote

So, I need the wireframe to be always visible (darker or ligher) independently of the object rotation.

Is there a way to implement it?

Regards,
Gianni
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 767

PostPosted: Mon Mar 27, 2017 2:49 pm    Post subject:
wireframe darker wrt the surface color
Reply with quote

Hi Gianni,

Simply disable depth testing. (osg::Depth)

Cheers
Sebastian
--

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 350

PostPosted: Tue Mar 28, 2017 8:09 am    Post subject:
Reply with quote

Hi Sebastian
I tried as follows:

stateset->setMode(GL_DEPTH_TEST, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);

but it behaves the same. Probably I was not clear but I'm not sure this is something related to depth. Isn't it a matter of light or material?

Please give a look at the attached movie. Depending on light inclination the wireframe is darker or lighter but at a certain point the wireframe has exactly the same color of the undarlying surface and for that reason it is not visible.
I would like to see always the wireframe, it doesn't matter if it is darker or lighter but always and with the same base color of the underlying 3D surface.

Hope this is clearer now.


Cheers,
Gianni
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Tue Mar 28, 2017 3:25 pm    Post subject:
wireframe darker wrt the surface color
Reply with quote

Hi Gianni,

you can do something like
getOrCreateStateSet()->setAttributeAndModes(new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0, false), osg::StateAttribute:ShockedN);



On Tue, Mar 28, 2017 at 10:09 AM, Gianni Ambrosio <g.ambrosio+ ([email]g.ambrosio+[/email])> wrote:
Quote:
Hi Sebastian
I tried as follows:

stateset->setMode(GL_DEPTH, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);

but it behaves the same. Probably I was not clear but I'm not sure this is something related to depth. Isn't it a matter of light or material?

Please give a look at the attached movie. Depending on light inclination the wireframe is darker or lighter but at a certain point the wireframe has exactly the same color of the undarlying surface and for that reason it is not visible.
I would like to see always the wireframe, it doesn't matter if it is darker or lighter but always and with the same base color of the underlying 3D surface.

Hope this is clearer now.


Cheers,
Gianni

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




_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 350

PostPosted: Wed Mar 29, 2017 8:50 am    Post subject:
Re: wireframe darker wrt the surface color
Reply with quote

Hi Nick
Trajce Nikolov NICK wrote:
Hi Gianni,

you can do something like
getOrCreateStateSet()->setAttributeAndModes(new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0, false), osg::StateAttribute:ShockedN);

I tried the line you suggested with lights on or off but I have in every case a gray wireframe. While I would like to have a darker/lighter yellow wireframe on a yellow surface, and a darker/lighter green wireframe on a green surface.

Gianni
Back to top
View user's profile Send private message
Trajce Nikolov NICK
Guest





PostPosted: Wed Mar 29, 2017 11:55 am    Post subject:
wireframe darker wrt the surface color
Reply with quote

Try a simple shader then Smile

On Wed, Mar 29, 2017 at 10:51 AM, Gianni Ambrosio <g.ambrosio+ ([email]g.ambrosio+[/email])> wrote:
Quote:
Hi Nick

Trajce Nikolov NICK wrote:
Quote:
Hi Gianni,

you can do something like
getOrCreateStateSet()->setAttributeAndModes(new osg::Depth(osg::Depth::ALWAYS, 0.0, 1.0, false), osg::StateAttribute:ShockedN);


I tried the line you suggested with lights on or off but I have in every case a gray wireframe. While I would like to have a darker/lighter yellow wireframe on a yellow surface, and a darker/lighter green wireframe on a green surface.

Gianni

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





_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org






--
trajce nikolov nick

------------------
Post generated by Mail2Forum
Back to top
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 350

PostPosted: Tue Apr 04, 2017 7:41 am    Post subject:
Reply with quote

Thanks Nick,
I have to think it over since I've implemented a shader some months ago but I'm not really familiar with. The point would be how to get the real geometry color? BTW, I can try.

Anyway, isn't there a simpler way to get the desired result? Robert, any idea?

Regards,
Gianni
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 767

PostPosted: Tue Apr 04, 2017 8:00 am    Post subject:
wireframe darker wrt the surface color
Reply with quote

Hi Gianni,


Quote:
Thanks Nick,
I have to think it over since I've implemented a shader some months ago but I'm not really familiar with. The point would be how to get the real geometry color? BTW, I can try.

I finally managed to take a look at the attached video. Most probably
your problem is lighting. Your surface is shaded correctly while your
wireframe stays constant. At a certain angle the lit result is simply
the same color as your constant wireframe. Can you present the relevant
code, where you set up the wireframe?

Cheers
Sebastian


Quote:

Anyway, isn't there a simpler way to get the desired result? Robert, any idea?

Regards,
Gianni

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









------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
gambr
Appreciator


Joined: 22 Jun 2010
Posts: 350

PostPosted: Tue Jul 18, 2017 9:38 am    Post subject:
Re: wireframe darker wrt the surface color
Reply with quote

Hi Sebastian,
sorry I missed your reply.

SMesserschmidt wrote:

Most probably your problem is lighting. Your surface is shaded correctly while your wireframe stays constant. At a certain angle the lit result is simply the same color as your constant wireframe.

I think you are right. That's what happening. Now I don't remember exactly what I tried few months ago but if it is simply to reach, what should I do to make the wireframe color just a little bit darker with respect to the surface color at every view angle?
SMesserschmidt wrote:

Can you present the relevant code, where you set up the wireframe?

Please see attached cpp file.

Regards,
Gianni
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts ViewerBase::frame() method slow after... gambr General 7 Fri Jul 21, 2017 9:11 am View latest post
No new posts How to color each character of an osg... lq37 General 0 Thu Jun 22, 2017 1:31 pm View latest post
No new posts background color for osgWidget::Input Meldryt General 0 Tue Jun 20, 2017 12:36 pm View latest post
No new posts Secondary Color not working? umesh General 0 Tue Feb 14, 2017 10:37 am View latest post
No new posts Version 3.5.6 osgText::Text bounding ... dcfennell General 0 Tue Jan 31, 2017 5:40 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP