+ osg::Texture::Extensions* extensions;
+ extensions = osg::Texture::getExtensions(0, true);
+ // OSGFIXME
+ bump_mapping = extensions->isMultiTexturingSupported() &&
+ (2 <= extensions->numTextureUnits()) &&
+ SGIsOpenGLExtensionSupported("GL_ARB_texture_env_combine") &&
+ SGIsOpenGLExtensionSupported("GL_ARB_texture_env_dot3");
+
+ osg::TextureCubeMap::Extensions* extensions2;
+ extensions2 = osg::TextureCubeMap::getExtensions(0, true);
+ bump_mapping = bump_mapping && extensions2->isCubeMapSupported();
+
+ // This bump mapping code was inspired by the tutorial available at
+ // http://www.paulsprojects.net/tutorials/simplebump/simplebump.html
+ // and a NVidia white paper
+ // http://developer.nvidia.com/object/bumpmappingwithregistercombiners.html
+ // The normal map textures were generated by the normal map Gimp plugin :
+ // http://nifelheim.dyndns.org/~cocidius/normalmap/
+ //
+ cubeMap = new osg::TextureCubeMap;
+ cubeMap->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
+ cubeMap->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
+ cubeMap->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
+ cubeMap->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
+ cubeMap->setWrap(osg::Texture::WRAP_R, osg::Texture::CLAMP_TO_EDGE);
+
+ const int size = 32;
+ const float half_size = 16.0f;
+ const float offset = 0.5f;
+ osg::Vec3 zero_normal(0.5, 0.5, 0.5);
+
+ osg::Image* image = new osg::Image;
+ image->allocateImage(size, size, 1, GL_RGB, GL_UNSIGNED_BYTE);
+ unsigned char *ptr = image->data(0, 0);
+ for (int j = 0; j < size; j++ ) {
+ for (int i = 0; i < size; i++ ) {
+ osg::Vec3 tmp(half_size, -( j + offset - half_size ),
+ -( i + offset - half_size ) );
+ tmp.normalize();
+ tmp = tmp*0.5 - zero_normal;
+
+ *ptr++ = (unsigned char)( tmp[ 0 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 1 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 2 ] * 255 );
+ }
+ }
+ cubeMap->setImage(osg::TextureCubeMap::POSITIVE_X, image);
+
+ image = new osg::Image;
+ image->allocateImage(size, size, 1, GL_RGB, GL_UNSIGNED_BYTE);
+ ptr = image->data(0, 0);
+ for (int j = 0; j < size; j++ ) {
+ for (int i = 0; i < size; i++ ) {
+ osg::Vec3 tmp(-half_size, -( j + offset - half_size ),
+ ( i + offset - half_size ) );
+ tmp.normalize();
+ tmp = tmp*0.5 - zero_normal;
+
+ *ptr++ = (unsigned char)( tmp[ 0 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 1 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 2 ] * 255 );
+ }
+ }
+ cubeMap->setImage(osg::TextureCubeMap::NEGATIVE_X, image);
+
+ image = new osg::Image;
+ image->allocateImage(size, size, 1, GL_RGB, GL_UNSIGNED_BYTE);
+ ptr = image->data(0, 0);
+ for (int j = 0; j < size; j++ ) {
+ for (int i = 0; i < size; i++ ) {
+ osg::Vec3 tmp(( i + offset - half_size ), half_size,
+ ( j + offset - half_size ) );
+ tmp.normalize();
+ tmp = tmp*0.5 - zero_normal;
+
+ *ptr++ = (unsigned char)( tmp[ 0 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 1 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 2 ] * 255 );
+ }
+ }
+ cubeMap->setImage(osg::TextureCubeMap::POSITIVE_Y, image);
+
+ image = new osg::Image;
+ image->allocateImage(size, size, 1, GL_RGB, GL_UNSIGNED_BYTE);
+ ptr = image->data(0, 0);
+ for (int j = 0; j < size; j++ ) {
+ for (int i = 0; i < size; i++ ) {
+ osg::Vec3 tmp(( i + offset - half_size ), -half_size,
+ -( j + offset - half_size ) );
+ tmp.normalize();
+ tmp = tmp*0.5 - zero_normal;
+
+ *ptr++ = (unsigned char)( tmp[ 0 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 1 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 2 ] * 255 );
+ }
+ }
+ cubeMap->setImage(osg::TextureCubeMap::NEGATIVE_Y, image);
+
+ image = new osg::Image;
+ image->allocateImage(size, size, 1, GL_RGB, GL_UNSIGNED_BYTE);
+ ptr = image->data(0, 0);
+ for (int j = 0; j < size; j++ ) {
+ for (int i = 0; i < size; i++ ) {
+ osg::Vec3 tmp(( i + offset - half_size ),
+ -( j + offset - half_size ), half_size );
+ tmp.normalize();
+ tmp = tmp*0.5 - zero_normal;
+
+ *ptr++ = (unsigned char)( tmp[ 0 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 1 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 2 ] * 255 );
+ }
+ }
+ cubeMap->setImage(osg::TextureCubeMap::POSITIVE_Z, image);
+
+ image = new osg::Image;
+ image->allocateImage(size, size, 1, GL_RGB, GL_UNSIGNED_BYTE);
+ ptr = image->data(0, 0);
+ for (int j = 0; j < size; j++ ) {
+ for (int i = 0; i < size; i++ ) {
+ osg::Vec3 tmp(-( i + offset - half_size ),
+ -( j + offset - half_size ), -half_size );
+ tmp.normalize();
+ tmp = tmp*0.5 - zero_normal;
+ *ptr++ = (unsigned char)( tmp[ 0 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 1 ] * 255 );
+ *ptr++ = (unsigned char)( tmp[ 2 ] * 255 );
+ }
+ }
+ cubeMap->setImage(osg::TextureCubeMap::NEGATIVE_Z, image);
+
+ osg::StateSet* state;
+ state = SGMakeState(texture_path, "overcast.png", "overcast_n.png");
+ layer_states[SG_CLOUD_OVERCAST] = state;
+ state = SGMakeState(texture_path, "overcast_top.png", "overcast_top_n.png");
+ layer_states2[SG_CLOUD_OVERCAST] = state;
+
+ state = SGMakeState(texture_path, "broken.png", "broken_n.png");
+ layer_states[SG_CLOUD_BROKEN] = state;
+ layer_states2[SG_CLOUD_BROKEN] = state;
+
+ state = SGMakeState(texture_path, "scattered.png", "scattered_n.png");
+ layer_states[SG_CLOUD_SCATTERED] = state;
+ layer_states2[SG_CLOUD_SCATTERED] = state;
+
+ state = SGMakeState(texture_path, "few.png", "few_n.png");
+ layer_states[SG_CLOUD_FEW] = state;
+ layer_states2[SG_CLOUD_FEW] = state;
+
+ state = SGMakeState(texture_path, "cirrus.png", "cirrus_n.png");
+ layer_states[SG_CLOUD_CIRRUS] = state;
+ layer_states2[SG_CLOUD_CIRRUS] = state;
+