[osg-users] Color Change Question

2016-07-06 Thread Daniel Lecklider
Hi,

At my work we use OSG for simulation purposes and I am looking to display a 
model with each of its individual parts/components displayed in a different 
color.

 I am new to OSG so I still dont understand everything yet. But I know I need 
to remove all of the skins and apply a new color. A co-worker already created a 
way to give the entire model a color but I need to do it for each sub 
component. 


Here is the function my co-worker has used to remove the textures and add the 
new material.

Code:

void removeTextures(osg::Node* x)
{

if(x != nullptr)
 {
  auto state = x->getOrCreateStateSet();
  state->setAttributeAndModes(this->material, 
osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON);
  state->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE 
| osg::StateAttribute::OFF);
  auto group = x->asGroup();
  
  if(group != nullptr)
  {
   auto numChildren = group->getNumChildren();
   for(decltype(numChildren) i = 0; i < numChildren; i++)
   {
this->removeTextures(group->getChild(i));
   }
  }
 }
}



How would I go about changing the material of each geode/geometry/drawable and 
what are the differences between these three classes?

Thank you!

Cheers,
Daniel

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





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


[osg-users] [osgPlugins] Need help with setting/calculating normals

2016-06-29 Thread Daniel Lecklider
Hi,

First of all I am new to OSG so forgive me if I am making any mistakes.

I am creating a plugin for a proprietary 3d model format that we use at my 
work. These model files only contain grid points and unsorted primitives such 
as TRI's and QUADs.

Currently when I create the model I am not setting normals since non are 
provided by the file format. So I used the smoothing visitor to calculate the 
normals for me. However when I do this I get weird white spots all over model 
when I rotate it and look at it.

It seems like this really occurs when there is a 2d shape that is outjutting 
into 3d space. (Essentially has no or almost no width).

Is there any way I can calculate the proper normals, even though they are not 
given? Or is there any way to fix this rendering issue.

And do not worry about the models color, each section has its own section to 
denote different things for our clients.

Thank you!

Cheers,
Daniel

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




Attachments: 
http://forum.openscenegraph.org//files/osg2_109.png
http://forum.openscenegraph.org//files/osg1_115.png


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