Documentation



Developed by The Demo Factory:
Kevin Brunner
, Tim Davison,
Ed Allard, Bob Penrod

Class SoDMBufferTexture2

SoDMBufferTexture2 is a subclass of the SoTexture2 node which provides texture mapping capabilities in an Inventor scene graph.

The image field is an SoSFDMBufferImage which (once assigned to an SbDMBuffer) provides dynamic (DMbuffer) texture mapping in Inventor on O2 systems.

The transform field is used to automatically adjust texture coordinates for DMbuffer texture pixel data which does not have dimensions which are a power of two.

For example: If image is connected to the textureBits field of an SoDMBufferMovieEngine having a movie with dimensions, 196x115, the SoDMBufferMovieEngine will allocate an SbDMBuffer with dimensions 256x256 and render the movie in the lower right-hand corner. For this reason, the SoDMBufferMovieEngine provides a scale field which can be connected to the transform field. To compensate for the ill-fitting render, the SoDMBufferMovieEngine class would set its scale field as follows:

   float scale[4][4] = { rx,  0,  0,  0,
                          0, ry,  0,  0,
                          0,  0,  1,  0,
                          0,  0,  0,  1 };
 

Where rx = is the ration of the movie's width to the allocated SbDMBuffer width (196/256 = 0.76562); and ry = is the ratio of the movie's height to the SbDMBuffer height (115/256 = 0.44921).

This allows the SoDMBufferTexture2 node to adjust the GL texture matrix stack in such a way that no adjustments should need to be made to down-stream objects -- in short, it does what you would expect.

Example Uses:

Video Texture

    SoDMBufferTexture2 *texture = new SoDMBufferTexture2();
    sep->addChild(texture);

    SoDMBufferVideoEngine *videoIn = new SoDMBufferVideoEngine();
    texture->image.connectFrom( &videoIn->textureBits );
    texture->transform.connectFrom( &videoIn->scale );
 

Movie Texture

    SoDMBufferTexture2 *texture = new SoDMBufferTexture2();
    sep->addChild(texture);

    SoDMBufferMovieEngine *movieIn = new SoDMBufferMovieEngine();
    texture->image.connectFrom( &movieIn->textureBits );
    texture->transform.connectFrom( &movieIn->scale );
 
Renderable Texture
    float scale[4][4] = { rx,  0,  0,  0,
                          0, ry,  0,  0,
                          0,  0,  1,  0,
                          0,  0,  0,  1 };

    SbMatrix renderMatrix;
    renderMatrix.setValue( scale );

    SbDMBuffer *renderDMBuffer;
    renderDMBuffer = new SbDMBuffer( SbVec2s( WIDTH, HEIGHT) );

    Display *display = NULL;
    openStandardPBuffer( display, renderDMBuffer );
    renderDMBuffer->setBufferCount( BUFFERCOUNT );
    renderDMBuffer->createPool();

    SoDMBufferTexture2 *texture = new SoDMBufferTexture2();
    sep->addChild(texture);

    SoSFDMBufferImage *image = new SoSFDMBufferImage();
    texture->image.connectFrom( &renderDMBuffer );
    texture->transform.connectFrom( &renderMatrix );
 

Fields from class SoTexture2:

    SoSFEnum            wrapS
    SoSFEnum            wrapT
    SoSFEnum            model
    SoSFColor           blendColor
 

See Also:
SbDMBuffer.html
SoDMBufferVideoEngine.html
SoDMBufferMovieEngine.html
SoDMBufferDMICMovieEngine.html
Related Man Pages:
SoTexture2
SoSFImage
dmbuffer

Fields

 o dmBufferImage
Must be connected to an SoSFDMBufferImage (such as the output of an SoDMBufferVideoEngine)

 o transform
May be connected to an SoSFMatrix (such as the scale output of an SoDMBufferVideoEngine)