13.4. Generating HTML


From a given scene graph containing a camera, this action generates an image file (an off-screen rendering of the scene graph) and an HTML file. The HTML file contains a reference to the image file (<IMG>) and the image map (<MAP>). Each region of the image map will have a URL associated with it.

With HTML, image maps allow you to specify regions of an image and assign a specific action to each region (a link can be associated with each map). When the region is clicked by the user, the action is executed.

Each region of the image is determined by a subgraph which is under an SoWWWAnchor SoWWWAnchor SoWWWAnchor group node.

The generated HTML file contains, in the following order:

  1. An image map tag that defines the region corresponding to each subgraph that is under an SoWWWAnchor SoWWWAnchor SoWWWAnchor group node. For each region, the associated link is the URL defined either by the SoWWWAnchor SoWWWAnchor SoWWWAnchor node.

  2. An image tag that references the image generated by SoToHTMLAction SoToHTMLAction SoToHTMLAction .

You can specify the format used to generate the image:

myAction->setImageFormat(SoToHTMLAction::JPEG_FORMAT);
  
myAction.SetImageFormat(SoToHTMLAction.ImageFormats.JPEG_FORMAT);
  
myAction.setImageFormat(SoToHTMLAction.ImageFormats.JPEG_FORMAT);
  

To specify the quality of the output, from 0.0 (worst) to 1.0 (best):

float quality;
quality = 0.75;
myAction->setImageQuality(quality);
  
float quality;
quality = 0.75f;
myAction.SetImageQuality(quality);
  
float quality;
quality = 0.75f;
myAction.setImageQuality(quality);
  

For JPEG output this specifies the amount of compression used to generate/store the JPEG image.

Next, specify the components used to describe the image pixels:

myAction->setImageComponents(SoToHTMLAction::RGB);
  
myAction.SetImageComponents(SoToHTMLAction.Components.RGB);
  
myAction.setImageComponents(SoToHTMLAction.Components.RGB);
  

You can chose from:

  • LUMINANCE

  • LUMINANCE_TRANSPARENCY

  • RGB

  • RGB_TRANSPARENCY

By default, the image component is RGB.

To specify the background color to be used for the image:

// Specify a RED background.
myAction->setImageBackgroundColor(SbColor(1,0,0));
  
// Specify a RED background.
myAction.SetImageBackgroundColor(new SbColor(1, 0, 0));
  
// Specify a RED background.
myAction.setImageBackgroundColor(new SbColor(1, 0, 0));
  

To specify the size of the image:

// This will create a 200x200 image.
myAction->setViewportRegion(SbViewportRegion(200,200));
  
// This will create a 200x200 image.
myAction.SetViewportRegion(new SbViewportRegion(200, 200));
 
// This will create a 200x200 image.
myAction.setViewportRegion(new SbViewportRegion((short)200, (short)200));

The image format, image quality, image component, background color, and size can be retrieved by:

SoToHTMLAction::ImageFormat format = myAction->getImageFormat();
float quality = myAction->getImageQuality();
SoToHTMLAction::Component components = myAction->getImageComponents();
const SbColor backColor = myAction-> getImageBackgroundColor();
const SbViewportRegion size = myAction->getViewportRegion();
  
SoToHTMLAction.ImageFormats format = myAction.GetImageFormat();
float quality = myAction.GetImageQuality();
SoToHTMLAction.Components components = myAction.GetImageComponents();
SbColor backColor = myAction.GetImageBackgroundColor();
SbViewportRegion size = myAction.GetViewportRegion();
SoToHTMLAction.ImageFormats format = myAction.getImageFormat();
float quality = myAction.getImageQuality();
SoToHTMLAction.Components components = myAction.getImageComponents();
SbColor backColor = myAction.getImageBackgroundColor();
SbViewportRegion size = myAction.getViewportRegion();