1 | #pragma once |
---|
2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
3 | * |
---|
4 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
5 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
6 | * (at your option) any later version. The full license is in LICENSE file |
---|
7 | * included with this distribution, and on the openscenegraph.org website. |
---|
8 | * |
---|
9 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
10 | * You have to aquire licenses for all used proprietary modules. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * OpenSceneGraph Public License for more details. |
---|
16 | * |
---|
17 | * This file is based on the OSG example of the Silverlining SDK: |
---|
18 | * Copyright (c) 2008 Sundog Software, LLC. All rights reserved worldwide. |
---|
19 | */ |
---|
20 | |
---|
21 | #include <osg/NodeCallback> |
---|
22 | #include <osg/Geode> |
---|
23 | |
---|
24 | #include <SilverLining.h> |
---|
25 | #include <MillisecondTimer.h> |
---|
26 | #ifdef WIN32 |
---|
27 | #include <windows.h> |
---|
28 | #endif |
---|
29 | #include <skySilverLining_skyDrawable.h> |
---|
30 | #include <skySilverLining_cloudsDrawable.h> |
---|
31 | #include <skySilverLining_AtmosphereReference.h> |
---|
32 | #include <skySilverLining_ProjectionMatrixCallback.h> |
---|
33 | #include <skySilverLining_cloudLayerSlot.h> |
---|
34 | |
---|
35 | #include <visual_util.h> |
---|
36 | |
---|
37 | namespace osgVisual |
---|
38 | { |
---|
39 | |
---|
40 | #define MAX_CLOUDLAYER_SLOTS 5 |
---|
41 | /** |
---|
42 | * \brief This class is the container class for the sky, stars and clouds |
---|
43 | * |
---|
44 | * This class is the container class for the sky, stars and clouds. It is responsible for initialization and updating of the sky system. |
---|
45 | * It is realized as Geode that it is possible to install an updateCallback on this class. |
---|
46 | * This way, the sky position is always updated during update traversal of the scene graph. |
---|
47 | * |
---|
48 | * The NodeCallback class is nested into this class that no external user can use this callback. |
---|
49 | * |
---|
50 | * @todo Add Cloudlayer->set/getalpha() function |
---|
51 | * @todo Terrain shadows do not exist |
---|
52 | * @todo Calibrate visual range with test objects. Populate a Lookuptable to use for true visibility ranges. |
---|
53 | * @todo Implement an abstract sky interface class to allow other sky implementations than silverlining with identical interfaces |
---|
54 | * |
---|
55 | * @author Torben Dannhauer |
---|
56 | * @date Jul 2009 |
---|
57 | */ |
---|
58 | class visual_skySilverLining : public osg::Geode |
---|
59 | { |
---|
60 | //#include <leakDetection.h> |
---|
61 | public: |
---|
62 | /** |
---|
63 | * \brief Constructor. |
---|
64 | * |
---|
65 | * @param viewer_ : Pointer to the applications viewer |
---|
66 | */ |
---|
67 | visual_skySilverLining(osgViewer::Viewer* viewer_); |
---|
68 | |
---|
69 | /** |
---|
70 | * \brief Destrcutor: The updateCallback is removed and the atmosphere, if instantiated. |
---|
71 | * |
---|
72 | */ |
---|
73 | virtual ~visual_skySilverLining(void); |
---|
74 | |
---|
75 | /** |
---|
76 | * \brief Returns a Pointer to the atmosphere object. |
---|
77 | * |
---|
78 | * @return Pointer to the atmosphere object. |
---|
79 | */ |
---|
80 | SilverLining::Atmosphere* getAtmosphere() {return atmosphere;}; |
---|
81 | |
---|
82 | /** |
---|
83 | * \brief Checks if the sky system is initialized. |
---|
84 | * |
---|
85 | * Checks if the sky system is initialized. If not, it makes a deep lookup at the main cameras userdata, if atmosphere is initialized. |
---|
86 | * If this returns true, the local variable is updated with ne new initialize status. If this deep lookup returns false, this method returns also false |
---|
87 | * asks the cameras user data if initialzed. If that is |
---|
88 | * |
---|
89 | * @return : Returns the status of initialization. |
---|
90 | */ |
---|
91 | bool isInitialized(); |
---|
92 | |
---|
93 | /** |
---|
94 | * \brief This function initializes the sky framework if its used with a PRE_RENDER camera like the distortion module. |
---|
95 | * |
---|
96 | * @param distortedRoot : osg::Group* which is the rootNode over distortion and scene |
---|
97 | * @param sceneGraphRoot : osg::Group* which is the rootNode and coordinateSystemNode of the scene. |
---|
98 | */ |
---|
99 | void init(osg::Group *distortedRoot, osg::CoordinateSystemNode *sceneGraphRoot); |
---|
100 | |
---|
101 | /** |
---|
102 | * \brief This function can be called by the updateCallback. If the postInitialization for adding clouds etc. has be called already, this function will skip. |
---|
103 | * |
---|
104 | * If this function is called before sky is initalized, all actions are skipped. |
---|
105 | * A standart usage is adding objects like clouds and winds, configuring time, location and visibility. |
---|
106 | * |
---|
107 | */ |
---|
108 | void postInit(); |
---|
109 | |
---|
110 | /** |
---|
111 | * \brief This function shuts the sky framework down. |
---|
112 | * |
---|
113 | */ |
---|
114 | void shutdown(); |
---|
115 | |
---|
116 | |
---|
117 | /** @name Time |
---|
118 | * The following functions control the simulated time and date. |
---|
119 | */ |
---|
120 | //@{ |
---|
121 | /** |
---|
122 | * \brief Sets the new Date and Time to the sky system. |
---|
123 | * |
---|
124 | * Update is only performed if the sky systme is initialized. |
---|
125 | * |
---|
126 | * @param year_ : Year to set. SilverLining can only handle Gregorian calendar years, which means that years before 1582 will not be accurately simulated. |
---|
127 | * @param month_ : Month to set. Ranging from 1 (Jan) to 12 (Dec) |
---|
128 | * @param day_ : Day to set Ranging from 1 to 31 |
---|
129 | * @param hour_ : Hour to set. Ranging from 0 to 23 |
---|
130 | * @param minute_ : Minute to set. Ranging from 0 to 59. |
---|
131 | * @param second_ : Second to set. Ranging from 0 to 59. |
---|
132 | * @param daylightSaving_ : Configures, if the configured DateTime is in daylight savings or without daylight savings. |
---|
133 | * @param timezoneOffset_ : Configures the timezone. Hour offset from GMT, ignoring daylight savings time. |
---|
134 | */ |
---|
135 | void setDateTime( int year_, int month_, int day_, int hour_, int minute_, int second_, bool daylightSaving_, double timezoneOffset_ ); |
---|
136 | |
---|
137 | /** |
---|
138 | * \brief Set time for the sky system. |
---|
139 | * |
---|
140 | * @param hour_ : Hour to set. Ranging from 0 to 23 |
---|
141 | * @param minute_ : Minute to set. Ranging from 0 to 59. |
---|
142 | * @param second_ : Second to set. Ranging from 0 to 59. |
---|
143 | */ |
---|
144 | void setTime( int hour_, int minute_, int second_ ); |
---|
145 | |
---|
146 | /** |
---|
147 | * \brief Sets the date for the sky system. |
---|
148 | * |
---|
149 | * @param year_ : Year to set. SilverLining can only handle Gregorian calendar years, which means that years before 1582 will not be accurately simulated. |
---|
150 | * @param month_ : Month to set. Ranging from 1 (Jan) to 12 (Dec) |
---|
151 | * @param day_ : Day to set Ranging from 1 to 31 |
---|
152 | */ |
---|
153 | void setDate( int year_, int month_, int day_ ); |
---|
154 | |
---|
155 | /** |
---|
156 | * \brief Configures the date and time by epoche (Seconds elapsed since midnight, January 1, 1970 UTC) |
---|
157 | * |
---|
158 | * This function ignores the daylight savings and timezone. |
---|
159 | * |
---|
160 | * @param secondsSince1970_ : Seconds elapsed since midnight, January 1, 1970 UTC |
---|
161 | */ |
---|
162 | void setDateByEpoch(int secondsSince1970_ ); |
---|
163 | |
---|
164 | //@} |
---|
165 | |
---|
166 | /** @name Location |
---|
167 | * The following functions control the location to simulate. |
---|
168 | */ |
---|
169 | //@{ |
---|
170 | /** |
---|
171 | * \brief Configures the sky system to simulate a specific location. |
---|
172 | * |
---|
173 | * @param lat_ : Latitude in radians |
---|
174 | * @param lon_ : Longitude in radians |
---|
175 | * @param alt_ : Altimeter in meters above see level. |
---|
176 | */ |
---|
177 | void setLocation(double lat_, double lon_, double alt_); |
---|
178 | //@} |
---|
179 | |
---|
180 | /** @name Visibility and Haze |
---|
181 | * The following functions control the atmosperic effects like visibility range and haze. |
---|
182 | */ |
---|
183 | //@{ |
---|
184 | /** |
---|
185 | * \brief This functions sets the visibility range in meters to simulate. |
---|
186 | * |
---|
187 | * @param visibility_ : Visibility range in meters. |
---|
188 | */ |
---|
189 | void setVisibility(double visibility_); |
---|
190 | |
---|
191 | /** |
---|
192 | * \brief This function returns the visibility range in meters which is simulated. |
---|
193 | * |
---|
194 | * @return : Visibility range in meters. |
---|
195 | */ |
---|
196 | double getVisibility(); |
---|
197 | |
---|
198 | /** |
---|
199 | * \brief This function sets the haze factor to simulate. |
---|
200 | * |
---|
201 | * 1 = Pure air, range 256 km |
---|
202 | * 2 = very clear, range 50 km |
---|
203 | * 3 = clear, range 15 km |
---|
204 | * 7 = light haze, range 8 km |
---|
205 | * 20 = haze, range 3 km |
---|
206 | * 50 = thin fog, range 2 km |
---|
207 | * |
---|
208 | * @param turbidity_ : Haze factor to simulate. |
---|
209 | */ |
---|
210 | void setTurbidity(double turbidity_); |
---|
211 | |
---|
212 | /** |
---|
213 | * \brief This function returns the simulated haze factor. |
---|
214 | * |
---|
215 | * @return : Haze factor. |
---|
216 | */ |
---|
217 | double getTurbidity(); |
---|
218 | //@} |
---|
219 | |
---|
220 | /** @name Light pollution |
---|
221 | * The following functions control the light pollution to simulate at night. |
---|
222 | */ |
---|
223 | //@{ |
---|
224 | /** |
---|
225 | * \brief This functions sets the light pollution in Watt/m2 |
---|
226 | * |
---|
227 | * @param lightPollution_ : Light pollution to set. |
---|
228 | */ |
---|
229 | void setLightPollution(double lightPollution_); |
---|
230 | |
---|
231 | /** |
---|
232 | * \brief This function returns the simulated light pollution in Watt/m2. |
---|
233 | * |
---|
234 | * @return : Light pollution in Watt/m2 |
---|
235 | */ |
---|
236 | double getLightPollution(); |
---|
237 | //@} |
---|
238 | |
---|
239 | /** @name Clouds |
---|
240 | * The following functions control the available slots for cloudLayer. In each slot a cloud layer can be adde and its perscpitation or |
---|
241 | * baseAltitude updated. All other values are not updateable, therefore a delete and recreation of the cloud layer would be necessary. |
---|
242 | */ |
---|
243 | //@{ |
---|
244 | /** |
---|
245 | * \brief This function adds a Cloudlayer to a sepcified SLOT. If the slot is used, this function returns immediately. |
---|
246 | * |
---|
247 | * If the slot number is out of range, nothing happens. |
---|
248 | * |
---|
249 | * Currently supported CloudTypes are: |
---|
250 | * |
---|
251 | * \li CloudTypes::CIRROCUMULUS - High planar cloud puffs. |
---|
252 | * \li CloudTypes::CIRRUS_FIBRATUS - High, wispy cirrus clouds. |
---|
253 | * \li CloudTypes::NIMBOSTRATUS - Low stratus decks. |
---|
254 | * \li CloudTypes::CUMULONIMBUS_CAPPILATUS - A large thunderhead with lightning and rain. |
---|
255 | * \li CloudTypes::CUMULUS_MEDIOCRIS - Small, puffy clouds. |
---|
256 | * \li CloudTypes::CUMULUS_CONGESTUS - Larger cumulus clouds with flattened bottoms. |
---|
257 | * \li CloudTypes::CUMULUS_MEDIOCRIS_INFINITE - A cumulus mediocris layer where the clouds wrap around |
---|
258 | * the camera location at all times, to create the illusion of an infinitely large cloud layer. |
---|
259 | * \li CloudTypes::CUMULUS_CONGESTUS_INFINITE - A cumulus congestus layer where the clouds wrap around |
---|
260 | * the camera location at all times, to create the illusion of an infinitely large cloud layer. |
---|
261 | * |
---|
262 | * @param slot_ : Slot to use. |
---|
263 | * @param baseLength_ : Baselength in meter of the cloud layer to generate. |
---|
264 | * @param baseWidth_ : Basewideth in meter of the cloud layer to generate. |
---|
265 | * @param thickness_ : Thicknes of the could layer in meter. |
---|
266 | * @param baseHeight_ : Height of the cloud base in WGS84. |
---|
267 | * @param density_ : Coverage of the cloud layer in percent (0.0 - 1.0). |
---|
268 | * @param cloudtype_ : Type of the cloudlayer to generate. |
---|
269 | */ |
---|
270 | void addCloudLayer(int slot_, double baseLength_, double baseWidth_, double thickness_, double baseHeight_, double density_, CloudTypes cloudtype_ ); |
---|
271 | |
---|
272 | /** |
---|
273 | * \brief This function remove the cloudlayer in the specified slot and marks the slot as free. |
---|
274 | * |
---|
275 | * If the slot number is out of range, nothing happens. |
---|
276 | * |
---|
277 | * @param slot_ : Slot number to clean |
---|
278 | */ |
---|
279 | void removeCloudLayer( int slot_ ); |
---|
280 | |
---|
281 | /** |
---|
282 | * \brief This function removes the cloud layers from all slots |
---|
283 | * |
---|
284 | */ |
---|
285 | void clearAllSlots(); |
---|
286 | |
---|
287 | /** |
---|
288 | * \brief This function returns a pointer to the cloudLayer this slot contains. |
---|
289 | * |
---|
290 | * If the slot number is out of range, nothing happens. |
---|
291 | * |
---|
292 | * @param slot_ : Slot to query for it's cloudLayer pointer. |
---|
293 | * @return : Pointer to the contained cloud layer. |
---|
294 | */ |
---|
295 | SilverLining::CloudLayer* getCloudLayer( int slot_ ); |
---|
296 | |
---|
297 | /** |
---|
298 | * \brief This function configure the cloud layer als enabled (show clouds) or disabled (hide clouds). |
---|
299 | * |
---|
300 | * If the slot number is out of range, nothing happens. |
---|
301 | * |
---|
302 | * @param slot_ : Cloudlayer to hide/show. |
---|
303 | * @param enabled_ : Control where hide or show should be configured. |
---|
304 | */ |
---|
305 | void setEnabled(int slot_, bool enabled_ ); |
---|
306 | |
---|
307 | /** |
---|
308 | * \brief This function returns if the specified cloud layer is en- or disabled (hidden or shown). |
---|
309 | * |
---|
310 | * If the slot number is out of range, nothing happens. |
---|
311 | * |
---|
312 | * @param slot_ : Slot zu query. |
---|
313 | * @return : true if clouds are visible, false if clouds are hidden. |
---|
314 | */ |
---|
315 | bool isEnabled( int slot_ ); |
---|
316 | |
---|
317 | /** |
---|
318 | * \brief This functions fade the clouds in or out, depending on the visibility tsatus before. |
---|
319 | * |
---|
320 | * If the slot number is out of range, nothing happens. |
---|
321 | * |
---|
322 | * @param slot_ : Slot to fade. |
---|
323 | * @param fadetimeMS_ : Milliseconds to fade the cloud layer. |
---|
324 | */ |
---|
325 | void fadeVisibility( int slot_, int fadetimeMS_); |
---|
326 | |
---|
327 | /** |
---|
328 | * \brief |
---|
329 | * |
---|
330 | * If the slot number is out of range, nothing happens. |
---|
331 | * |
---|
332 | * @param slot_ |
---|
333 | * @return : String with the literal name of the cloud layer type. |
---|
334 | */ |
---|
335 | std::string getCloudLayerTypeName( int slot_ ); |
---|
336 | |
---|
337 | //@} |
---|
338 | |
---|
339 | /** @name Wind |
---|
340 | * Description of wind. Attention: Wind volumes are not geocentric: If far enough away from upvector location, the earth will curve away under the wind volume. |
---|
341 | */ |
---|
342 | //@{ |
---|
343 | /** |
---|
344 | * \brief This function adds a wind volume to the scene, with the specified characteristics. |
---|
345 | * |
---|
346 | * @param bottom_ : Height in WGS84 in metern of the wind volumes bottom. |
---|
347 | * @param top_ : Height in WGS84 in metern of the wind volumes top. |
---|
348 | * @param speed_ : Windspeed in the wind volume in meter per seconds. |
---|
349 | * @param direction_ : Wind direction in the wind volume in degree (wind origin, not wind destination). |
---|
350 | * |
---|
351 | */ |
---|
352 | void addWindVolume(double bottom_, double top_, double speed_, int direction_); |
---|
353 | |
---|
354 | /** |
---|
355 | * \brief This function deletes all wind volumes. |
---|
356 | * |
---|
357 | */ |
---|
358 | void clearAllWindVolumes(); |
---|
359 | |
---|
360 | /** |
---|
361 | * \brief This functions checks wether the specified altitude in MSL is inside a wind volume. |
---|
362 | * |
---|
363 | * If multiple wind volumes are nested, this function returns the first matching wind volume. |
---|
364 | * Because geocentric wind is not implemented, the altitude information is always base on the location where the wind was added. |
---|
365 | * To avoid multiple winds, don't use nested wind volumes. |
---|
366 | * |
---|
367 | * @param height_ : Height in meters in WGS84 to check for wind. |
---|
368 | * @param bottom_ : If checking altitude is inside a volume, the bottom altitude of the volume in meters above MSL is written into, otherwise -1. |
---|
369 | * @param top_ : If checking altitude is inside a volume, the top altitude of the volume in meters above MSL is written into, otherwise -1. |
---|
370 | * @param speed_ : If checking altitude is inside a volume, the wind speed in the wind volume is written into, otherwise -1. |
---|
371 | * @param direction_ : If checking altitude is inside a volume, the wind direction (0 deg = from north, 90 deg = from east) in the wind volume is written into, otherwise -1. |
---|
372 | * @return : True if checking altitude is inside a wind volume, otherwise false. |
---|
373 | */ |
---|
374 | bool insideWind(double height_, double& bottom_, double& top_, double& speed_, double& direction_); |
---|
375 | |
---|
376 | |
---|
377 | //@} |
---|
378 | |
---|
379 | /** @name Precipitation |
---|
380 | * The following functions control the rate and type of precipitation. It is possible to configure it on an global or a per cloud basis. |
---|
381 | */ |
---|
382 | //@{ |
---|
383 | // Per SLOT |
---|
384 | /** |
---|
385 | * \brief This functions enables the specified precipitation rate and precipitation type at the specified cloudLayer slot. |
---|
386 | * |
---|
387 | * @param slot_ : CloudLayer slot to enable precipitation in. |
---|
388 | * @param rate_mmPerHour_rain_ : Precipitation rate in mm/hour of rain. |
---|
389 | * @param rate_mmPerHour_drySnow_ : Precipitation rate in mm/hour of dry snow. |
---|
390 | * @param rate_mmPerHour_wetSnow_ : Precipitation rate in mm/hour of wet snow. |
---|
391 | * @param rate_mmPerHour_sleet_ : Precipitation rate in mm/hour of sleet. |
---|
392 | */ |
---|
393 | void setSlotPrecipitation( int slot_, double rate_mmPerHour_rain_, double rate_mmPerHour_drySnow_, double rate_mmPerHour_wetSnow_, double rate_mmPerHour_sleet_ ); |
---|
394 | |
---|
395 | /** |
---|
396 | * \brief This function retrieves the precipitation of a cloudlayer slot. |
---|
397 | * |
---|
398 | * @param slot_ : Slot to check for precipitation. |
---|
399 | * @param rate_mmPerHour_rain : Precipitation rate in mm/hour of rain. |
---|
400 | * @param rate_mmPerHour_drySnow : Precipitation rate in mm/hour of dry snow. |
---|
401 | * @param rate_mmPerHour_wetSnow : Precipitation rate in mm/hour of wet snow. |
---|
402 | * @param rate_mmPerHour_sleet : Precipitation rate in mm/hour of sleet. |
---|
403 | * @return : True if cloudLayer has precipitation. |
---|
404 | */ |
---|
405 | bool getSlotPrecipitation( int slot_, double& rate_mmPerHour_rain, double& rate_mmPerHour_drySnow, double& rate_mmPerHour_wetSnow, double& rate_mmPerHour_sleet ); |
---|
406 | |
---|
407 | /** |
---|
408 | * \brief This function checks a specified location for precipitation at the specified cloudLayer slot. |
---|
409 | * |
---|
410 | * @param slot_ : CloudLayer slot to check for specification. |
---|
411 | * @param rate_mmPerHour_rain : Precipitation rate in mm/hour of rain. |
---|
412 | * @param rate_mmPerHour_drySnow : Precipitation rate in mm/hour of dry snow. |
---|
413 | * @param rate_mmPerHour_wetSnow : Precipitation rate in mm/hour of wet snow. |
---|
414 | * @param rate_mmPerHour_sleet : Precipitation rate in mm/hour of sleet. |
---|
415 | * @param lat_ : Latitude to check for precipitation. If it defaults to -1, the internal sky latitude will be used. |
---|
416 | * @param lon_ : Longitude to check for precipitation. If it defaults to -1, the internal sky longitude will be used. |
---|
417 | * @param height_ : Height in WGS84 to check for precipitation. If it defaults to -1, the internal sky height will be used. |
---|
418 | * @return : Returns true if precipitation at the specified location is true. |
---|
419 | */ |
---|
420 | bool getSlotPrecipitationAtLocation( int slot_, double& rate_mmPerHour_rain, double& rate_mmPerHour_drySnow, double& rate_mmPerHour_wetSnow, double& rate_mmPerHour_sleet, double lat_=-1, double lon_=-1, double height_=-1 ); |
---|
421 | |
---|
422 | /** |
---|
423 | * \brief This function clears all types of precipitation of the specified slot. |
---|
424 | * |
---|
425 | * @param slot_ : Slot toe clear precipitation. |
---|
426 | */ |
---|
427 | void clearAllPrecipitation( int slot_ ); |
---|
428 | |
---|
429 | // Global |
---|
430 | /** |
---|
431 | * \brief This function clears the global precipitation. |
---|
432 | * |
---|
433 | */ |
---|
434 | void clearGlobalPrecipitation(); |
---|
435 | |
---|
436 | /** |
---|
437 | * \brief This function sets the cloud independent, global precipitation. |
---|
438 | * |
---|
439 | * @param rate_mmPerHour_rain_ : Precipitation rate in mm/hour of rain. |
---|
440 | * @param rate_mmPerHour_drySnow_ : Precipitation rate in mm/hour of dry snow. |
---|
441 | * @param rate_mmPerHour_wetSnow_ : Precipitation rate in mm/hour of wet snow. |
---|
442 | * @param rate_mmPerHour_sleet_ : Precipitation rate in mm/hour of sleet. |
---|
443 | */ |
---|
444 | void setGlobalPrecipitation( double rate_mmPerHour_rain_, double rate_mmPerHour_drySnow_, double rate_mmPerHour_wetSnow_, double rate_mmPerHour_sleet_ ); |
---|
445 | |
---|
446 | // Misc |
---|
447 | /** |
---|
448 | * \brief This function returns the overall precipitation rate of all cloud dependent precipitation. |
---|
449 | * |
---|
450 | * This function adds the precipitation of all cloudLayer seperated for all types of precipitation. |
---|
451 | * Global precipitation is ignored, because precipitation without clouds is artificial and only reasonable for visualiszation purposes. |
---|
452 | * |
---|
453 | * @param rate_mmPerHour_rain : Precipitation rate in mm/hour of rain. |
---|
454 | * @param rate_mmPerHour_drySnow : Precipitation rate in mm/hour of dry snow. |
---|
455 | * @param rate_mmPerHour_wetSnow : Precipitation rate in mm/hour of wet snow. |
---|
456 | * @param rate_mmPerHour_sleet : Precipitation rate in mm/hour of sleet. |
---|
457 | * @param lat_ : Latitude to check for precipitation. If it defaults to -1, the internal sky latitude will be used. |
---|
458 | * @param lon_ : Longitude to check for precipitation. If it defaults to -1, the internal sky longitude will be used. |
---|
459 | * @param height_ : Height in WGS84 to check for precipitation. If it defaults to -1, the internal sky height will be used. |
---|
460 | * @return : True if precipitation lookup was successful. |
---|
461 | */ |
---|
462 | bool getOverallPrecipitationAtLocation( double& rate_mmPerHour_rain, double& rate_mmPerHour_drySnow, double& rate_mmPerHour_wetSnow, double& rate_mmPerHour_sleet, double lat_=-1, double lon_=-1, double height_=-1 ); |
---|
463 | //@} |
---|
464 | |
---|
465 | |
---|
466 | |
---|
467 | |
---|
468 | |
---|
469 | private: |
---|
470 | /** |
---|
471 | * \brief Nested Callback class |
---|
472 | * |
---|
473 | * @author Torben Dannhauer |
---|
474 | * @date Jul 2009 |
---|
475 | */ |
---|
476 | class skyUpdateCallback : public osg::NodeCallback |
---|
477 | { |
---|
478 | public: |
---|
479 | /** |
---|
480 | * \brief Constructor |
---|
481 | * |
---|
482 | * @param csn_ : Pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position. |
---|
483 | * @param sceneCamera_ : Pointer to the scene camera (undistorted camera, type PRE_RENDER) |
---|
484 | * @param sky_ : Pointer to the sky system. |
---|
485 | */ |
---|
486 | skyUpdateCallback(osg::CoordinateSystemNode* csn_, osg::Camera* sceneCamera_, visual_skySilverLining* sky_) |
---|
487 | : csn(csn_), sceneCamera(sceneCamera_), sky(sky_) {}; |
---|
488 | |
---|
489 | /** |
---|
490 | * \brief This function is executed as callback during traversal. It updates the skys displayed location. |
---|
491 | * |
---|
492 | */ |
---|
493 | virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); |
---|
494 | private: |
---|
495 | /** |
---|
496 | * Referenced pointer to the Coordinate System Node. Necessary to extract lat, lon and height of the camera position. |
---|
497 | */ |
---|
498 | osg::ref_ptr<osg::CoordinateSystemNode> csn; |
---|
499 | |
---|
500 | /** |
---|
501 | * Referenced pointer to the scene camera (undistorted camera, type PRE_RENDER) |
---|
502 | */ |
---|
503 | osg::ref_ptr<osg::Camera> sceneCamera; |
---|
504 | |
---|
505 | /** |
---|
506 | * Referenced pointer to the sky system. |
---|
507 | */ |
---|
508 | osg::ref_ptr<visual_skySilverLining> sky; |
---|
509 | }; // Nested class END |
---|
510 | |
---|
511 | /** |
---|
512 | * \brief This function updates the atmosphere's upVector, |
---|
513 | * if delta_lat or delta_lon (from the existing location |
---|
514 | * and the location of the last upVector update) is larger than N degree. |
---|
515 | * If an update is requiered, the existing location is noted as the last update location. |
---|
516 | * |
---|
517 | * Iis called by this->setLocation. |
---|
518 | * |
---|
519 | */ |
---|
520 | void updateUpVector(); |
---|
521 | |
---|
522 | /** |
---|
523 | * Pointer to the atmosphere object of Silverlining. |
---|
524 | */ |
---|
525 | SilverLining::Atmosphere *atmosphere; |
---|
526 | |
---|
527 | /** |
---|
528 | * Referenced Pointer to the viewer |
---|
529 | */ |
---|
530 | osg::ref_ptr<osgViewer::Viewer> viewer; |
---|
531 | |
---|
532 | /** |
---|
533 | * Referenced Pointer to the camera which pre renders the scene |
---|
534 | */ |
---|
535 | osg::ref_ptr<osg::Camera> sceneCamera; |
---|
536 | |
---|
537 | /** |
---|
538 | * Referenced Pointer to the coordinate system node. Required for WGS84 transformations. |
---|
539 | */ |
---|
540 | osg::ref_ptr<osg::CoordinateSystemNode> sceneRoot; |
---|
541 | |
---|
542 | /** |
---|
543 | * Referenced Pointer to the updatecallback, which is installed at this node. |
---|
544 | */ |
---|
545 | osg::ref_ptr<skyUpdateCallback> updateCallback; |
---|
546 | |
---|
547 | /** |
---|
548 | * Referenced Pointer to the ProjectionMatrix callback. |
---|
549 | */ |
---|
550 | osg::ref_ptr<skySilverLining_projectionMatrixCallback> cb; |
---|
551 | |
---|
552 | /** |
---|
553 | * Referenced Pointer to the sky Drawable, which renders the skybox. |
---|
554 | */ |
---|
555 | osg::ref_ptr<skySilverLining_skyDrawable> skyDrawable; |
---|
556 | |
---|
557 | /** |
---|
558 | * Referenced Pointer to the cloudsDrawable, which renders the clouds. |
---|
559 | */ |
---|
560 | osg::ref_ptr<skySilverLining_cloudsDrawable> cloudsDrawable; |
---|
561 | |
---|
562 | /** |
---|
563 | * Flag which contains if the sky system is initialized. This status is only a local |
---|
564 | * copy if the cameras userdata which contain the primary information if the sky system is initialized |
---|
565 | */ |
---|
566 | bool atmosphereInitialized; |
---|
567 | |
---|
568 | /** |
---|
569 | * This variable indicates whether postinit() was called already. |
---|
570 | */ |
---|
571 | bool postInitialized; |
---|
572 | |
---|
573 | /** |
---|
574 | * This vector contains all available slots for cloud layer. |
---|
575 | */ |
---|
576 | std::vector<cloudLayerSlot> cloudLayerSlots; |
---|
577 | |
---|
578 | /** |
---|
579 | * Latitude, which mirrors the latitude of the last sky update. This is neccesary if any weather effect is added to calculate the earth radius on that location for appropriate level above MSL |
---|
580 | */ |
---|
581 | double lat; |
---|
582 | |
---|
583 | /** |
---|
584 | * Longitude, which mirrors the latitude of the last sky update. This is neccesary if any weather effect is added to calculate the earth radius on that location for appropriate level above MSL |
---|
585 | */ |
---|
586 | double lon; |
---|
587 | |
---|
588 | /** |
---|
589 | * Height, which mirrors the height of the last sky update. |
---|
590 | */ |
---|
591 | double height; |
---|
592 | |
---|
593 | /** |
---|
594 | * This variable contains the latitude of the last upVector update. |
---|
595 | */ |
---|
596 | double upVectorLat; |
---|
597 | |
---|
598 | /** |
---|
599 | * This variable contains the longitude of the last upVector update. |
---|
600 | */ |
---|
601 | double upVectorLon; |
---|
602 | |
---|
603 | }; |
---|
604 | |
---|
605 | using namespace SilverLining; |
---|
606 | |
---|
607 | //class MyMillisecondTimer : public SilverLining::MillisecondTimer |
---|
608 | //{ |
---|
609 | //public: |
---|
610 | // virtual unsigned long GetMilliseconds() const |
---|
611 | // { |
---|
612 | // return timeGetTime() * 50; |
---|
613 | // } |
---|
614 | //}; |
---|
615 | |
---|
616 | |
---|
617 | } // END NAMESPACE |
---|