Jim Wilson writes:
>
>Norman Vine <[EMAIL PROTECTED]> said:
>
>> Jim Wilson writes:
>> >
>> >David Megginson <[EMAIL PROTECTED]> said:
>> >
>> >> As of this morning, FlightGear has a new infrastructure for
>> >> incorporating moving, animated 3D models besides the aircraft model.
>> >> This is not intended to be a general solution for adding thousands of
>> >> bridges, buildings, etc. to the scenery
>> >
>> >Why not?
>>
>> My guess after a  quick peek at the code is that because the method
>> used is based on the 'global' FGLocation positioning scheme and will
>> rapidly effect the system's performance.  Just doing the math required
>> to update the transformations ...
>>
>Actually these should only update once if they do not move.

Not really as we need to take into acount that the Transform
will change when the overflown tile changes

Hmm...
With a little masaging this should be possible though :-)

Following 'untested code' assumes that the FGModel3D has a
_type field for distinguishing between static and non-static models
and should be a 'good bit' faster too !!

Norman

void
FG3DModel::update (int dt)
{
  for (unsigned int i = 0; i < _animations.size(); i++)
    _animations[i]->update(dt);

   /* this test for changed scenery center could be a flag in globals
       that was set by the tile_manger every iteration of the main loop */
//  static sgdVec3 last_sc = [ SGD_ZERO, SGD_ZERO, SGD_ZERO ];
//  if( last_sc[0] - scenery_center.x() != 0.0 ||
//    last_sc[1] - scenery_center.y() != 0.0 ||
//    last_sc[2] - scenery_center.z() != 0.0 ||
//    (_type != FGMODEL_STATIC) )
// {
//  sgdSetVec3(last_sc, scenery_center.x(),
//             scenery_center.y(), scenery_center.z());

    _location->setPosition( _lon_deg, _lat_deg, _elev_ft );
    _location->setOrientation( _roll_deg, _pitch_deg, _heading_deg );

    sgVec3 trans;
    sgCopyVec3(trans, _location->get_view_pos());

    sgMat4 POS;
    sgCopyMat4(POS, _location->getTransformMatrix());

    for( int i=0; i<4; i++) {
      float tmp = POS[i][3];
      for( int j=0; j<3; j++ ) {
        POS[i][j] += (tmp * trans[j]);
      }
    }
    _position->setTransform(POS);
//  }
}


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to