1
0
Fork 0

Added a hardcoded "LIGHTING" material entry in the matlib.

Fixed a typo in creating textured ssg simple states.
Start looking at a faster method for generating surface lighting based on the
scenery triangles.
This commit is contained in:
curt 2000-12-04 05:23:06 +00:00
parent 39632b90b8
commit bb108c7917
3 changed files with 69 additions and 1 deletions

View file

@ -161,6 +161,23 @@ bool FGMaterialLib::load( const string& mpath ) {
}
}
// hard coded light state
ssgSimpleState *lights = new ssgSimpleState;
lights->ref();
lights->disable( GL_TEXTURE_2D );
lights->enable( GL_CULL_FACE );
lights->enable( GL_COLOR_MATERIAL );
lights->setColourMaterial( GL_AMBIENT_AND_DIFFUSE );
lights->setMaterial( GL_EMISSION, 0, 0, 0, 1 );
lights->setMaterial( GL_SPECULAR, 0, 0, 0, 1 );
lights->disable( GL_BLEND );
lights->disable( GL_ALPHA_TEST );
lights->disable( GL_LIGHTING );
FGNewMat m;
m.set_ssg_state( lights );
matlib["LIGHTS"] = m;
return true;
}
@ -257,3 +274,13 @@ void FGMaterialLib::set_step ( int step )
slot.get_state()->selectStep(step);
}
}

View file

@ -85,6 +85,7 @@ void FGNewMat::build_ssg_state( const string& path,
// Set up the textured state
textured->setShadeModel( shade_model );
textured->enable( GL_LIGHTING );
textured->enable ( GL_CULL_FACE ) ;
textured->enable( GL_TEXTURE_2D );
textured->disable( GL_BLEND );

View file

@ -46,10 +46,10 @@
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/fg_random.h>
#include <simgear/math/point3d.hxx>
#include <simgear/math/polar3d.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/misc/fgstream.hxx>
#include <simgear/misc/stopwatch.hxx>
#include <simgear/misc/texcoord.hxx>
@ -267,6 +267,37 @@ ssgBranch *fgGenTile( const string& path, FGTileEntry *t) {
}
void gen_random_surface_points( ssgLeaf *leaf, ssgVertexArray *lights ) {
int num = leaf->getNumVertices();
float *n1, *n2, *n3;
sgVec3 p1, p2, p3;
sgVec3 result;
float remainder = 1.0;
float weight;
n1 = leaf->getVertex( 1 );
n2 = leaf->getVertex( 2 );
for ( int i = 3; i < num; ++i ) {
n3 = leaf->getVertex( i );
weight = sg_random();
remainder -= weight;
sgScaleVec3( p1, n1, weight );
weight = sg_random() * remainder;
remainder -= weight;
sgScaleVec3( p2, n2, weight );
sgScaleVec3( p3, n3, remainder );
sgAddVec3( result, p1, p2 );
sgAddVec3( result, p3 );
sgScaleVec3( result, 1.0 / 3.0 );
lights->add( result );
}
}
// Load a .obj file
ssgBranch *fgObjLoad( const string& path, FGTileEntry *t, const bool is_base) {
FGNewMat *newmat;
@ -667,6 +698,15 @@ ssgBranch *fgObjLoad( const string& path, FGTileEntry *t, const bool is_base) {
leaf->setState( state );
tile->addKid( leaf );
/*
ssgVertexArray *lights = NULL;
if ( is_base ) {
// generate lighting
lights = new ssgVertexArray( size );
gen_random_surface_points( leaf, lights );
}
*/
} else {
FG_LOG( FG_TERRAIN, FG_WARN, "Unknown token in "
<< path << " = " << token );