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.

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. 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?
*================================================================

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?*
    endEditCP(g_ptrGeoQuad);
================================================================

So, what is your suggestion to write such a program? 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?

The email is a little long, I hope it will not bother you too much~~

Thanks

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

Reply via email to