The prisms are not colourised properly. The reason turned out to be the clockwise orientation of the polygon vertices (winding order). 3-D implementations of KML use the vertex winding order for determining the direction in which it faces. This is necessary to display the correct lighting on curved surfaces. For the prisms to be displayed properly the vertex order has to be anti-clockwise.
The prisms will be colourised properly by simply changing the direction of the coordinates.
The light has been switched back on.
The vertex order was changed by this PHP function:
function kmlReverseCoordinates($coordinates) {
$coordinates = explode(" ", $coordinates);
$coordinates = array_reverse($coordinates);
$coordinates = implode(" ", $coordinates);
return $coordinates;
}
$coordinates = explode(" ", $coordinates);
$coordinates = array_reverse($coordinates);
$coordinates = implode(" ", $coordinates);
return $coordinates;
}
2 comments:
What a coincidence! Just last night I was struggling with this very problem and I didn't have a clue how to solve it. And today the answer was just delivered to me through my RSS feeds.
Thanks!
Maarten
www.merkador.com
I think it looks cooler with improper winding, but I suppose the project requirements come first. :)
Post a Comment