1
0
Fork 0

Linear features: Yellow hold lights are unidirectional to the right of the line direction.

Implement this by creating a directional normal for these types.
This commit is contained in:
Christian Schmitt 2012-09-14 12:41:16 +02:00
parent e8e1123db1
commit ccfde6914a
2 changed files with 28 additions and 4 deletions

View file

@ -759,6 +759,7 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
{ {
prev_outer = Point3D(0.0f, 0.0f, 0.0f); prev_outer = Point3D(0.0f, 0.0f, 0.0f);
cur_light_dist = 0.0f; cur_light_dist = 0.0f;
bool directional_light = lights[i]->IsDirectional();
// which material for this light // which material for this light
switch( lights[i]->type ) switch( lights[i]->type )
@ -839,10 +840,28 @@ int LinearFeature::Finish( bool closed, unsigned int idx )
poly.add_node(0, tmp); poly.add_node(0, tmp);
// calculate the normal double length;
Point3D vec = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS ); Point3D vec;
double length = vec.distance3D( Point3D(0.0) );
vec = vec / length; if ( !directional_light )
{
// calculate the omnidirectional normal
vec = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS );
length = vec.distance3D( Point3D(0.0) );
vec = vec / length;
} else
{
// calculate the directional normal
double heading_vec = heading + 90.0;
if (heading_vec > 360.0) { heading_vec -= 360.0; }
geo_direct_wgs_84( tmp.y(), tmp.x(), heading_vec, 10, &pt_y, &pt_x, &az2 );
Point3D cart1 = sgGeodToCart( tmp * SG_DEGREES_TO_RADIANS );
Point3D cart2 = sgGeodToCart( Point3D(pt_x, pt_y, 0.0) * SG_DEGREES_TO_RADIANS );
vec = cart2 - cart1;
length = vec.distance3D( Point3D(0.0) );
vec = vec / length;
}
normals_poly.add_node(0, vec ); normals_poly.add_node(0, vec );

View file

@ -57,6 +57,11 @@ public:
unsigned int type; unsigned int type;
unsigned int start_idx; unsigned int start_idx;
unsigned int end_idx; unsigned int end_idx;
bool IsDirectional()
{
return (type == 103 || type == 104) ? true : false;
}
}; };
typedef std::vector <Lighting*> LightingList; typedef std::vector <Lighting*> LightingList;