Re: [osg-users] transparency becomes dark
Hi Ulrich thanks - you are right - it was the wrong place Dieter Unclassified Mail -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Ulrich Hertlein Sent: Thursday, 31 July, 2008 01:34 To: OpenSceneGraph Users Subject: Re: [osg-users] transparency becomes dark Hi Dieter, Dieter Pfeffer wrote: I supposed that it has s.th to do with the missing material paramters; my idea was to change the original material of the node, therefore I set: osg::StateSet *ss = loadedModel -getOrCreateStateSet(); osg::Material* blendMaterial = (osg::Material*)(ss-getAttribute(osg::StateAttribute::MATERIAL)); but the material is always NULL so I don't have the original material Is this the wrong function call ? The function call is correct, you're probably looking in the wrong spot ;-) I assume 'loadedModel' is the Node returned from 'readNodeFile'? If this is the case than most likely this is only a Group node that contains the rest of the scene graph. If you take a look at e.g. 'cow.osg' (or most of the examples) you'll see that the Material isn't actually attached to the top node. What you'll need to do is traverse the scene graph and find the Material node(s) you're looking for. For example you could look for a Node with a certain name and fetch it's Material. Also keep in mind that Materials are attached to StateSets which may be attached to Nodes *or* Drawables (attached to Geodes). Cheers! /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org Disclaimer: This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Considering the inherent risks of the use of e-mail communication, Thales Nederland BV shall not be liable for any damage derived from it. Thales Nederland BV is seated in Hengelo (Ov.), the Netherlands, and registered at the Chamber of Commerce under number 06061578. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transparency becomes dark
Thanks Ulrich and Dimi I supposed that it has s.th to do with the missing material paramters; my idea was to change the original material of the node, therefore I set: osg::StateSet *ss = loadedModel -getOrCreateStateSet(); osg::Material* blendMaterial = (osg::Material*)(ss-getAttribute(osg::StateAttribute::MATERIAL)); but the material is always NULL so I don't have the original material Is this the wrong function call ? Dieter Unclassified Mail -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Ulrich Hertlein Sent: Saturday, 26 July, 2008 08:08 To: OpenSceneGraph Users Subject: Re: [osg-users] transparency becomes dark Hi Dieter, Dieter Pfeffer wrote: I am trying to set the object transparency from 1.0 - 0.0 and vice versa; but when I start changing the alpha of the material the object becomes dark. I have changed the material parameters but without success; when I look in the loaded model (for example cow.osg) for material, the material is always null. I have modified the osgviewer example and attached it. Could s.o. give me a hint what I am doing wrong ? You're creating a new Material that overrides the material of the node you're fading. However, you're not setting the Material properties (ambient, diffuse, specular, emissive, shininess) and the default values for Material are unlikely to match that of the node you're trying to blend. Hence when you override the original material it will switch from the original settings to the default Material. For an experiment, have a look at any .osg file and look at the material properties. Then set those values on the 'blendMaterial' node you're creating and it should look smooth. You're probably better off modifying the original Material(s) of the node hierarchy. Or try another approach, like using blendcolor. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org Disclaimer: This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Considering the inherent risks of the use of e-mail communication, Thales Nederland BV shall not be liable for any damage derived from it. Thales Nederland BV is seated in Hengelo (Ov.), the Netherlands, and registered at the Chamber of Commerce under number 06061578. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transparency becomes dark
OGL sets up a default material , you may be picking this up -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dieter Pfeffer Sent: Wednesday, July 30, 2008 8:09 AM To: OpenSceneGraph Users Subject: Re: [osg-users] transparency becomes dark Thanks Ulrich and Dimi I supposed that it has s.th to do with the missing material paramters; my idea was to change the original material of the node, therefore I set: osg::StateSet *ss = loadedModel -getOrCreateStateSet(); osg::Material* blendMaterial = (osg::Material*)(ss-getAttribute(osg::StateAttribute::MATERIAL)); but the material is always NULL so I don't have the original material Is this the wrong function call ? Dieter Unclassified Mail -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Ulrich Hertlein Sent: Saturday, 26 July, 2008 08:08 To: OpenSceneGraph Users Subject: Re: [osg-users] transparency becomes dark Hi Dieter, Dieter Pfeffer wrote: I am trying to set the object transparency from 1.0 - 0.0 and vice versa; but when I start changing the alpha of the material the object becomes dark. I have changed the material parameters but without success; when I look in the loaded model (for example cow.osg) for material, the material is always null. I have modified the osgviewer example and attached it. Could s.o. give me a hint what I am doing wrong ? You're creating a new Material that overrides the material of the node you're fading. However, you're not setting the Material properties (ambient, diffuse, specular, emissive, shininess) and the default values for Material are unlikely to match that of the node you're trying to blend. Hence when you override the original material it will switch from the original settings to the default Material. For an experiment, have a look at any .osg file and look at the material properties. Then set those values on the 'blendMaterial' node you're creating and it should look smooth. You're probably better off modifying the original Material(s) of the node hierarchy. Or try another approach, like using blendcolor. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org Disclaimer: This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Considering the inherent risks of the use of e-mail communication, Thales Nederland BV shall not be liable for any damage derived from it. Thales Nederland BV is seated in Hengelo (Ov.), the Netherlands, and registered at the Chamber of Commerce under number 06061578. ___ 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] transparency becomes dark
Hi Dieter, Dieter Pfeffer wrote: I supposed that it has s.th to do with the missing material paramters; my idea was to change the original material of the node, therefore I set: osg::StateSet *ss = loadedModel -getOrCreateStateSet(); osg::Material* blendMaterial = (osg::Material*)(ss-getAttribute(osg::StateAttribute::MATERIAL)); but the material is always NULL so I don't have the original material Is this the wrong function call ? The function call is correct, you're probably looking in the wrong spot ;-) I assume 'loadedModel' is the Node returned from 'readNodeFile'? If this is the case than most likely this is only a Group node that contains the rest of the scene graph. If you take a look at e.g. 'cow.osg' (or most of the examples) you'll see that the Material isn't actually attached to the top node. What you'll need to do is traverse the scene graph and find the Material node(s) you're looking for. For example you could look for a Node with a certain name and fetch it's Material. Also keep in mind that Materials are attached to StateSets which may be attached to Nodes *or* Drawables (attached to Geodes). Cheers! /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transparency becomes dark
Hi Dieter, Dieter Pfeffer wrote: I am trying to set the object transparency from 1.0 - 0.0 and vice versa; but when I start changing the alpha of the material the object becomes dark. I have changed the material parameters but without success; when I look in the loaded model (for example cow.osg) for material, the material is always null. I have modified the osgviewer example and attached it. Could s.o. give me a hint what I am doing wrong ? You're creating a new Material that overrides the material of the node you're fading. However, you're not setting the Material properties (ambient, diffuse, specular, emissive, shininess) and the default values for Material are unlikely to match that of the node you're trying to blend. Hence when you override the original material it will switch from the original settings to the default Material. For an experiment, have a look at any .osg file and look at the material properties. Then set those values on the 'blendMaterial' node you're creating and it should look smooth. You're probably better off modifying the original Material(s) of the node hierarchy. Or try another approach, like using blendcolor. Cheers, /ulrich ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transparency becomes dark
Hi, I dont see that you are doing anything wrong... It was not working for me either though but I think you messed somehow the logic up. Here is an example based on what you sent which makes the model (I used cow.osg) fade in/out. Hope this helps - Original Message From: Dieter Pfeffer [EMAIL PROTECTED] To: osg-users@lists.openscenegraph.org Sent: Thursday, July 24, 2008 3:30:37 PM Subject: [osg-users] transparency becomes dark Hi I am trying to set the object transparency from 1.0 - 0.0 and vice versa; but when I start changing the alpha of the material the object becomes dark. I have changed the material parameters but without success; when I look in the loaded model (for example cow.osg) for material, the material is always null. I have modified the osgviewer example and attached it. Could s.o. give me a hint what I am doing wrong ? Thanks Dieter Unclassified Mail Disclaimer: This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Considering the inherent risks of the use of e-mail communication, Thales Nederland BV shall not be liable for any damage derived from it. Thales Nederland BV is seated in Hengelo (Ov.), the Netherlands, and registered at the Chamber of Commerce under number 06061578. osgviewer_alpha.cpp Description: Binary data ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] transparency becomes dark
Hi I am trying to set the object transparency from 1.0 - 0.0 and vice versa; but when I start changing the alpha of the material the object becomes dark. I have changed the material parameters but without success; when I look in the loaded model (for example cow.osg) for material, the material is always null. I have modified the osgviewer example and attached it. Could s.o. give me a hint what I am doing wrong ? Thanks Dieter Unclassified Mail Disclaimer: This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Considering the inherent risks of the use of e-mail communication, Thales Nederland BV shall not be liable for any damage derived from it. Thales Nederland BV is seated in Hengelo (Ov.), the Netherlands, and registered at the Chamber of Commerce under number 06061578. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield * * This application is open source and may be redistributed and/or modified * freely and without restriction, both in commericial and non commericial applications, * as long as this copyright notice is maintained. * * This application is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ #include osgDB/ReadFile #include osgUtil/Optimizer #include osg/CoordinateSystemNode #include osg/Switch #include osgText/Text #include osgViewer/Viewer #include osgViewer/ViewerEventHandlers #include osgGA/TrackballManipulator #include osgGA/FlightManipulator #include osgGA/DriveManipulator #include osgGA/KeySwitchMatrixManipulator #include osgGA/StateSetManipulator #include osgGA/AnimationPathManipulator #include osgGA/TerrainManipulator #include osg/Material #include osg/BlendFunc #include iostream int doAlpha; float currentAlpha; osg::ref_ptrosg::Node loadedModel; void setAlpha() { if ( doAlpha == 1) currentAlpha +=.01; if ( doAlpha == 2) currentAlpha -=.01; if (loadedModel.valid()) { osg::StateSet *ss = loadedModel -getOrCreateStateSet(); osg::Material* blendMaterial = 0; blendMaterial = (osg::Material*)(ss-getAttribute(osg::StateAttribute::MATERIAL)); if(blendMaterial ==0) { blendMaterial = new osg::Material(); } if (doAlpha == 1) { if (currentAlpha 1.0) { blendMaterial-setAlpha( osg::Material::FRONT_AND_BACK, currentAlpha); } else { blendMaterial-setAlpha( osg::Material::FRONT_AND_BACK, 1.0); doAlpha = 0; } } else if (doAlpha == 2) { if (currentAlpha .0) { blendMaterial-setAlpha( osg::Material::FRONT_AND_BACK, currentAlpha); } else { blendMaterial-setAlpha( osg::Material::FRONT_AND_BACK, 0.0); doAlpha = 0; } } osg::BlendFunc *bl = new osg::BlendFunc(); bl-setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA); ss-setAttributeAndModes(bl, osg::StateAttribute::ON |osg::StateAttribute::OVERRIDE); ss-setMode(GL_BLEND, osg::StateAttribute::ON |osg::StateAttribute::OVERRIDE); ss-setAttributeAndModes(blendMaterial ,osg::StateAttribute::ON |osg::StateAttribute::OVERRIDE); ss-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); loadedModel-setStateSet( ss ); // not neccessary if (currentAlpha =1 ) { doAlpha = 0; ss-setMode(GL_BLEND, osg::StateAttribute::OFF); ss-setAttributeAndModes(blendMaterial,osg::StateAttribute::OFF); } if (currentAlpha 0) doAlpha = 1; } } int main(int argc, char** argv) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(argc,argv); arguments.getApplicationUsage()-setApplicationName(arguments.getApplicationName());