<div dir="auto"><div>Lighting is enabled, which is why the line darkens based on camera position. Disable lighting on line_geometry. Search osg examples for GL_LIGHTING to see how.<br><br><div data-smartmail="gmail_signature">---<br>Ravi<br><br>Sent from my phone, please excuse my brevity.</div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 23, 2018, 4:46 PM Diego Mancilla <<a href="mailto:dmancillac@gmail.com">dmancillac@gmail.com</a> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I'm drawing some simple lines on osg. So far I have successfully draw the lines and set a single color for each of them... but when I rotate the view the color is shown only on one direction of the camera, for instance, if rotate on 180 degrees the view, all lines are shown in black (looking from "down")... how can I get that the color of the lines is correctly shown regardless of the position/orientation of the camera on the viewer?<br>
<br>
<br>
<br>
Code:<br>
osg::Geode * root = getRoot();<br>
osg::Vec4Array * color = new osg::Vec4Array;<br>
double r, g, b, a;<br>
r = 1.0;<br>
g = 0.0;<br>
b = 0.0;<br>
a = 1.0;<br>
color->push_back(osg::Vec4d(r, g, b, a)); //single color <br>
osg::Vec3Array* osg_points = new osg::Vec3Array;<br>
...<br>
Here I fill the vertex array<br>
...<br>
osg::Geometry* line_geometry = new osg::Geometry;<br>
line_geometry->setVertexArray(osg_points); //osg_points has the points of the lines<br>
line_geometry->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP, 0, osg_points->size()));<br>
line_geometry->setColorArray(color);<br>
line_geometry->setColorBinding(osg::Geometry::BIND_OVERALL);<br>
root->addDrawable(line_geometry);<br>
<br>
<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
<br>
------------------<br>
Read this topic online here:<br>
<a href="http://forum.openscenegraph.org/viewtopic.php?p=75341#75341" rel="noreferrer noreferrer" target="_blank">http://forum.openscenegraph.org/viewtopic.php?p=75341#75341</a><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank" rel="noreferrer">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div></div></div>