Oops! Sorry. I was thinking halfway to the 2.x API (I think)

How about viewport->getMFForegrounds()->setValue(0, ptr). That should 
work on any MField according to the documentation.

http://www.opensg.org/doc-1.6.0/classosg_1_1MFForegroundPtr.html

Cheers,
/Marcus

Jie Liu wrote:
> *"* g_ptrViewport->getMFForegrounds()[0] = ptrImgForeground; *"*
> 
> Sorry, the compiler reports an error: binary '=' :
> no operator found which takes a right-hand operand of type 
> 'osg::ImageForegroundPtr' (or there is no acceptable conversion)
> 
> My compiler is VC++, but I dont think this is an issue
> 
> 
> 
> 2009/8/10 Marcus Lindblom <[email protected] 
> <mailto:[email protected]>>
> 
>     Jie Liu wrote:OO
>      > Hi,
>      >
>      > I want to use OpenSG do display about 150 images located in a given
>      > directory.
>      > For each time, I show one of them, and I press left key or right
>     key to
>      > nevigate backward or forward. All images should align center,
>     keep their
>      > width/height (w/h) ratio and they will fit to the width or height
>     of the
>      > window according to the value of w/h ratio.
>      >
>      > I now have three solutions for this purpose.
>      > a). take an image as a background object. The problem is OpenSG will
>      > auto scale the image to the window area for me. But as I must
>     keep the
>      > width/height ratio of the image, I give up.
> 
>     That's just how the default ImageBackground works currently. Adding
>     aspect-keeping functionality would be a welcome patch though. :)
> 
>      > b). take an image as a foreground object, the problem is I can only
>      > appoint its bottom-left position. There seems no parameters for me to
>      > scale its size.
> 
>     IIRC, I'm not sure OpenGL can scale images uploaded with glWritePixels,
>     so that would be OpenGL's fault, not OpenSG's. :)
> 
>      > Below are my code to do this
>      > ===================================================================
>      >     ImagePtr tImage = Image::create();
>      >     *tImage->read(file_name[index]);*  *// I change the value of
>     /index/
>      > to display different images. Images are loaded dynamically
>     according to
>      > their names*
>      >
>      >     ImageForegroundPtr ptrImgForeground = ImageForeground::create();
>      >     beginEditCP(ptrImgForeground);
>      >     {
>      > *        ptrImgForeground->addImage(tImage, Pnt2f(0.0, 0)); // Can I
>      > assign a bounding box for an image? Or do I have to manually
>     scale the
>      > image first?*
>      >     }
>      >     endEditCP(ptrImgForeground);
>      >
>      >    *
>     g_ptrViewport->getMFForegrounds()->push_back(ptrImgForeground); *
>      > *// push_back is to add a new image to the queue, OpenSG will try to
>      > render all images in the queue and this will slow down the rendering
>      > speed obviously. But I only want to display a single image at one
>     time.
>      > So what is the right and efficient way to replace the current
>     foreground
>      > image?
> 
>     g_ptrViewport->getMFForegrounds()[0] = ptrImgForeground;
> 
>      > *================================================================
>      >
>      > c). Take an image as a texture material, and attach it to a Quad
>     primitive.
>      > ================================================================
>      >     ImagePtr tImage = Image::create();
>      >     tImage->read(file_name[index]);
>      >
>      >     beginEditCP(g_ptrGeoTex);
>      >     g_ptrGeoTex->setImage(tImage); *// g_ptrGeoTex is a globle
>     variable,
>      > its type is SimpleTexturedMaterialPtr*
>      >     endEditCP(g_ptrGeoTex);
>      >
>      >     beginEditCP(g_ptrGeoQuad);
>      >         g_ptrGeoQuad->setMaterial(g_ptrGeoTex);*  // I found the
>      > setMaterial process will be very very slow, how can I accelerate it?*
> 
>     You're probably suffering from auto mipmap generation here. (Mipmapping
>     for textures is enabled by default, and if you set an image with no
>     mipmaps, OpenSG creates them for you whe you use the material for the
>     first time). Try setting the minification filter (minFilter) to
>     GL_LINEAR.
> 
>      >     endEditCP(g_ptrGeoQuad);
>      > ================================================================
>      >
>      > So, what is your suggestion to write such a program?
> 
>     If you have enough memory (system and gfx) textures is probably the way
>     to go, because you can do more fun stuff with them (animation etc).
> 
>     If not, you probably need to use ImageBackground or ImageForeground, but
>     neither of these do what you want currently, so you need to hack them a
>     bit. If you know OpenGL well enough to do get it to do what you want,
>     this is pretty easy. (I haven't looked at that part of OpenGL for a
>     time, so I can't say if nor how it can and should be done. Maybe some
>     other guys know better).
> 
>      > I also want to load
>      > all iamges at the begining of the program and store them in vectors
>      > (vector<ImagePtr>, and vector<SimpleTexturedMaterialPtr>), but the
>      > program crashed while switching the image. What is the right way
>     to read
>      > and store all image data?
> 
>     You probably want Image|MaterialRefPtr to make sure your images stay in
>     memory here. However, make sure your images fit in graphics memory if
>     you use textures.
> 
>      > The email is a little long, I hope it will not bother you too much~
> 
>     Not at all. Glad to help. :)
> 
>     Cheers,
>     /Marcus
> 
> 
> 
> 
> 
> 
> 
> 
>     
> ------------------------------------------------------------------------------
>     Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>     30-Day
>     trial. Simplify your report design, integration and deployment - and
>     focus on
>     what you do best, core application coding. Discover what's new with
>     Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>     _______________________________________________
>     Opensg-users mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/opensg-users
> 
> 
> 
> 
> -- 
> Jie Liu
> Visualization Research Group
> Center for Information Science, School of EECS,
> Room 2104, Science Building No.2,
> Peking University, Beijing 100871, China
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Opensg-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensg-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to