Hello Dominik,

Dominik Rau wrote:
> 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?

I'm fine making this change (the implementation looks good to me too), 
but want to point out that it may have performance implications as the 
decomposition of a matrix into "components" is not very fast right now 
(it should be correct though - I reimplemented this a while ago).
Again, I'll be happy to make the change, as I agree it is more helpful 
to be consistent in this case than it is to optimize this without 
evidence that it is a bottleneck, just wanted to point it out and see if 
anyone has a different opinion :)

        Cheers,
                Carsten

------------------------------------------------------------------------------
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