Changeset 197 for osgVisual/trunk/src
- Timestamp:
- Jan 12, 2011, 10:20:19 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/trunk/src/sky_Silverlining/visual_skySilverLining.cpp
r183 r197 742 742 } 743 743 } 744 745 void visual_skySilverLining::configureCloudlayerbyXML( xmlNode* cloudlayerNode_ ) 746 { 747 std::string node_name=reinterpret_cast<const char*>(cloudlayerNode_->name); 748 if(cloudlayerNode_->type == XML_ELEMENT_NODE && node_name == "cloudlayer") 749 { 750 int slot = -1; 751 bool enabled; 752 int fadetime = -1, baselength = -1, basewidth = -1, thickness = -1, baseHeight = -1 ; 753 float density = -1.0, rate_mmPerHour_rain = -1.0, rate_mmPerHour_drySnow = -1.0, rate_mmPerHour_wetSnow = -1.0, rate_mmPerHour_sleet = -1.0; 754 CloudTypes ctype = CUMULUS_CONGESTUS; 755 756 757 758 xmlAttr *attr = cloudlayerNode_->properties; 759 while ( attr ) 760 { 761 std::string attr_name=reinterpret_cast<const char*>(attr->name); 762 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 763 if( attr_name == "slot" ) 764 { 765 std::stringstream sstr(attr_value); 766 sstr >> slot; 767 } 768 if( attr_name == "enabled" ) 769 { 770 if(attr_value=="yes") 771 enabled = true; 772 else 773 enabled = false; 774 } 775 if( attr_name == "fadetime" ) 776 { 777 std::stringstream sstr(attr_value); 778 sstr >> fadetime; 779 } 780 if( attr_name == "type" ) 781 { 782 if(attr_value=="CIRROCUMULUS") 783 ctype = CIRROCUMULUS; 784 if(attr_value=="CIRRUS_FIBRATUS") 785 ctype = CIRRUS_FIBRATUS; 786 if(attr_value=="STRATUS") 787 ctype = STRATUS; 788 if(attr_value=="CUMULUS_MEDIOCRIS") 789 ctype = CUMULUS_MEDIOCRIS; 790 if(attr_value=="CUMULUS_CONGESTUS") 791 ctype = CUMULUS_CONGESTUS; 792 if(attr_value=="CUMULONIMBUS_CAPPILATUS") 793 ctype = CUMULONIMBUS_CAPPILATUS; 794 if(attr_value=="STRATOCUMULUS") 795 ctype = STRATOCUMULUS; 796 } 797 attr = attr->next; 798 } 799 800 cloudlayerNode_ = cloudlayerNode_->children; 801 if(!cloudlayerNode_) 802 { 803 OSG_NOTIFY( osg::ALWAYS ) << "ERROR - visual_skySilverLining::configureCloudlayerbyXML: Missing geometry specification for a cloudlayer." << std::endl; 804 return; 805 } 806 807 for (xmlNode *cur_node = cloudlayerNode_; cur_node; cur_node = cur_node->next) 808 { 809 if(cur_node->type == XML_ELEMENT_NODE && node_name == "geometry") 810 { 811 xmlAttr *attr = cloudlayerNode_->properties; 812 while ( attr ) 813 { 814 std::string attr_name=reinterpret_cast<const char*>(attr->name); 815 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 816 if( attr_name == "baselength" ) 817 { 818 std::stringstream sstr(attr_value); 819 sstr >> baselength; 820 } 821 if( attr_name == "basewidth" ) 822 { 823 std::stringstream sstr(attr_value); 824 sstr >> basewidth; 825 } 826 if( attr_name == "thickness" ) 827 { 828 std::stringstream sstr(attr_value); 829 sstr >> thickness; 830 } 831 if( attr_name == "baseHeight" ) 832 { 833 std::stringstream sstr(attr_value); 834 sstr >> baseHeight; 835 } 836 if( attr_name == "density" ) 837 { 838 std::stringstream sstr(attr_value); 839 sstr >> density; 840 } 841 attr = attr->next; 842 } 843 } 844 845 if(cur_node->type == XML_ELEMENT_NODE && node_name == "precipitation") 846 { 847 xmlAttr *attr = cloudlayerNode_->properties; 848 while ( attr ) 849 { 850 std::string attr_name=reinterpret_cast<const char*>(attr->name); 851 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 852 if( attr_name == "rate_mmPerHour_rain" ) 853 { 854 std::stringstream sstr(attr_value); 855 sstr >> rate_mmPerHour_rain; 856 } 857 if( attr_name == "rate_mmPerHour_drySnow" ) 858 { 859 std::stringstream sstr(attr_value); 860 sstr >> rate_mmPerHour_drySnow; 861 } 862 if( attr_name == "rate_mmPerHour_wetSnow" ) 863 { 864 std::stringstream sstr(attr_value); 865 sstr >> rate_mmPerHour_wetSnow; 866 } 867 if( attr_name == "rate_mmPerHour_sleet" ) 868 { 869 std::stringstream sstr(attr_value); 870 sstr >> rate_mmPerHour_sleet; 871 } 872 attr = attr->next; 873 } 874 } 875 } 876 877 if(slot!=-1 && baselength!=-1 && basewidth!=-1 && thickness!=-1 && baseHeight!=-1 && density!=-1 ) 878 addCloudLayer( slot, baselength, basewidth, thickness, baseHeight, density, ctype ); 879 880 if(slot!=-1 && rate_mmPerHour_rain!=-1 && rate_mmPerHour_drySnow!=-1 && thickness!=-1 && baseHeight!=-1 && density!=-1 ) 881 setSlotPrecipitation( slot, rate_mmPerHour_rain, rate_mmPerHour_drySnow, rate_mmPerHour_wetSnow, rate_mmPerHour_sleet ); 882 } 883 else 884 OSG_NOTIFY( osg::ALWAYS ) << "ERROR - visual_skySilverLining::configureCloudlayerbyXML: Node is not a cloudlayer node." << std::endl; 885 }
Note: See TracChangeset
for help on using the changeset viewer.