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