* Get the polygons texture at a given point * @param lon Longitude of the point. * @param lat Latitude of the point. * @param texture pointer to texture ID returns -1 when polygon not found * @param shade pointer to shade */
| 2034 | * @param shade pointer to shade |
| 2035 | */ |
| 2036 | void Globe::getPolygonTextureAndShade(double lon, double lat, int *texture, int *shade) const |
| 2037 | { |
| 2038 | ///this is shade conversion from 0..31 levels of geoscape to battlescape levels 0..15 |
| 2039 | int worldshades[32] = { 0, 0, 0, 0, 1, 1, 2, 2, |
| 2040 | 3, 3, 4, 4, 5, 5, 6, 6, |
| 2041 | 7, 7, 8, 8, 9, 9,10,11, |
| 2042 | 11,12,12,13,13,14,15,15}; |
| 2043 | |
| 2044 | *texture = -1; |
| 2045 | *shade = worldshades[ CreateShadow::getShadowValue(0, Cord(0.,0.,1.), getSunDirection(lon, lat), 0) ]; |
| 2046 | |
| 2047 | // We're only temporarily changing cenLon/cenLat so the "const" is actually preserved |
| 2048 | Globe* const globe = const_cast<Globe* const>(this); // WARNING: BAD CODING PRACTICE |
| 2049 | double oldLon = _cenLon, oldLat = _cenLat; |
| 2050 | globe->_cenLon = lon; |
| 2051 | globe->_cenLat = lat; |
| 2052 | for (std::list<Polygon*>::iterator i = _game->getResourcePack()->getPolygons()->begin(); i != _game->getResourcePack()->getPolygons()->end(); ++i) |
| 2053 | { |
| 2054 | if (insidePolygon(lon, lat, *i)) |
| 2055 | { |
| 2056 | *texture = (*i)->getTexture(); |
| 2057 | break; |
| 2058 | } |
| 2059 | } |
| 2060 | globe->_cenLon = oldLon; |
| 2061 | globe->_cenLat = oldLat; |
| 2062 | } |
| 2063 | |
| 2064 | /** |
| 2065 | * Checks if the globe is zoomed in to it's maximum. |
no test coverage detected