1
0
Fork 0

Added support for specifying light coverage on a per material basis in the

materials file (contributed by David Megginson.)
This commit is contained in:
curt 2000-12-05 20:53:14 +00:00
parent 3ec542d18f
commit 84440e9b5e
3 changed files with 64 additions and 34 deletions

View file

@ -42,6 +42,7 @@
FGNewMat::FGNewMat ( void ) {
wrapu = wrapv = 1;
mipmap = 1;
light_coverage = -1.0;
}
@ -65,6 +66,7 @@ FGNewMat::FGNewMat ( const string &mat_name, const string &tex_name )
diffuse[0] = diffuse[1] = diffuse[2] = diffuse[3] = 1.0;
specular[0] = specular[1] = specular[2] = specular[3] = 1.0;
emission[0] = emission[1] = emission[2] = emission[3] = 1.0;
light_coverage = -1.0;
}
@ -237,6 +239,8 @@ operator >> ( istream& in, FGNewMat& m )
} else {
FG_LOG( FG_TERRAIN, FG_INFO, "Bad alpha value " << token );
}
} else if ( token == "light-coverage" ) {
in >> token >> m.light_coverage;
} else if ( token[0] == '}' ) {
break;
}

View file

@ -79,6 +79,13 @@ private:
// use mipmapping?
int mipmap;
// coverage of night lighting. This number is specifically the
// amount of area coverage we give a single light. The size of a
// triangle is divided by this number and that is the number of
// lights assigned to that triangle. Lower numbers mean more
// dense light ocverage.
double light_coverage;
// material properties
sgVec4 ambient, diffuse, specular, emission;
@ -119,6 +126,11 @@ public:
inline void set_specular( sgVec4 s ) { sgCopyVec4( specular, s ); }
inline void set_emission( sgVec4 e ) { sgCopyVec4( emission, e ); }
inline double get_light_coverage () const { return light_coverage; }
inline void set_light_coverage (double coverage) {
light_coverage = coverage;
}
inline ssgStateSelector *get_state() const { return state; }
void dump_info();

View file

@ -373,8 +373,9 @@ static void gen_random_surface_points( ssgLeaf *leaf, ssgVertexArray *lights,
ssgBranch *fgObjLoad( const string& path, FGTileEntry *t,
ssgVertexArray *lights, const bool is_base)
{
FGNewMat *newmat;
FGNewMat *newmat = NULL;
string material;
float coverage = -1;
Point3D pp;
// sgVec3 approx_normal;
// double normal[3], scale = 0.0;
@ -560,11 +561,14 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t,
tex_width = newmat->get_xsize();
tex_height = newmat->get_ysize();
state = newmat->get_state();
coverage = newmat->get_light_coverage();
// cout << "(w) = " << tex_width << " (h) = "
// << tex_width << endl;
} else {
coverage = -1;
}
} else {
// unknown comment, just gobble the input untill the
// unknown comment, just gobble the input until the
// end of line
in >> skipeol;
@ -773,39 +777,49 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t,
tile->addKid( leaf );
if ( is_base ) {
// generate lighting
if ( material == "Urban" || material == "BuiltUpCover" ) {
gen_random_surface_points( leaf, lights, 100000.0 );
} else if ( material == "EvergreenBroadCover" ||
material == "Default" || material == "Island" ||
material == "SomeSort" ||
material == "DeciduousBroadCover" ||
material == "EvergreenNeedleCover" ||
material == "DeciduousNeedleCover" ) {
gen_random_surface_points( leaf, lights, 10000000.0 );
} else if ( material == "MixedForestCover" ) {
gen_random_surface_points( leaf, lights, 5000000.0 );
} else if ( material == "WoodedTundraCover" ||
material == "BareTundraCover" ||
material == "HerbTundraCover" ||
material == "MixedTundraCover" ||
material == "Marsh" ||
material == "HerbWetlandCover" ||
material == "WoodedWetlandCover" ) {
gen_random_surface_points( leaf, lights, 20000000.0 );
} else if ( material == "ShrubCover" ||
material == "ShrubGrassCover" ) {
gen_random_surface_points( leaf, lights, 4000000.0 );
} else if ( material == "GrassCover" ||
material == "SavannaCover" ) {
gen_random_surface_points( leaf, lights, 4000000.0 );
} else if ( material == "MixedCropPastureCover" ||
material == "IrrCropPastureCover" ||
material == "DryCropPastureCover" ||
material == "CropGrassCover" ||
material == "CropWoodCover" ) {
gen_random_surface_points( leaf, lights, 2000000.0 );
if ( coverage > 0.0 ) {
if ( coverage < 10000.0 ) {
FG_LOG(FG_INPUT, FG_ALERT, "Light coverage is "
<< coverage << ", pushing up to 10000");
coverage = 10000;
}
gen_random_surface_points(leaf, lights, coverage);
}
// // generate lighting
// if ( material == "Urban" || material == "BuiltUpCover" ) {
// gen_random_surface_points( leaf, lights, 100000.0 );
// } else if ( material == "EvergreenBroadCover" ||
// material == "Default" || material == "Island" ||
// material == "SomeSort" ||
// material == "DeciduousBroadCover" ||
// material == "EvergreenNeedleCover" ||
// material == "DeciduousNeedleCover" ) {
// gen_random_surface_points( leaf, lights, 10000000.0 );
// } else if ( material == "Road") {
// gen_random_surface_points( leaf, lights, 10000.0);
// } else if ( material == "MixedForestCover" ) {
// gen_random_surface_points( leaf, lights, 5000000.0 );
// } else if ( material == "WoodedTundraCover" ||
// material == "BareTundraCover" ||
// material == "HerbTundraCover" ||
// material == "MixedTundraCover" ||
// material == "Marsh" ||
// material == "HerbWetlandCover" ||
// material == "WoodedWetlandCover" ) {
// gen_random_surface_points( leaf, lights, 20000000.0 );
// } else if ( material == "ShrubCover" ||
// material == "ShrubGrassCover" ) {
// gen_random_surface_points( leaf, lights, 4000000.0 );
// } else if ( material == "GrassCover" ||
// material == "SavannaCover" ) {
// gen_random_surface_points( leaf, lights, 4000000.0 );
// } else if ( material == "MixedCropPastureCover" ||
// material == "IrrCropPastureCover" ||
// material == "DryCropPastureCover" ||
// material == "CropGrassCover" ||
// material == "CropWoodCover" ) {
// gen_random_surface_points( leaf, lights, 2000000.0 );
// }
}
} else {
FG_LOG( FG_TERRAIN, FG_WARN, "Unknown token in "