Hi,

I have some very strange behaviour of my code. I am trying to cumulate the 
matrices of a subgraph:

(don't know what these questionsmarks should be, maybe you don't see them at 
all and it's a problem of firefox, but if you do, imagine spaces and inequality 
signs instead, that's what I actually added here.)

Code:
     Matrix m;
     osg::MatrixTransform *transform = NULL;
     for( osg::NodePath::iterator it = pathList[0].begin(); it != 
pathList[0].end(); ++it )
     {
          transform = dynamic_cast<osg::MatrixTransform*>( *it );
          if( transform )
               m.preMult( transform->getMatrix() );
     }


This subgraph consists of three osg::MatrixTransforms. If I debug into this 
loop I can see in the watch window (MSVS, which also displays the actual type 
of the instance) that actually two of the three are just osg::Transforms (even 
though I have created them as osg::MatrixTransforms) which prevents me from 
casting and accessing the contained matrix. However I also can see there is a 
member _matrix which suggests the type actually IS osg::MatrixTransform. 

The transforms are created in the initializerlist of a constructor:

Code:
     OsgArtTracking::ARNodes::ARNodes( osgART::Marker *marker, double scale, 
bool insertAxes, 
                     bool enableVisibilityCallback, bool 
enableMarkerDebugCallback ) :
     scaleNode( new osg::MatrixTransform() ),
     fixCSNode( new osg::MatrixTransform( osg::Matrix::rotate( osg::PI / 2.0, 
osg::Vec3( 1.0, 0.0, 0.0 ) ) ) ),
     arTransform( new osg::MatrixTransform() ),
     marker( marker )
{
     ...



all of them are osg::ref_ptrs:

Code:

     osg::ref_ptr<osg::MatrixTransform>     scaleNode;
     osg::ref_ptr<osg::MatrixTransform>     fixCSNode;
     osg::ref_ptr<osg::MatrixTransform>     arTransform;



If I debug into the constructor I can see that the osg::MatrixTransform 
constructor is called on all of them. In the next line my debugger says they 
are just osg::Transforms, also dynamiccasting them to osg::MatrixTransform 
fails.

How is this even possible? Any ideas? (MSVC 9.0, no optimizations enabled, 
mostly default settings of configuration "Debug")

Thanks,
Jason

------------------------
ithrak (Jason Fisher)

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=23114#23114





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to