Using RAYZ Library Operations

RAYZ allows the plugin programmer access to its own internal image manipulation routines, such as scaling, brightness, over, etc. The purpose of this is to allow the programmer to concentrate on the parts of the plugin which are unique, while avoiding reinventing base functions.

For example, say you want to build a node which does camera shake. A simple way to do this is to generate the XY offsets for the image, and then use the RAYZ Transform utility to do the actual work. The code for that is given in source/EarthQuake.C, and the relevant parts of that plugin are shown below, with the library operations shown in bold.


static CPI_ImageOp
QuakeExec( CPI_Float32      time,
           CPI_Uint8        quality,
           CPI_Uint32       output,
           CPI_Bool         viewerOutput,
           CPI_Float32      scaleX,
           CPI_Float32      scaleY )

{
    CPI_ImageOp          retval = NULL;
    CPI_ImageOp          myInput;
    CPI_Float32          maxZrot, maxX, maxY, speed;
    CPI_Float32          xoff, yoff, roll, px, py;
    CPI_Int32            sizeX, sizeY;

    // get the input image
    myInput = cpiGetInputOp( 0, time, quality, scaleX, scaleY );

    // get the parameters from the user
    cpiGetFloat( &maxZrot, "roll", time );  
    cpiGetFloat( &maxX, "shift.x", time );  
    cpiGetFloat( &maxY, "shift.y", time );  
    cpiGetFloat( &speed, "speed", time );  

    // compute the tranform values
    roll = maxZrot * newrand() * speed;
    xoff = maxX * newrand() * speed;
    yoff = maxY * newrand() * speed;

    // get the input size - pivot and translates need
    // to be given in pixel values
    cpiGetInputFullSize( &sizeX, &sizeY, 0, time );
    px = CPI_Float32(sizeX) / 2.0F;
    py = CPI_Float32(sizeY) / 2.0F;

    // set up the metadata
    // metadata variable names are defined in 
    // Appendix B - 
				Internal Ops Reference List
    CPI_Metadata theParms = cpiCreateMetadata();

    cpiSetMetaFloat32( theParms, "movex", xoff );
    cpiSetMetaFloat32( theParms, "movey", yoff );
    cpiSetMetaFloat32( theParms, "rotatez", roll );
    cpiSetMetaFloat32( theParms, "pivotx", px);
    cpiSetMetaFloat32( theParms, "pivoty", py );
    cpiSetMetaString( theParms, "order", "RTS" );

    
    // add the 'transform' op to the list. This is an internal
    // RAYZ image op
    if ( NULL != myInput )
        retval = cpiAddImageOp( "transform", theParms, &myInput, 1 );
    

    cpiDeleteMetadata( theParms );
    return retval;
}
In this case, there is no internal operation to define, because we are simply taking advantage of the RAYZ Image Op called "transform".

It is possible to use more than one Image Op in the same plugin, and / or to mix your own Image Ops with RAYZ internal ones.

Also see the BlurXY.C source example.


[Previous Page] [Next Page]
[Table of Contents] [Index]

Copyright © 2002 Silicon Grail Inc.
736 Seward Street, Hollywood, CA 90038