]> git.mxchange.org Git - simgear.git/commitdiff
Modified Files:
authorfrohlich <frohlich>
Fri, 10 Nov 2006 05:30:37 +0000 (05:30 +0000)
committerfrohlich <frohlich>
Fri, 10 Nov 2006 05:30:37 +0000 (05:30 +0000)
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.

13 files changed:
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/obj.cxx
simgear/scene/tgdb/pt_lights.cxx
simgear/scene/util/SGDebugDrawCallback.hxx

index c9cd80466c0b6e329db239af9036d7757b1f2e4d..e73ba37c6fafba7a06fe26f886074d9b1bc5d97a 100644 (file)
@@ -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;
     }
index 07a20b11ddf70834c441e3d4008c24b35a8ba56d..7a8ea5440609ab5e928f4845df753a9c420d1f46 100644 (file)
@@ -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);
     }
     
 
index f236b46a57c8a70472a6fa5a25d6fc4b34610ee3..b97d39b08b267d699939e6f09a59a9d9d786421f 100644 (file)
@@ -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);
 
index a859958ec983ba5164ccf59cc44c1291bbaa9a4b..e8073c2c0a5767c73744123eb37758adf84e4444 100644 (file)
@@ -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());
index 568a89bd5849d352f97a0ffb5ea69e6730d44c6f..6cfb8788cb66b920a62ef2d1a89e21cfa8975223 100644 (file)
@@ -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);
index dd0d2cad986c1ed208c90cb893d1acc67d2d7b3c..f40f7fd919823affd79c911a78bc5c364922d550 100644 (file)
@@ -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);
index 11251b0ab6a0003734b1d34442f5d6fa85acabb4..bbd6869411068edc2643ffda990381a6863fdd41 100644 (file)
@@ -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);
 
index 22cf539ae6a9135275b4d5682d42984266b48b07..bd31aedcfb56b751751aaea87b3e4a3a8f2b96bb 100644 (file)
@@ -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,
index 22d6344b3f13d804644f94443ed535a308b6321a..543882c734e72f142f749513fe3feaea6cfd047e 100644 (file)
@@ -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);
index dd8d743b98a97cb777b35f4a168b233aa71184bd..1d3e6d9477f5b66532199ffcfbdb6e24acb36a7d 100644 (file)
@@ -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);
index a5bfcda9b346694155499e469e0c0e0786e09e38..363c8910a8eb792920a518222ebcec4944e700e1 100644 (file)
@@ -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;
index 6097d12d6a4f33bbc899a5ce6996c4b4079298c0..71fbdcf263fcd774fa3b2178b84928e404e09f6f 100644 (file)
@@ -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);
index 914d0d1ab3b59b5fb580011b1f5d726739249eae..5818f641d6df087d4ff06f520c76c301dc28ced3 100644 (file)
@@ -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 << ")";
     }