]> git.mxchange.org Git - flightgear.git/commitdiff
Removed tilecache.cxx tilecache.hxx.
authorcurt <curt>
Fri, 8 Dec 2000 17:28:05 +0000 (17:28 +0000)
committercurt <curt>
Fri, 8 Dec 2000 17:28:05 +0000 (17:28 +0000)
Tweaks to ground lighting.

src/Scenery/newcache.cxx
src/Scenery/tilecache.cxx [deleted file]
src/Scenery/tilecache.hxx [deleted file]

index 1fe5307c51d2deefabf6f2e8bc8e646dd9df1e06..daa67c82a76cde6d18b2e72ccad6a7a85992ade2 100644 (file)
@@ -157,19 +157,22 @@ static ssgLeaf *gen_lights( ssgVertexArray *lights, int inc, float bright ) {
        if ( i % inc == 0 ) {
            vl->add( lights->get(i) );
 
-           // yellow = 1,1,0
+           // factor = sg_random() ^ 2, range = 0 .. 1 concentrated towards 0
+           float factor = sg_random();
+           factor *= factor;
+
            if ( zombie > 0.5 ) {
                // 50% chance of yellowish
-               sgSetVec4( color, 0.9, 0.9, 0.3, bright );
+               sgSetVec4( color, 0.9, 0.9, 0.3, bright - factor * 0.2 );
            } else if ( zombie > 0.15 ) {
                // 35% chance of whitish
-               sgSetVec4( color, 0.9, 0.9, 0.8, bright );
+               sgSetVec4( color, 0.9, 0.9, 0.8, bright - factor * 0.2 );
            } else if ( zombie > 0.05 ) {
                // 10% chance of orangish
-               sgSetVec4( color, 0.9, 0.6, 0.2, bright );
+               sgSetVec4( color, 0.9, 0.6, 0.2, bright - factor * 0.2 );
            } else {
                // 5% chance of redish
-               sgSetVec4( color, 0.9, 0.2, 0.2, bright );
+               sgSetVec4( color, 0.9, 0.2, 0.2, bright - factor * 0.2 );
            }
            cl->add( color );
        }
diff --git a/src/Scenery/tilecache.cxx b/src/Scenery/tilecache.cxx
deleted file mode 100644 (file)
index 0d14651..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-// tilecache.cxx -- routines to handle scenery tile caching
-//
-// Written by Curtis Olson, started January 1998.
-//
-// Copyright (C) 1998 - 2000  Curtis L. Olson  - curt@flightgear.org
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>
-#endif
-
-#include <GL/glut.h>
-#include <simgear/xgl/xgl.h>
-
-#include <plib/ssg.h>          // plib include
-
-#include <simgear/bucket/newbucket.hxx>
-#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgstream.hxx>
-#include <simgear/misc/fgpath.hxx>
-
-#include <Main/globals.hxx>
-#include <Objects/obj.hxx>
-#include <Scenery/scenery.hxx>  // for scenery.center
-
-#include "tilecache.hxx"
-#include "tileentry.hxx"
-
-FG_USING_NAMESPACE(std);
-
-// a cheesy hack (to be fixed later)
-extern ssgBranch *terrain;
-extern ssgEntity *penguin;
-
-
-// the tile cache
-FGTileCache global_tile_cache;
-
-
-// Constructor
-FGTileCache::FGTileCache( void ) {
-    tile_cache.clear();
-}
-
-
-// Initialize the tile cache subsystem
-void
-FGTileCache::init( void )
-{
-    int i;
-
-    FG_LOG( FG_TERRAIN, FG_INFO, "Initializing the tile cache." );
-
-    // expand cache if needed.  For best results ... i.e. to avoid
-    // tile load problems and blank areas: 
-    // 
-    //   target_cache_size >= (current.options.tile_diameter + 1) ** 2 
-    // 
-    int side = globals->get_options()->get_tile_diameter() + 2;
-    int target_cache_size = (side*side);
-    FG_LOG( FG_TERRAIN, FG_DEBUG, "  target cache size = " 
-           << target_cache_size );
-    FG_LOG( FG_TERRAIN, FG_DEBUG, "  current cache size = " 
-           << tile_cache.size() );
-    FGTileEntry e;
-    e.mark_unused();
-    e.vec3_ptrs.clear();
-    e.vec2_ptrs.clear();
-    e.index_ptrs.clear();
-    
-    FG_LOG( FG_TERRAIN, FG_DEBUG, "  size of tile = " 
-           << sizeof( e ) );
-    if ( target_cache_size > (int)tile_cache.size() ) {
-       // FGTileEntry e;
-       int expansion_amt = target_cache_size - (int)tile_cache.size();
-       for ( i = 0; i < expansion_amt; ++i ) {
-           tile_cache.push_back( e );
-           FG_LOG( FG_TERRAIN, FG_DEBUG, "  expanding cache size = " 
-                   << tile_cache.size() );
-       }
-    }
-    FG_LOG( FG_TERRAIN, FG_DEBUG, "  done expanding cache, size = " 
-           << tile_cache.size() );
-
-    for ( i = 0; i < (int)tile_cache.size(); i++ ) {
-       if ( !tile_cache[i].is_unused() ) {
-           entry_free(i);
-       }
-       tile_cache[i].mark_unused();
-       tile_cache[i].tile_bucket.make_bad();
-    }
-
-    // and ... just in case we missed something ... 
-    terrain->removeAllKids();
-
-    FG_LOG( FG_TERRAIN, FG_INFO, "  done with init()"  );
-}
-
-
-// Search for the specified "bucket" in the cache
-int
-FGTileCache::exists( const FGBucket& p )
-{
-    int i;
-
-    for ( i = 0; i < (int)tile_cache.size(); i++ ) {
-       if ( tile_cache[i].tile_bucket == p ) {
-           FG_LOG( FG_TERRAIN, FG_DEBUG, 
-                   "TILE EXISTS in cache ... index = " << i );
-           return( i );
-       }
-    }
-    
-    return( -1 );
-}
-
-
-#if 0
-static void print_refs( ssgSelector *sel, ssgTransform *trans, 
-                ssgRangeSelector *range) 
-{
-    cout << "selector -> " << sel->getRef()
-        << "  transform -> " << trans->getRef()
-        << "  range -> " << range->getRef() << endl;
-}
-#endif
-
-
-// Fill in a tile cache entry with real data for the specified bucket
-void
-FGTileCache::fill_in( int index, const FGBucket& p )
-{
-    // cout << "FILL IN CACHE ENTRY = " << index << endl;
-
-    tile_cache[index].center = Point3D( 0.0 );
-    if ( tile_cache[index].vec3_ptrs.size() || 
-        tile_cache[index].vec2_ptrs.size() || 
-        tile_cache[index].index_ptrs.size() )
-    {
-       FG_LOG( FG_TERRAIN, FG_ALERT, 
-               "Attempting to overwrite existing or"
-               << " not properly freed leaf data." );
-       exit(-1);
-    }
-
-    tile_cache[index].select_ptr = new ssgSelector;
-    tile_cache[index].transform_ptr = new ssgTransform;
-    tile_cache[index].range_ptr = new ssgRangeSelector;
-    tile_cache[index].tile_bucket = p;
-
-    FGPath tile_path;
-    if ( globals->get_options()->get_fg_scenery() != "" ) {
-       tile_path.set( globals->get_options()->get_fg_scenery() );
-    } else {
-       tile_path.set( globals->get_options()->get_fg_root() );
-       tile_path.append( "Scenery" );
-    }
-    tile_path.append( p.gen_base_path() );
-    
-    // Load the appropriate data file
-    FGPath tile_base = tile_path;
-    tile_base.append( p.gen_index_str() );
-    ssgBranch *new_tile = fgObjLoad( tile_base.str(), &tile_cache[index], 
-                                    true );
-
-    if ( new_tile != NULL ) {
-       tile_cache[index].range_ptr->addKid( new_tile );
-    }
-  
-    // load custom objects
-    cout << "CUSTOM OBJECTS" << endl;
-
-    FGPath index_path = tile_path;
-    index_path.append( p.gen_index_str() );
-    index_path.concat( ".ind" );
-
-    cout << "Looking in " << index_path.str() << endl;
-
-    fg_gzifstream in( index_path.str() );
-
-    if ( in.is_open() ) {
-       string token, name;
-
-       while ( ! in.eof() ) {
-           in >> token;
-           in >> name;
-#if defined ( macintosh ) || defined ( _MSC_VER )
-           in >> ::skipws;
-#else
-           in >> skipws;
-#endif
-           cout << "token = " << token << " name = " << name << endl;
-
-           FGPath custom_path = tile_path;
-           custom_path.append( name );
-           ssgBranch *custom_obj = fgObjLoad( custom_path.str(),
-                                              &tile_cache[index], false );
-           if ( (new_tile != NULL) && (custom_obj != NULL) ) {
-               new_tile -> addKid( custom_obj );
-           }
-       }
-    }
-
-    tile_cache[index].transform_ptr->addKid( tile_cache[index].range_ptr );
-
-    // calculate initial tile offset
-    tile_cache[index].SetOffset( scenery.center );
-    sgCoord sgcoord;
-    sgSetCoord( &sgcoord,
-               tile_cache[index].offset.x(), 
-               tile_cache[index].offset.y(), tile_cache[index].offset.z(),
-               0.0, 0.0, 0.0 );
-    tile_cache[index].transform_ptr->setTransform( &sgcoord );
-
-    tile_cache[index].select_ptr->addKid( tile_cache[index].transform_ptr );
-    terrain->addKid( tile_cache[index].select_ptr );
-
-    if ( tile_cache[index].is_scheduled_for_cache() ) {
-       // cout << "FOUND ONE SCHEDULED FOR CACHE" << endl;
-       // load, but not needed now so disable
-       tile_cache[index].mark_loaded();
-       tile_cache[index].ssg_disable();
-       tile_cache[index].select_ptr->select(0);
-    } else {
-       // cout << "FOUND ONE READY TO LOAD" << endl;
-       tile_cache[index].mark_loaded();
-       tile_cache[index].select_ptr->select(1);
-    }
-}
-
-
-// Free a tile cache entry
-void
-FGTileCache::entry_free( int cache_index )
-{
-    // cout << "FREEING CACHE ENTRY = " << cache_index << endl;
-    tile_cache[cache_index].free_tile();
-}
-
-
-// Return index of next available slot in tile cache
-int
-FGTileCache::next_avail( void )
-{
-    // Point3D delta;
-    sgdVec3 abs_view_pos;
-    int i;
-    // float max, med, min, tmp;
-    float dist, max_dist;
-    int max_index;
-    
-    max_dist = 0.0;
-    max_index = -1;
-
-    for ( i = 0; i < (int)tile_cache.size(); i++ ) {
-       // only look at freeing NON-scheduled (i.e. ready to load
-       // cache entries.  This assumes that the cache is always big
-       // enough for our tile radius!
-
-       if ( tile_cache[i].is_unused() ) {
-           // favor unused cache slots
-           return(i);
-       } else if ( tile_cache[i].is_loaded() || tile_cache[i].is_cached() ) {
-           // calculate approximate distance from view point
-           sgdCopyVec3( abs_view_pos,
-                        globals->get_current_view()->get_abs_view_pos() );
-
-           FG_LOG( FG_TERRAIN, FG_DEBUG, "DIST Abs view pos = " 
-                   << abs_view_pos[0] << ","
-                   << abs_view_pos[1] << ","
-                   << abs_view_pos[2] );
-           FG_LOG( FG_TERRAIN, FG_DEBUG,
-                   "    ref point = " << tile_cache[i].center );
-
-           /*
-           delta.setx( fabs(tile_cache[i].center.x() - abs_view_pos.x() ) );
-           delta.sety( fabs(tile_cache[i].center.y() - abs_view_pos.y() ) );
-           delta.setz( fabs(tile_cache[i].center.z() - abs_view_pos.z() ) );
-
-           max = delta.x(); med = delta.y(); min = delta.z();
-           if ( max < med ) {
-               tmp = max; max = med; med = tmp;
-           }
-           if ( max < min ) {
-               tmp = max; max = min; min = tmp;
-           }
-           dist = max + (med + min) / 4;
-           */
-
-           sgdVec3 center;
-           sgdSetVec3( center,
-                       tile_cache[i].center[0],
-                       tile_cache[i].center[1],
-                       tile_cache[i].center[2] );
-           dist = sgdDistanceVec3( center, abs_view_pos );
-
-           FG_LOG( FG_TERRAIN, FG_DEBUG, "    distance = " << dist );
-
-           if ( dist > max_dist ) {
-               max_dist = dist;
-               max_index = i;
-           }
-       }
-    }
-
-    // If we made it this far, then there were no open cache entries.
-    // We will instead free the furthest cache entry and return it's
-    // index.
-
-    if ( max_index >=0 ) {
-       FG_LOG( FG_TERRAIN, FG_DEBUG, "    max_dist = " << max_dist );
-       FG_LOG( FG_TERRAIN, FG_DEBUG, "    index = " << max_index );
-       entry_free( max_index );
-       return( max_index );
-    } else {
-       FG_LOG( FG_TERRAIN, FG_ALERT, "WHOOPS!!! Dying in next_avail()" );
-       exit( -1 );
-    }
-
-    // avoid a potential compiler warning
-    return -1;
-}
-
-
-// Destructor
-FGTileCache::~FGTileCache( void ) {
-}
-
-
diff --git a/src/Scenery/tilecache.hxx b/src/Scenery/tilecache.hxx
deleted file mode 100644 (file)
index 4658a19..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-// tilecache.hxx -- routines to handle scenery tile caching
-//
-// Written by Curtis Olson, started January 1998.
-//
-// Copyright (C) 1998 - 2000  Curtis L. Olson  - curt@flightgear.org
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 2 of the
-// License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
-// $Id$
-
-
-#ifndef _TILECACHE_HXX
-#define _TILECACHE_HXX
-
-
-#ifndef __cplusplus                                                          
-# error This library requires C++
-#endif                                   
-
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>
-#endif
-
-#include <GL/glut.h>
-#include <simgear/xgl/xgl.h>
-
-#include <vector>
-
-#include <simgear/bucket/newbucket.hxx>
-#include <simgear/math/point3d.hxx>
-
-#include "tileentry.hxx"
-
-FG_USING_STD(vector);
-
-
-// A class to store and manage a pile of tiles
-class FGTileCache {
-
-    // cache storage space
-    tile_list tile_cache;
-
-public:
-
-    // Constructor
-    FGTileCache( void );
-
-    // Destructor
-    ~FGTileCache( void );
-
-    // Initialize the tile cache subsystem 
-    void init( void );
-
-    // Search for the specified "bucket" in the cache 
-    int exists( const FGBucket& p );
-
-    // Return index of next available slot in tile cache 
-    int next_avail( void );
-
-    // Free a tile cache entry
-    void entry_free( int index );
-
-    // Fill in a tile cache entry with real data for the specified bucket 
-    void fill_in( int index, const FGBucket& p );
-
-    // Return a pointer to the specified tile cache entry 
-    FGTileEntry *get_tile( int index ) {
-       return &tile_cache[index];
-    }
-
-    // Return the cache size
-    inline size_t get_size() const { return tile_cache.size(); }
-};
-
-
-// the tile cache
-extern FGTileCache global_tile_cache;
-
-
-#endif // _TILECACHE_HXX