Changeset 205


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

Legend:

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

    r204 r205  
    4141    <animationpath filename="salzburg.path"></animationpath>
    4242    <models>
    43       <!-- Models can be loaded and placed in the scenerey.
    44         - filename: 3D model to load. Leave empty to use model without 3D model.
    45         - type: [plain] ? todo
     43      <!-- Models can be loaded and placed in the scenery.
     44        - objectname: Name of the object to identify it in the scenegraph.
    4645        - label: text to label the model with.
    47         - dynamic: Add an standard updater to the model. todo
    48         - position: Poisition to place the model
    49         - attitude: Orientation to place the model
     46        - dynamic: "yes" to add an standard updater to the model.
     47        - position: Position to place the model
     48        - attitude: Orientation in degree to place the model
    5049        - updater [optional]: Channels to use for position and attitude update
    51         - modeloffset [optional]: Offset for the loaded 3D model to the visual_object (if the 3D model has a wrong coordinate frame)
    52         - cameraoffset [optional]: Offset for the object mounted camera manipulator to the visual_object   
     50        - cameraoffset [optional]: Rotational (in degree) and translational offset for the object mounted camera manipulator to the visual_object   
     51        - Geometry [optional]: 3D model to display. Leave empty to use model without 3D model.
     52        - Geometryoffset [optional]: Rotational offset (in degree) for the loaded 3D model to the visual_object (if the 3D model has a wrong coordinate frame)
     53        - Geometryscale [optional]: Scale factors for the loaded 3D model in all three dimensions.
    5354      -->
    54       <model filename="cessna.osg" type="plain" label="TestText!" dynamic="yes">
     55      <model objectname="TestObject" label="TestText!" dynamic="yes">
    5556        <position lat="47.12345" lon="11.234567" alt="1500.0"></position>
    5657        <attitude rot_x="0.0" rot_y="0.0" rot_z="0.0"></attitude>
    5758        <updater>
    58           <position lat="channelXYZ" lon="channelXYZ" alt="channelXYZ"></position>
    59           <attitude rot_x="channelXYZ" rot_y="channelXYZ" rot_z="channelXYZ"></attitude>
     59          <translation-slots>todo</translation-slots>
    6060        </updater>
    61         <modeloffset>
    62           <translation trans_x="0.0" trans_y="0.0" trans_z="0.0"></translation>
    63           <rotation rot_x="0.0" rot_y="0.0" rot_z="0.0"></rotation>
    64         </modeloffset>
    6561        <cameraoffset>
    6662          <translation trans_x="0.0" trans_y="0.0" trans_z="0.0"></translation>
    6763          <rotation rot_x="0.0" rot_y="0.0" rot_z="0.0"></rotation>
    6864        </cameraoffset>
     65        <geometry filename="cessna">
     66          <offset rot_x="0.0" rot_y="0.0" rot_z="0.0"></offset>
     67          <scalefactor scale_x="1.0" scale_y="1.0" scale_z="1.0"></scalefactor>
     68        </geometry>
    6969      </model>
    7070    </models>
  • osgVisual/trunk/src/object/visual_object.cpp

    r204 r205  
    4343        geometry_offset_rotation.makeRotate( 0.0, 1.0, 1.0, 1.0 );
    4444
    45         // Init Scale
     45        // Init Scale factor
    4646        scaleX = 1.0;
    4747        scaleY = 1.0;
     
    7474        //osg::ref<visual_object> object = new visual_object( root, nodeName);
    7575
    76         std::string filename="", type
    77 
    78                         /*
    79                         <models>
    80                           <model filename="cessna" type="plain" label="TestText!" dynamic="yes">
    81                                 <position lat="47.12345" lon="11.234567" alt="1500.0"></position>
    82                                 <attitude rot_x="0.0" rot_y="0.0" rot_z="0.0"></attitude>
    83                                 <cameraoffset>
    84                                   <translation trans_x="0.0" trans_y="0.0" trans_z="0.0"></translation>
    85                                   <rotation rot_x="0.0" rot_y="0.0" rot_z="0.0"></rotation>
    86                                 </cameraoffset>
    87                           </model>
    88                         </models>
    89                         */
     76        std::string objectname="", filename="", label="";
     77        bool dynamic = false;
     78        double lat=0.0, lon=0.0, alt=0.0, rot_x=0.0, rot_y=0.0, rot_z=0.0;
     79        double cam_trans_x=0.0, cam_trans_y=0.0, cam_trans_z=0.0, cam_rot_x=0.0, cam_rot_y=0.0, cam_rot_z=0.0;
     80        double geometry_rot_x=0.0, geometry_rot_y=0.0, geometry_rot_z=0.0;
     81        double geometry_scale_x=1.0, geometry_scale_y=1.0, geometry_scale_z=1.0;
     82        osg::ref_ptr<osgVisual::object_updater> updater = NULL;
     83
     84        osgVisual::visual_object* object = new osgVisual::visual_object( sceneRoot_, objectname );
     85        object->lat = lat;
     86        object->lon = lon;
     87        object->alt = alt;
     88        object->azimuthAngle_psi = rot_x;
     89        object->pitchAngle_theta = rot_y;
     90        object->bankAngle_phi = rot_z;
     91        if(label!="")
     92                object->addLabel("XML_defined_label", label);
     93        if(dynamic)
     94        {
     95                updater = new osgVisual::object_updater(object);
     96        }
     97        object->setCameraOffset( cam_trans_x, cam_trans_y, cam_trans_z, cam_rot_x, cam_rot_y, cam_rot_z);
     98        if(filename!="")
     99        {
     100                object->loadGeometry( filename );
     101                object->setGeometryOffset( geometry_rot_x, geometry_rot_y, geometry_rot_z );
     102                object->setScale( geometry_scale_x, geometry_scale_y, geometry_scale_z );
     103        }
     104
     105        if(updater.valid())
     106                object->addUpdater( updater ); 
     107
     108        /*
     109        - updater [optional]: Channels to use for position and attitude update
     110
     111        <updater>
     112          <translation-slots>todo</translation-slots>
     113        </updater>
     114    */
    90115
    91116        OSG_NOTIFY( osg::ALWAYS ) << "Done." << std::endl;
    92         return NULL;
     117        return object;
    93118}
    94119
Note: See TracChangeset for help on using the changeset viewer.