SG(3)

NAME
SG - Agar-SG 3D scene graph

SYNOPSIS

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

DESCRIPTION
The SG object is a general-purpose scene-graph, or a collection of nodes (i.e., SG_Node(3) objects) organized in a tree structure. The SG_Node object is used to describe both "group" nodes and "leaf" nodes.

Scene-graphs are usually rendered using the SG_View(3) widget (or a subclass of it).

INHERITANCE HIERARCHY
AG_Object(3) -> SG.

INITIALIZATION
SG * SG_New(void *parent, const char *name, Uint flags)

void SG_Clear(SG *sg)

The SG_New() function allocates, initializes, and attaches a SG object. Acceptable flags options include:

SG_OVERLAY_WIREFRAME
    Overlay wireframe onto geometric objects when rendering scene.

SG_OVERLAY_VERTICES
    Overlay vertices onto geometric objects when rendering scene.

SG_OVERLAY_VNORMALS
    Overlay vertex normals when rendering scene.

SG_OVERLAY_FNORMALS
    Overlay facet normals when rendering scene.

SG_SKIP_UNKNOWN_NODES
    When loading the contents of a scene, ignore unknown/unimplemented elements (otherwise, encountering an unknown node will make the load operation fail).

SG_NO_DEFAULT_NODES
    Don't create the default nodes (e.g., ‘Camera0’, ‘Light0’).

The SG_Clear() routine reinitializes sg to an empty scene. If default nodes (e.g., ‘Camera0’) are used, they are preserved but their state is reinitialized.

NODE QUERIES
SG_Node * SG_SearchNodes(SG_Node *parent, const char *name)

void * SG_FindNode(SG *sg, const char *name)

int SG_Intersect(SG_Node *node, M_Geom3 g, M_GeomSet3 *S)

The SG_SearchNodes() function scans all descendants of parent for a node of the specified name. The SG_FindNode() function searches the entire scene graph sg for a node of the specified name. On success, SG_SearchNodes() and SG_FindNode() return a pointer to the matching node.

The SG_Intersect() function performs an intersection test between the given node and an arbitrary geometrical object g (see M_Geom3(3)). The function returns 1 if the objects intersect, 0 if they don't intersect, or -1 if the test is not implemented. If the S argument is non-NULL, the intersections are computed and returned as one or more geometrical objects, into S. The structure pointed to by S should have been previously initialized with M_GEOM_SET_EMPTY(3).

SEE ALSO
sgedit(1), M_Matrix(3), M_Plane(3), M_Real(3), M_Vector(3), SG_Intro(3)

HISTORY
The SG library first appeared in Agar 1.6.0.