stateSet->setAttributeAndModes(cullFace, osg::StateAttribute::ON);
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
- stateSet->setMode(GL_BLEND, osg::StateAttribute::OFF);
- stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
if ( !defer_tex_load ) {
SG_LOG(SG_INPUT, SG_INFO, " " << _status[i].texture_path );
material->setEmission(osg::Material::FRONT_AND_BACK, emission.osg());
material->setShininess(osg::Material::FRONT_AND_BACK, shininess );
stateSet->setAttribute(material);
- stateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON);
+
+ if (ambient[3] < 1 || diffuse[3] < 1 ||
+ specular[3] < 1 || emission[3] < 1) {
+ stateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
+ stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
+ } else {
+ stateSet->setMode(GL_BLEND, osg::StateAttribute::OFF);
+ stateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
+ }
_status[i].state = stateSet;
}
osg::ref_ptr<osg::StateSet> lightStateSet = new osg::StateSet;
{
-// lightStateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
-// lightStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
+ lightStateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
lightStateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
// lightStateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
+ lightStateSet->setMode(GL_BLEND, osg::StateAttribute::ON);
+
lightStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF);
-// lightStateSet->setAttribute(new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0));
-// lightStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
+ lightStateSet->setAttribute(new osg::AlphaFunc(osg::AlphaFunc::GREATER, 0.01));
+ lightStateSet->setMode(GL_ALPHA_TEST, osg::StateAttribute::ON);
osg::CullFace* cullFace = new osg::CullFace;
cullFace->setMode(osg::CullFace::BACK);
osg::Material* material = new osg::Material;
lightStateSet->setAttribute(material);
-// lightStateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::OFF);
}
#include <simgear/math/sg_random.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/scene/model/model.hxx>
-#include <simgear/scene/util/SGDebugDrawCallback.hxx>
#include <simgear/math/polar3d.hxx>
#include "newcloud.hxx"
// material->setSpecular(osg::Material::FRONT_AND_BACK,
// osg::Vec4(0, 0, 0, 1));
// stateSet->setAttribute(material);
-// stateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::ON);
stateSet->setMode(GL_FOG, osg::StateAttribute::OFF);
#include <osg/Material>
#include <osg/ShadeModel>
-#include <simgear/scene/util/SGDebugDrawCallback.hxx>
#include <simgear/debug/logstream.hxx>
#include "dome.hxx"
// osg::Vec4(0, 0, 0, 1));
// material->setShininess(osg::Material::FRONT_AND_BACK, 0);
stateSet->setAttribute(material);
-// stateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::OFF);
// initialize arrays
// initially seed to all blue
// into the provide scene graph branch
osg::Geometry* geometry = new osg::Geometry;
geometry->setName("Dome Center");
-// geometry->setDrawCallback(new SGDebugDrawCallback);
geometry->setUseDisplayList(false);
geometry->setVertexArray(center_disk_vl.get());
geometry->setColorArray(center_disk_cl.get());
geometry = new osg::Geometry;
geometry->setName("Dome Upper Ring");
-// geometry->setDrawCallback(new SGDebugDrawCallback);
geometry->setUseDisplayList(false);
geometry->setVertexArray(upper_ring_vl.get());
geometry->setColorArray(upper_ring_cl.get());
geometry = new osg::Geometry;
geometry->setName("Dome Middle Ring");
-// geometry->setDrawCallback(new SGDebugDrawCallback);
geometry->setUseDisplayList(false);
geometry->setVertexArray(middle_ring_vl.get());
geometry->setColorArray(middle_ring_cl.get());
geometry = new osg::Geometry;
geometry->setName("Dome Lower Ring");
-// geometry->setDrawCallback(new SGDebugDrawCallback);
geometry->setUseDisplayList(false);
geometry->setVertexArray(lower_ring_vl.get());
geometry->setColorArray(lower_ring_cl.get());
orb_material->setSpecular(osg::Material::FRONT_AND_BACK,
osg::Vec4(0, 0, 0, 1));
orb_material->setShininess(osg::Material::FRONT_AND_BACK, 0);
- stateSet->setAttributeAndModes(orb_material.get());
+ stateSet->setAttribute(orb_material.get());
stateSet->setMode(GL_LIGHTING, osg::StateAttribute::ON);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
stateSet->setMode(GL_FOG, osg::StateAttribute::OFF);
osg::Vec4(0, 0, 0, 1));
material->setSpecular(osg::Material::FRONT_AND_BACK,
osg::Vec4(0, 0, 0, 1));
- stateSet->setAttributeAndModes(material);
+ stateSet->setAttribute(material);
osg::ShadeModel* shadeModel = new osg::ShadeModel;
shadeModel->setMode(osg::ShadeModel::FLAT);
geometry->setVertexArray(sun_vl);
geometry->setColorArray(sun_cl.get());
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
+ geometry->setNormalBinding(osg::Geometry::BIND_OFF);
geometry->setTexCoordArray(0, sun_tl);
geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4));
geode->addDrawable(geometry);
geometry->setVertexArray(ihalo_vl);
geometry->setColorArray(ihalo_cl.get());
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
+ geometry->setNormalBinding(osg::Geometry::BIND_OFF);
geometry->setTexCoordArray(0, ihalo_tl);
geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4));
geode->addDrawable(geometry);
geometry->setVertexArray(ihalo_vl);
geometry->setColorArray(ihalo_cl.get());
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
+ geometry->setNormalBinding(osg::Geometry::BIND_OFF);
geometry->setTexCoordArray(0, ihalo_tl);
geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, 4));
geode->addDrawable(geometry);
exit(-1);
}
+ // colors
+ osg::Vec4Array* cl = new osg::Vec4Array;
+ cl->push_back(osg::Vec4(1, 1, 1, 1));
+
geometry->setUseDisplayList(false);
geometry->setVertexArray(vl);
geometry->setNormalArray(nl);
geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
geometry->setTexCoordArray(0, tl);
- geometry->setColorBinding(osg::Geometry::BIND_OFF);
+ geometry->setColorArray(cl);
+ geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_STRIP, 0, vl->size()));
geode->addDrawable(geometry);
// material->setSpecular(osg::Material::FRONT_AND_BACK,
// osg::Vec4(0, 0, 0, 1));
stateSet->setAttribute(material);
-// stateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::OFF);
osg::BlendFunc* blendFunc = new osg::BlendFunc;
blendFunc->setFunction(osg::BlendFunc::SRC_ALPHA,
cl->push_back(osg::Vec4(1, 1, 1, 1));
osg::Geometry* geometry = new osg::Geometry;
-// geometry->setUseDisplayList(false);
geometry->setVertexArray(vl);
geometry->setNormalArray(nl);
geometry->setNormalBinding(osg::Geometry::BIND_OVERALL);
#include <simgear/math/sg_random.h>
#include <simgear/scene/material/mat.hxx>
#include <simgear/scene/material/matlib.hxx>
-// #include <simgear/scene/util/SGDebugDrawCallback.hxx>
#include "leaf.hxx"
osg::Geometry* geometry = new osg::Geometry;
-// geometry->setUseDisplayList(false);
-// geometry->setDrawCallback(new SGDebugDrawCallback);
geometry->setVertexArray(vl);
geometry->setNormalArray(nl);
geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
tl->push_back(osg::Vec2(texs[i].x(), texs[i].y()));
}
+ osg::Vec4Array* cl = new osg::Vec4Array;
+ cl->push_back(osg::Vec4(1, 1, 1, 1));
osg::Geometry* geometry = new osg::Geometry;
geometry->setVertexArray(vl);
geometry->setNormalArray(nl);
geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
- geometry->setColorBinding(osg::Geometry::BIND_OFF);
+ geometry->setColorArray(cl);
+ geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
geometry->setTexCoordArray(0, tl);
geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLE_FAN, 0, vl->size()));
osg::Geode* geode = new osg::Geode;
osg::Geometry* geometry = new osg::Geometry;
geometry->setName("Dir Lights " + mat->get_names().front());
-// geometry->setDrawCallback(new SGDebugDrawCallback);
-// geometry->setUseDisplayList(false);
geometry->setVertexArray(vl);
geometry->setNormalArray(nl);
geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
#include <GL/gl.h>
#include <osg/Drawable>
#include <osg/State>
+#include <simgear/math/SGMath.hxx>
struct SGDebugDrawCallback : public osg::Drawable::DrawCallback {
virtual void drawImplementation(osg::State& state,
#undef PRINT_STATE
#undef ERROR_CHECK
+
+#ifdef PRINT_LIGHT
+#undef PRINT_LIGHT
+#endif
+#define PRINT_LIGHT(pname) \
+do { \
+ SGVec4f color; \
+ glGetLightfv(GL_LIGHT0, pname, color.data());\
+ stream << " " #pname " " << color; \
+} while(0)
+ PRINT_LIGHT(GL_AMBIENT);
+ PRINT_LIGHT(GL_DIFFUSE);
+ PRINT_LIGHT(GL_SPECULAR);
+ PRINT_LIGHT(GL_POSITION);
+ PRINT_LIGHT(GL_SPOT_DIRECTION);
+
+#undef PRINT_LIGHT
+
if (glIsEnabled(GL_COLOR_MATERIAL)) {
stream << " GL_COLOR_MATERIAL(";
GLint value;
if (value == GL_SPECULAR)
stream << "GL_SPECULAR";
+#ifdef PRINT_MATERIAL
+#undef PRINT_MATERIAL
+#endif
+#define PRINT_MATERIAL(pname) \
+do { \
+ SGVec4f color; \
+ glGetMaterialfv(GL_FRONT, pname, color.data());\
+ stream << " " #pname " GL_FRONT " << color; \
+ glGetMaterialfv(GL_BACK, pname, color.data()); \
+ stream << " " #pname " GL_BACK " << color; \
+} while(0)
+
+ PRINT_MATERIAL(GL_AMBIENT);
+ PRINT_MATERIAL(GL_DIFFUSE);
+ PRINT_MATERIAL(GL_EMISSION);
+ PRINT_MATERIAL(GL_SPECULAR);
+#undef PRINT_MATERIAL
+
stream << ")";
}