Hi Antonio,
> I tried to add the image in two ways... But it doesn't work at all!
>
> beginEditCP(imf);
> imf->addImage( image, position );
> endEditCP(imf);
>
> In this first case the image is not updated when I modify it...
>
> beginEditCP(imf, ImageForeground::ImagesFieldMask);
> imf->addImage( image, position );
> endEditCP(imf, ImageForeground::ImagesFieldMask);
>
> In this case the image is not visible!
Since you use a cluster, you should be careful with the FieldMasks, addImage
changes the images MField as well as the positions MField, so to be sure all
changes are transmitted the second call should be:
beginEditCP(imf, ImageForeground::ImagesFieldMask |
ImageForeground::PositionsFieldMask);
and the same for the endEditCP call.
>
> Here there is all the code... I hope somebody sees an error! Anyway,
> thanks for your help.
you only add the image, when first == 0, which by itself is ok, but for first >
0 you want to change the image in the Foreground, see code below.
> addForeground( ViewportPtr viewportRight, ViewportPtr viewportLeft, string
> label )
> {
> //addForeground is called continuously. We use this counter to add image
> and foreground only the first time
> static int first = 0;
>
> // Create the new image
> Text2d *oText = new Text2d( makeCoredNode<Group>() );
> oText->createLabel( label, 26 );
> oText->setLabelPosition(Pnt3f(0.0f,0.0f,0.0f),0);
> image = oText->getImage();
>
> if (first<1)
> {
> beginEditCP(imf, ImageForeground::ImagesFieldMask);
> imf->addImage( image, position );
> endEditCP(imf, ImageForeground::ImagesFieldMask);
>
> beginEditCP( viewportRight);
> viewportRight->getForegrounds().push_back(imf);
> endEditCP( viewportRight);
>
> beginEditCP( viewportLeft);
> viewportLeft->getForegrounds().push_back(imf);
> endEditCP( viewportLeft);
>
> first++;
> }
>
> delete oText;
> }
Try adding this else branch to your code (this is untested, though). There is
no convenience method setImage(ImagePtr image, Pnt2f pos, UInt32 index) in the
ImageForeground, so we have to go and change the field "by hand".
else
{
MFImagePtr& images = imf->getImages();
beginEditCP(imf, ImageForeground::ImagesFieldMask);
images[0] = image;
endEditCP(imf, ImageForeground::ImagesFieldMask);
}
Hope it helps,
Carsten
--
Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users