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