Agar Logo

Agar 1.7 Manual

(Printable Version)
SG_Image(3)

SYNOPSIS

#include <agar/core.h>
#include <agar/sg.h>

DESCRIPTION

The SG_Image node maps an input image onto a polygonal mesh. If transparency information is available, SG_Image generates a complex polygon contour for the image.

INHERITANCE HIERARCHY

AG_Object(3)-> SG_Node(3)-> SG_Image.

INITIALIZATION


SG_Image * SG_ImageNew (SG_Node *parent, const char *name)

SG_Image * SG_ImageFromSurface (SG_Node *parent, const char *name, AG_Surface *s)

SG_Image * SG_ImageFromSurfaceNODUP (SG_Node *parent, const char *name, AG_Surface *s)

SG_Image * SG_ImageFromAnim (SG_Node *parent, const char *name, const AG_Anim *anim)

SG_Image * SG_ImageFromAnimNODUP (SG_Node *parent, const char *name, AG_Anim *anim)

void SG_ImageSetSurface (SG_Image *bb, const AG_Surface *s, M_Real scale)

void SG_ImageSetSurfaceNODUP (SG_Image *bb, AG_Surface *s)

int SG_ImageSetAnim (SG_Image *bb, AG_Anim *anim)

int SG_ImageSetAnimNODUP (SG_Image *bb, AG_Anim *anim)

void SG_ImageAnimPlay (SG_Image *bb)

void SG_ImageAnimStop (SG_Image *bb)

void SG_ImageSetShape (SG_Image *bb, enum sg_image_shape shape)

void SG_ImageSetShapeAuto (SG_Image *bb)

void SG_ImageSetProj (SG_Image *bb, int enable)

void SG_ImageSetTolContour (SG_Image *bb, float tol)

void SG_ImageSetSize (SG_Image *bb, M_Real w, M_Real h)

void SG_ImageSetColor (SG_Image *bb, const AG_Color *c)


The SG_ImageNew() function creates a new image node at the origin of the parent node. The SG_ImageFromSurface() and SG_ImageFromAnim() variants set an initial surface or animation.

The SG_ImageSetSurface() function loads the specified surface. Image pixels are related to SG(3) node coordinates by the scaling factor scale.

The SG_ImageSetAnim() function loads the specified animation (see AG_Anim(3)). Playback can be initiated or stopped with SG_ImageAnimPlay() and SG_ImageAnimStop().

SG_ImageSetShape() selects the contour shape for the image object. Possible values for shape include:
SG_IMAGE_RECTRender as solid rectangle.
SG_IMAGE_POLYGONRender as a complex polygon calculated from the contours of the image. The contour of the polygon is reduced to a manageable set of vertices using Douglas-Peucker polygon simplification.

The SG_ImageSetShapeAuto() function scans the image and selects SG_IMAGE_POLYGON if a usable shape exists over a transparent background, otherwise the SG_IMAGE_RECT shape is selected.

SG_ImageSetProj() configures the image projection mode. If an argument of 1 is given, the image object will be rendered as to always face the camera. Otherwise, the object is rendered as a textured plane in its original orientation (the default).

SG_ImageSetTolContour() sets the tolerance for Douglas-Peucker simplification (default is 10.0).

SG_ImageSetSize() sets the relative size of the image (default is 1.0 x 1.0).

SG_ImageSetColor() sets the background color (RGBA) of the image object (default is transparent black).

FLAGS

The following public SG_Image flags are defined:
SG_IMAGE_BILLBOARDEnable billboard projection (image will be rendered as facing the camera).
SG_IMAGE_WIREFRAMEOverlay the wireframe structure ontop of the image surface. This can be useful when adjusting the contour tolerance.

STRUCTURE DATA

For the SG_Image object:
Uint flags Option flags (see FLAGS section).
M_Color color Background color.
AG_Surface *su Current source surface (read-only; use
M_Real w Width (default is 1.0).
M_Real h Height (default is 1.0).
float tolContour Tolerance for polygon simplification (default is 10.0).

SEE ALSO


HISTORY

The SG_Image node class first appeared in Agar 1.6.0.

Csoft.net ElectronTubeStore