#include <Inventor/nodes/SoImage.h>
Inheritance diagram for SoImage:
Public Types | |
enum | VertAlignment { BOTTOM, HALF, TOP } |
enum | HorAlignment { LEFT, CENTER, RIGHT } |
Public Member Functions | |
SoImage (void) | |
virtual void | GLRender (SoGLRenderAction *action) |
virtual void | rayPick (SoRayPickAction *action) |
virtual void | getPrimitiveCount (SoGetPrimitiveCountAction *action) |
Static Public Member Functions | |
void | initClass (void) |
Public Attributes | |
SoSFInt32 | width |
SoSFInt32 | height |
SoSFEnum | vertAlignment |
SoSFEnum | horAlignment |
SoSFImage | image |
SoSFString | filename |
Protected Member Functions | |
virtual | ~SoImage () |
virtual void | generatePrimitives (SoAction *action) |
virtual void | computeBBox (SoAction *action, SbBox3f &box, SbVec3f ¢er) |
virtual SbBool | readInstance (SoInput *in, unsigned short flags) |
virtual void | notify (SoNotList *list) |
int | getReadStatus (void) |
void | setReadStatus (SbBool flag) |
An image can be specified either by using the image field, or by specifying a filename. If width and or height is specified, the image will be resized to match those values before it is displayed.
The current modelview matrix will be used to find the viewport position, and the image is rendered in that position, with z-buffer testing activated.
Here's a simple, stand-alone example on how to set up and show an SoImage:
#include <stdlib.h> #include <Inventor/Qt/SoQt.h> #include <Inventor/Qt/viewers/SoQtExaminerViewer.h> #include <Inventor/nodes/SoSeparator.h> #include <Inventor/nodes/SoCamera.h> #include <Inventor/nodes/SoCube.h> #include <Inventor/nodes/SoImage.h> static void mandel(double sr, double si, double width, double height, int bwidth, int bheight, int mult, unsigned char * bmp, int n) { double zr, zr_old, zi, cr, ci; int w; for (int y=0; y<bheight; y++) for (int x=0; x<bwidth; x++) { cr = ((double)(x)/(double)(bwidth))*width+sr; ci = ((double)(y)/(double)(bheight))*height+si; zr = zi = 0.0; for (w = 0; (w < n) && (zr*zr + zi*zi)<n; w++) { zr_old = zr; zr = zr*zr - zi*zi + cr; zi = 2*zr_old*zi + ci; } bmp[y*bwidth+x] = w*mult; } } int main(int argc, char ** argv) { QWidget * mainwin = SoQt::init(argv[0]); SoSeparator * root = new SoSeparator; root->ref(); const int IMGWIDTH = 256; const int IMGHEIGHT = 256; unsigned char * img = new unsigned char[IMGWIDTH * IMGHEIGHT]; mandel(-0.5, 0.6, 0.025, 0.025, IMGWIDTH, IMGHEIGHT, 1, img, 256); SoImage * nimage = new SoImage; nimage->vertAlignment = SoImage::HALF; nimage->horAlignment = SoImage::CENTER; nimage->image.setValue(SbVec2s(IMGWIDTH, IMGHEIGHT), 1, img); SoCube * cube = new SoCube; root->addChild(cube); root->addChild(nimage); SoQtExaminerViewer * viewer = new SoQtExaminerViewer(mainwin); viewer->setSceneGraph(root); viewer->setTitle("SoImage use"); viewer->show(); SoCamera * cam = viewer->getCamera(); cam->position = SbVec3f(0, 0, 50); cam->focalDistance = 50; SoQt::show(mainwin); SoQt::mainLoop(); delete viewer; root->unref(); delete img; return 0; }
Coin 1.0
|
Vertical alignment for image. |
|
Horizontal alignment for image. |
|
Constructor. |
|
Destructor. |
|
Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system. Reimplemented from SoShape. |
|
Action method for the SoGLRenderAction. This is called during rendering traversals. Nodes influencing the rendering state in any way or who wants to throw geometry primitives at OpenGL overrides this method. Reimplemented from SoShape. |
|
Calculates picked point based on primitives generated by subclasses. Reimplemented from SoShape. |
|
Action method for the SoGetPrimitiveCountAction. Calculates the number of triangle, line segment and point primitives for the node and adds these to the counters of the action. Nodes influencing how geometry nodes calculates their primitive count also overrides this method to change the relevant state variables. Reimplemented from SoShape. |
|
Will generate a textured quad, representing the image in 3D. Implements SoShape. |
|
Implemented by SoShape subclasses to let the SoShape superclass know the exact size and weighted center point of the shape's bounding box. The bounding box and center point should be calculated and returned in the local coordinate system. The method implements action behavior for shape nodes for SoGetBoundingBoxAction. It is invoked from SoShape::getBoundingBox(). (Subclasses should not override SoNode::getBoundingBox().) The box parameter sent in is guaranteed to be an empty box, while center is undefined upon function entry. Implements SoShape. |
|
This method is mainly intended for internal use during file import operations. It reads a definition of an instance from the input stream in. The input stream state points to the start of a serialized / persistant representation of an instance of this class type.
flags is used internally during binary import when reading user extension nodes, group nodes or engines. Reimplemented from SoNode. |
|
Notifies all auditors for this instance when changes are made. Reimplemented from SoNode. |
|
Returns TRUE if node was read ok. |
|
Set read status for this node. |
|
If bigger than 0, resize image to this width before rendering. Default value is -1 (ie "don't resize"). |
|
If bigger than 0, resize image to this height before rendering. Default value is -1 (ie "don't resize"). |
|
Vertical alignment. Default value is SoImage::BOTTOM. |
|
Horizontal alignment. Default value is SoImage::LEFT. |
|
Inline image data. Default empty. |
|
Image filename. Default empty. |