Changeset 207


Ignore:
Timestamp:
Jan 25, 2011, 10:18:21 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/bin/osgVisualConfig.xml

    r206 r207  
    6565          <rotation rot_x="0.0" rot_y="0.0" rot_z="0.0"></rotation>
    6666        </cameraoffset>
    67         <geometry filename="cessna">
     67        <geometry filename="../models/Boing777-200.ive">
    6868          <offset rot_x="0.0" rot_y="0.0" rot_z="0.0"></offset>
    6969          <scalefactor scale_x="1.0" scale_y="1.0" scale_z="1.0"></scalefactor>
  • osgVisual/trunk/src/object/visual_object.cpp

    r205 r207  
    7272
    7373        OSG_NOTIFY( osg::ALWAYS ) << __FUNCTION__ << "Try to creating a new Model.." << std::endl;
    74         //osg::ref<visual_object> object = new visual_object( root, nodeName);
    75 
     74       
     75        // Prepare Variables
    7676        std::string objectname="", filename="", label="";
    7777        bool dynamic = false;
     
    8181        double geometry_scale_x=1.0, geometry_scale_y=1.0, geometry_scale_z=1.0;
    8282        osg::ref_ptr<osgVisual::object_updater> updater = NULL;
     83
     84        // extract model properties
     85        xmlAttr  *attr = a_node->properties;
     86        while ( attr )
     87        {
     88                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     89                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     90                if( attr_name == "objectname" ) objectname = attr_value;
     91                if( attr_name == "label" ) label = attr_value;
     92                if( attr_name == "dynamic" )
     93                {
     94                        if(attr_value=="yes")
     95                                dynamic=true;
     96                        else
     97                                dynamic=false;
     98                }
     99                attr = attr->next;
     100        }
     101        for (xmlNode *cur_node = a_node->children; cur_node; cur_node = cur_node->next)
     102        {
     103                std::string node_name=reinterpret_cast<const char*>(cur_node->name);
     104
     105                if(cur_node->type == XML_ELEMENT_NODE && node_name == "position")
     106                {
     107                        xmlAttr  *attr = cur_node->properties;
     108                        while ( attr )
     109                        {
     110                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     111                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     112                                if( attr_name == "lat" )
     113                                {
     114                                        std::stringstream sstr(attr_value);
     115                                        sstr >> lat;
     116                                }
     117                                if( attr_name == "lon" )
     118                                {
     119                                        std::stringstream sstr(attr_value);
     120                                        sstr >> lon;
     121                                }
     122                                if( attr_name == "alt" )
     123                                {
     124                                        std::stringstream sstr(attr_value);
     125                                        sstr >> alt;
     126                                }
     127                                attr = attr->next;
     128                        }
     129                }
     130
     131                if(cur_node->type == XML_ELEMENT_NODE && node_name == "attitude")
     132                {
     133                        xmlAttr  *attr = cur_node->properties;
     134                        while ( attr )
     135                        {
     136                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     137                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     138                                if( attr_name == "rot_x" )
     139                                {
     140                                        std::stringstream sstr(attr_value);
     141                                        sstr >> rot_x;
     142                                }
     143                                if( attr_name == "rot_y" )
     144                                {
     145                                        std::stringstream sstr(attr_value);
     146                                        sstr >> rot_y;
     147                                }
     148                                if( attr_name == "rot_z" )
     149                                {
     150                                        std::stringstream sstr(attr_value);
     151                                        sstr >> rot_z;
     152                                }
     153                                attr = attr->next;
     154                        }
     155                }
     156
     157                //if(cur_node->type == XML_ELEMENT_NODE && node_name == "updater")
     158                //{
     159                //      for (xmlNode *sub_cur_node = cur_node->children; sub_cur_node; sub_cur_node = sub_cur_node->next)
     160                //      {
     161                //              std::string sub_node_name=reinterpret_cast<const char*>(cur_node->children->name);
     162                //              if(sub_cur_node->type == XML_ELEMENT_NODE && sub_node_name == "position")
     163                //              {
     164                //                      <position lat="" lon="" alt=""></position>
     165                //              }
     166                //              if(sub_cur_node->type == XML_ELEMENT_NODE && sub_node_name == "attitude")
     167                //              {
     168                //                      <attitude rot_x="0.0" rot_y="0.0" rot_z="0.0"></attitude>
     169                //              }
     170                //              if(sub_cur_node->type == XML_ELEMENT_NODE && sub_node_name == "label")
     171                //              {
     172                //                      <label text=""></label>
     173                //              }
     174                //      }
     175                //}
     176
     177                if(cur_node->type == XML_ELEMENT_NODE && node_name == "cameraoffset")
     178                {
     179                        for (xmlNode *sub_cur_node = cur_node->children; sub_cur_node; sub_cur_node = sub_cur_node->next)
     180                        {
     181                                std::string sub_node_name=reinterpret_cast<const char*>(cur_node->children->name);
     182                                if(sub_cur_node->type == XML_ELEMENT_NODE && sub_node_name == "translation")
     183                                {
     184                                        xmlAttr  *attr = sub_cur_node->properties;
     185                                        while ( attr )
     186                                        {
     187                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     188                                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     189                                                if( attr_name == "trans_x" )
     190                                                {
     191                                                        std::stringstream sstr(attr_value);
     192                                                        sstr >> cam_trans_x;
     193                                                }
     194                                                if( attr_name == "trans_y" )
     195                                                {
     196                                                        std::stringstream sstr(attr_value);
     197                                                        sstr >> cam_trans_y;
     198                                                }
     199                                                if( attr_name == "trans_z" )
     200                                                {
     201                                                        std::stringstream sstr(attr_value);
     202                                                        sstr >> cam_trans_y;
     203                                                }
     204                                                attr = attr->next;
     205                                        }
     206                                }
     207                                if(sub_cur_node->type == XML_ELEMENT_NODE && sub_node_name == "rotation")
     208                                {
     209                                        xmlAttr  *attr = sub_cur_node->properties;
     210                                        while ( attr )
     211                                        {
     212                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     213                                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     214                                                if( attr_name == "rot_x" )
     215                                                {
     216                                                        std::stringstream sstr(attr_value);
     217                                                        sstr >> cam_rot_x;
     218                                                }
     219                                                if( attr_name == "rot_y" )
     220                                                {
     221                                                        std::stringstream sstr(attr_value);
     222                                                        sstr >> cam_rot_y;
     223                                                }
     224                                                if( attr_name == "rot_z" )
     225                                                {
     226                                                        std::stringstream sstr(attr_value);
     227                                                        sstr >> cam_rot_y;
     228                                                }
     229                                                attr = attr->next;
     230                                        }
     231                                }
     232                        }
     233                }
     234
     235                if(cur_node->type == XML_ELEMENT_NODE && node_name == "geometry")
     236                {
     237                        // extract filename
     238                        xmlAttr  *attr = cur_node->properties;
     239                        while ( attr )
     240                        {
     241                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     242                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     243                                if( attr_name == "filename" )
     244                                        filename = attr_value;
     245                                attr = attr->next;
     246                        }
     247
     248                        // Extract optional settings
     249                        for (xmlNode *sub_cur_node = cur_node->children; sub_cur_node; sub_cur_node = sub_cur_node->next)
     250                        {
     251                                std::string sub_node_name=reinterpret_cast<const char*>(sub_cur_node->name);
     252                                if(sub_cur_node->type == XML_ELEMENT_NODE && sub_node_name == "offset")
     253                                {
     254                                        xmlAttr  *attr = sub_cur_node->properties;
     255                                        while ( attr )
     256                                        {
     257                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     258                                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     259                                                if( attr_name == "rot_x" )
     260                                                {
     261                                                        std::stringstream sstr(attr_value);
     262                                                        sstr >> geometry_rot_x;
     263                                                }
     264                                                if( attr_name == "rot_y" )
     265                                                {
     266                                                        std::stringstream sstr(attr_value);
     267                                                        sstr >> geometry_rot_y;
     268                                                }
     269                                                if( attr_name == "rot_z" )
     270                                                {
     271                                                        std::stringstream sstr(attr_value);
     272                                                        sstr >> geometry_rot_z;
     273                                                }
     274                                                attr = attr->next;
     275                                        }
     276                                }
     277                                if(sub_cur_node->type == XML_ELEMENT_NODE && sub_node_name == "scalefactor")
     278                                {
     279                                        xmlAttr  *attr = sub_cur_node->properties;
     280                                        while ( attr )
     281                                        {
     282                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
     283                                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
     284                                                if( attr_name == "scale_x" )
     285                                                {
     286                                                        std::stringstream sstr(attr_value);
     287                                                        sstr >> geometry_scale_x;
     288                                                }
     289                                                if( attr_name == "scale_y" )
     290                                                {
     291                                                        std::stringstream sstr(attr_value);
     292                                                        sstr >> geometry_scale_y;
     293                                                }
     294                                                if( attr_name == "scale_z" )
     295                                                {
     296                                                        std::stringstream sstr(attr_value);
     297                                                        sstr >> geometry_scale_z;
     298                                                }
     299                                                attr = attr->next;
     300                                        }
     301                                }
     302                        }
     303                }
     304        }
     305
     306
     307
    83308
    84309        osgVisual::visual_object* object = new osgVisual::visual_object( sceneRoot_, objectname );
Note: See TracChangeset for help on using the changeset viewer.