Hi.

In my application, I use mostly ComponentTransforms, as they are better 
suited for my purpose and "easier" to hande (in my particular case). 
However, from time to time, I also use the setMatrix() method. 
Unfortunately, setting the matrix directly on a ComponentTransform 
leaves the translate, rotate etc. fields of the ComponentTransform 
untouched -> they are wrong afterwards.

I added this small piece of code to the ComponentTransform (of OpenSG 
2.0, but 1.x had the same problem AFAIR) changed method to overcome this:

void ComponentTransform::changed(ConstFieldMaskArg whichField,
                                 UInt32            origin,
                                 BitVector         details)
{
    if((whichField & CenterFieldMask          ) ||
       (whichField & RotationFieldMask        ) ||
       (whichField & ScaleFieldMask           ) ||
       (whichField & ScaleOrientationFieldMask) ||
       (whichField & TranslationFieldMask     )  )
    {
        editMatrix().setTransform(getTranslation     (),
                                  getRotation        (),
                                  getScale           (),
                                  getScaleOrientation(),
                                  getCenter          ());
    }
    else if(whichField & MatrixFieldMask)
    {
      OSG::Vec3f translation;
      OSG::Quaternion rotation;
      OSG::Vec3f scale;
      OSG::Quaternion scaleOrientation;
      OSG::Vec3f center;

      getMatrix().getTransform(translation, rotation, scale, 
scaleOrientation, center);
      _sfTranslation.setValue(translation);
      _sfRotation.setValue(rotation);
      _sfScale.setValue(scale);
      _sfScaleOrientation.setValue(scaleOrientation);
      _sfCenter.setValue(center);
    }

    Inherited::changed(whichField, origin, details);
}

If this is the right way to do it (my mostly single threaded app shows 
the right values with it), could  please anybody add it to the 
repository? Ot otherwise, if this is not correct, fix it accordingly?

Thanks,
Dominik


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to