Modified Files:
simgear/scene/material/mat.cxx simgear/scene/material/matlib.cxx simgear/scene/sky/cloud.cxx simgear/scene/sky/dome.cxx simgear/scene/sky/moon.cxx simgear/scene/sky/oursun.cxx simgear/scene/sky/sphere.cxx simgear/scene/sky/stars.cxx simgear/scene/tgdb/apt_signs.cxx simgear/scene/tgdb/leaf.cxx simgear/scene/tgdb/leaf.hxx simgear/scene/tgdb/obj.cxx simgear/scene/tgdb/pt_lights.cxx simgear/scene/util/SGDebugDrawCallback.hxx simgear/screen/Makefile.am: Use color arrays for every geode. Just use osg::Material instead of osg::Material and the associated mode.
This commit is contained in:
@@ -275,8 +275,6 @@ SGMaterial::build_state( bool defer_tex_load )
|
||||
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 );
|
||||
@@ -294,7 +292,15 @@ SGMaterial::build_state( bool defer_tex_load )
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -216,14 +216,15 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
|
||||
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);
|
||||
@@ -266,7 +267,6 @@ bool SGMaterialLib::load( const string &fg_root, const string& mpath, const char
|
||||
|
||||
osg::Material* material = new osg::Material;
|
||||
lightStateSet->setAttribute(material);
|
||||
// lightStateSet->setMode(GL_COLOR_MATERIAL, osg::StateAttribute::OFF);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#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"
|
||||
@@ -117,7 +116,6 @@ SGMakeState(const SGPath &path, const char* colorTexture, const char* normalText
|
||||
// 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);
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <osg/Material>
|
||||
#include <osg/ShadeModel>
|
||||
|
||||
#include <simgear/scene/util/SGDebugDrawCallback.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "dome.hxx"
|
||||
@@ -107,7 +106,6 @@ SGSkyDome::build( double hscale, double vscale ) {
|
||||
// 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
|
||||
@@ -194,7 +192,6 @@ SGSkyDome::build( double hscale, double vscale ) {
|
||||
// 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());
|
||||
@@ -205,7 +202,6 @@ SGSkyDome::build( double hscale, double vscale ) {
|
||||
|
||||
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());
|
||||
@@ -216,7 +212,6 @@ SGSkyDome::build( double hscale, double vscale ) {
|
||||
|
||||
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());
|
||||
@@ -227,7 +222,6 @@ SGSkyDome::build( double hscale, double vscale ) {
|
||||
|
||||
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());
|
||||
|
||||
@@ -90,7 +90,7 @@ SGMoon::build( SGPath path, double moon_size ) {
|
||||
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);
|
||||
|
||||
@@ -80,7 +80,7 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
|
||||
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);
|
||||
@@ -133,6 +133,7 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
|
||||
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);
|
||||
@@ -171,6 +172,7 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
|
||||
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);
|
||||
@@ -210,6 +212,7 @@ SGSun::build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node )
|
||||
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);
|
||||
|
||||
@@ -110,12 +110,17 @@ SGMakeSphere(double radius, int slices, int stacks)
|
||||
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);
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ SGStars::build( int num, const SGVec3d star_data[], double star_dist ) {
|
||||
// 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,
|
||||
|
||||
@@ -313,7 +313,6 @@ SGMakeSign(SGMaterialLib *matlib, const string& path, const string& content)
|
||||
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);
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#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"
|
||||
|
||||
@@ -234,8 +233,6 @@ osg::Node* SGMakeLeaf( const string& path,
|
||||
|
||||
|
||||
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);
|
||||
|
||||
@@ -156,12 +156,15 @@ bool SGGenTile( const string& path, SGBucket b,
|
||||
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;
|
||||
|
||||
@@ -146,8 +146,6 @@ gen_dir_light_group( const point_list &nodes,
|
||||
|
||||
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);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#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,
|
||||
@@ -141,6 +142,24 @@ do { \
|
||||
#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;
|
||||
@@ -156,6 +175,24 @@ do { \
|
||||
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 << ")";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user