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 

Pergunta


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Renan Mendes
Guest





PostPosted: Tue Nov 04, 2008 2:50 pm    Post subject:
Pergunta
Reply with quote

Hi,

In my application, I'm trying to create a point (a small sphere) and alter its properties, like shininess and transparency. When I execute the following method, the point is created with shininess effects alright. However, no matter how much I change the values related to transparency (values from 0. to 1.), nothing seems to be different in my view...
What do I have to do to get the right result?


osg::Geode* Point::createPoint(osg::Vec3f position)
{
this->geode = new osg::Geode() // geode is an osg::ref_ptr<osg::Geode>, member of my class
this->drawable = new osg::ShapeDrawable(new osg::Sphere(position, RADIUS)); // drawable is an
// osg::ref_ptr<osg::Drawable>, member of my class
this->drawable->setColor(osg::Vec4(0.0, 0.0, 1.0, 1.0));
this->geode->addDrawable(this->drawable);
this->material -> setColorMode(osg::Material::DIFFUSE);
this->material -> setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
this->material -> setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
this->material -> setShininess(osg::Material::FRONT_AND_BACK, 128.0f);
this->material -> setTransparency(osg::Material::FRONT_AND_BACK, 0.5f);
geode -> getOrCreateStateSet() -> setAttributeAndModes(this->material.get(), osg::StateAttribute:ShockedN);

return geode.get();
}
Thanks for your help,
Renan

------------------
Post generated by Mail2Forum
Back to top
Can T. Oguz
Guest





PostPosted: Tue Nov 04, 2008 3:15 pm    Post subject:
Pergunta
Reply with quote

May be it is that blending is not turned on :

stateSet->setMode(GL_BLEND, StateAttribute:ShockedN);

Can


2008/11/4 Renan Mendes < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:
Hi,

In my application, I'm trying to create a point (a small sphere) and alter its properties, like shininess and transparency. When I execute the following method, the point is created with shininess effects alright. However, no matter how much I change the values related to transparency (values from 0. to 1.), nothing seems to be different in my view...
What do I have to do to get the right result?


osg::Geode* Point::createPoint(osg::Vec3f position)
{
this->geode = new osg::Geode() // geode is an osg::ref_ptr<osg::Geode>, member of my class
this->drawable = new osg::ShapeDrawable(new osg::Sphere(position, RADIUS)); // drawable is an
// osg::ref_ptr<osg::Drawable>, member of my class
this->drawable->setColor(osg::Vec4(0.0, 0.0, 1.0, 1.0));
this->geode->addDrawable(this->drawable);
this->material -> setColorMode(osg::Material::DIFFUSE);
this->material -> setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
this->material -> setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(1, 1, 1, 1));
this->material -> setShininess(osg::Material::FRONT_AND_BACK, 128.0f);
this->material -> setTransparency(osg::Material::FRONT_AND_BACK, 0.5f);
geode -> getOrCreateStateSet() -> setAttributeAndModes(this->material.get(), osg::StateAttribute:ShockedN);

return geode.get();
}
Thanks for your help,
Renan



_______________________________________________
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



------------------
Post generated by Mail2Forum
Back to top
Renan Mendes
Guest





PostPosted: Tue Nov 04, 2008 3:28 pm    Post subject:
Pergunta
Reply with quote

Hi, Can.

The stateSet whose mode you are setting is from the drawable or the geode? And how exactly can I do that without destroying my previous settings? (geode -> getOrCreateStateSet() -> setAttributeAndModes(this->material.get(), osg::StateAttribute:ShockedN)Wink


Thanks again,


Renan

------------------
Post generated by Mail2Forum
Back to top
Skylark (Jean-S├ębastien Guay)
Professional


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Tue Nov 04, 2008 3:49 pm    Post subject:
Pergunta
Reply with quote

Hello Renan,

Quote:
In my application, I'm trying to create a point (a small sphere) and
alter its properties, like shininess and transparency. When I execute
the following method, the point is created with shininess effects
alright. However, no matter how much I change the values related to
transparency (values from 0. to 1.), nothing seems to be different in my
view...

You could try to use the alpha in the ShapeDrawable->setColor() call
instead of in a material.

this->drawable->setColor(osg::Vec4(0.0, 0.0, 1.0, 0.5));

This should work (I think I remember we do something like that).

As for why it doesn't work when setting it through the material, I don't
know.

J-S
--
______________________________________________________
Jean-Sebastien Guay
http://www.cm-labs.com/
http://whitestar02.webhop.org/


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Skylark (Jean-S├ębastien Guay)
Professional


Joined: 05 Jan 2009
Posts: 2249

PostPosted: Tue Nov 04, 2008 3:58 pm    Post subject:
Pergunta
Reply with quote

Hello Renan,

Can is probably right, blending is probably not enabled on your node. If
you enable it, setting the transparency through the material will
probably work.

You will probably also need to give OSG a hint that your node contains
transparency:

stateset->setMode(GL_BLEND,osg::StateAttribute:ShockedN);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

Quote:
The stateSet whose mode you are setting is from the drawable or the
geode? And how exactly can I do that without destroying my previous
settings? (geode -> getOrCreateStateSet() ->
setAttributeAndModes(this->material.get(), osg::StateAttribute:ShockedN)Wink

The stateset will contain different settings without losing them. When
you set a material, it doesn't affect anything else in the stateset. The
only case where you'll lose something is if your stateset already had a
material (the new one will replace the old one).

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay
http://www.cm-labs.com/
http://whitestar02.webhop.org/


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Can T. Oguz
Guest





PostPosted: Wed Nov 05, 2008 7:05 am    Post subject:
Pergunta
Reply with quote

Hi,

That's what I do to make things transparent. I would apply the setting to where I apply material of course. I'm not much experienced with materials. There is a common sense that one needs a material to set transparency. But I think it's a common misunderstanding. Choosing the opaque or transparent bin is another issue. You get transparency in both cases; but, if there are more than one transparent face groups intersecting the same line of sight, you need to choose the opaque or transparent for the desired effect. I think somebody with more experience should tell us the theoretical difference between rendering bins.



2008/11/4 Renan Mendes < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:
Hi, Can.

The stateSet whose mode you are setting is from the drawable or the geode? And how exactly can I do that without destroying my previous settings? (geode -> getOrCreateStateSet() -> setAttributeAndModes(this->material.get(), osg::StateAttribute:ShockedN)Wink


Thanks again,


Renan

_______________________________________________
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



------------------
Post generated by Mail2Forum
Back to top
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 Happy New Year to all OSG Users Chris Hanson General 0 Mon Jan 07, 2019 10:17 am View latest post
No new posts osg-users Digest, Vol 138, Issue 27 Zachary1234 General 0 Tue Jan 01, 2019 1:16 am View latest post
No new posts osg-users Digest, Vol 137, Issue 14 poweruserm@live.com.au General 0 Fri Nov 16, 2018 11:16 pm View latest post
No new posts General Users starting questions in O... A Z General 1 Mon Oct 15, 2018 3:59 am View latest post
No new posts osg-users Digest, Vol 136, Issue 8 jonasydy General 0 Wed Oct 10, 2018 12:40 am 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