Hi Dirk

Dirk Reiners schrieb:

Or can I use a PolygonForeground instead with a second Viewport, that is hidden?


That was the idea, yes. Add a new Viewport with your desired size, and
add it to the front of the port Field in the Window, so that it is
rendered first. You need to set a Camera, a scene root and a background,
otherwise the Viewport won't render. They won't matter as you're hiding
everything behind a PolygonForeground, but the Viewport needs them to
work (I might relax that in future versions, but that's what it is right
now). Then add your PolygonForeground and a GrabForeground or
TextureGrabForeground to get stuff into a usable place.

Hope it helps

        Dirk

Thanks, that all worked fine so far, but I don't get the PolygonForeground to work and I don't see my mistake, if I have one. But I think I have, because my application crashes at startup. Anyway, the PolygonForeground usage seems a bit strange to me, because of the 2d positions and the 3d texture coordinates.

Here is my code. (I've tried an ImageForeground instead of the PolygonForeground, that worked fine, but this does not!)

// ------------

// data image (add here more data textures)
ImagePtr _image = Image::create();
image->read("data/dataImages/dataset01.tif");

// and result image
ImagePtr _result = Image::create();

// texture for the polygon foreground
TextureChunkPtr tex = TextureChunk::create();
tex->setImage(_image);
tex->setEnvMode(GL_MODULATE);
tex->setMinFilter(GL_LINEAR_MIPMAP_LINEAR);
tex->setMagFilter(GL_NEAREST);

// texture for the texture grab foreground
TextureChunkPtr result = TextureChunk::create();
result->setImage(_result);
result->setEnvMode(GL_MODULATE);
result->setMinFilter(GL_LINEAR_MIPMAP_LINEAR);
result->setMagFilter(GL_NEAREST);

// material for the polygon foreground
ChunkMaterialPtr mat = ChunkMaterial::create();
mat->addChunk(tex);

/* // try the image foreground instead
ImageForegroundPtr polyFrgnd = ImageForeground::create();
polyFrgnd->addImage(_image, Pnt2f(0,0));
*/

// the polygon foreground
PolygonForegroundPtr polyFrgnd = PolygonForeground::create();
polyFrgnd->setMaterial(mat);

polyFrgnd->getMFPositions()->push_back(Pnt2f(0.0, 0.0));
polyFrgnd->getMFPositions()->push_back(Pnt2f(1.0, 0.0));
polyFrgnd->getMFPositions()->push_back(Pnt2f(1.0, 1.0));
polyFrgnd->getMFPositions()->push_back(Pnt2f(0.0, 1.0));

polyFrgnd->getMFTexCoords()->push_back(Vec3f(0.0, 0.0, 0.0));
polyFrgnd->getMFTexCoords()->push_back(Vec3f(1.0, 0.0, 0.0));
polyFrgnd->getMFTexCoords()->push_back(Vec3f(1.0, 1.0, 0.0));
polyFrgnd->getMFTexCoords()->push_back(Vec3f(0.0, 1.0, 0.0));

// the texture grab foreground
TextureGrabForegroundPtr grabFrgnd = TextureGrabForeground::create();
grabFrgnd->setTexture(result);

// the camera
MatrixCameraPtr cam = MatrixCamera::create();
cam->setNear(0.1);
cam->setFar(10);
cam->setModelviewMatrix(Matrix::identity());
cam->setProjectionMatrix(Matrix::identity());

// m_vp is the first viewport, m_vp2 is the second
m_vp2 = Viewport::create();
m_vp2->setCamera(cam);
m_vp2->setBackground(m_vp->getBackground());
m_vp2->getMFForegrounds()->push_back(polyFrgnd);
m_vp2->getMFForegrounds()->push_back(grabFrgnd);
m_vp2->setRoot(makeCoredNode<Group>());
m_vp2->setSize(0,0,256.0f/w,256.0f/h);

// ------------

I think, this should be the last of this emails.
And thanks for the help.

Oliver


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to