primitive

primitive — 3D primitive generation functions

Functions

Includes

#include <g3d/primitive.h>

Description

Primitives are objects containing basic 3D geometrical structures. A variety of them can be created using these functions.

Functions

g3d_primitive_cube ()

G3DObject *
g3d_primitive_cube (G3DFloat width,
                    G3DFloat height,
                    G3DFloat depth,
                    G3DMaterial *material);

Generates an object containing a box. It is deprecated and now a wrapper for g3d_primitive_box().

Parameters

width

the width of the box

 

height

the height of the box

 

depth

the depth of the box

 

material

the material to use for all faces

 

Returns

the box object


g3d_primitive_box ()

G3DObject *
g3d_primitive_box (G3DFloat width,
                   G3DFloat height,
                   G3DFloat depth,
                   G3DMaterial *material);

Generates an object containing a box.

Parameters

width

the width of the box

 

height

the height of the box

 

depth

the depth of the box

 

material

the material to use for all faces

 

Returns

the box object


g3d_primitive_box_strip_2d ()

G3DObject *
g3d_primitive_box_strip_2d (guint32 vcnt,
                            gdouble *vdata,
                            gdouble height,
                            gdouble width,
                            G3DMaterial *material);

Generates a strip of box segments defined by corner center points using two-dimensional data (x/z plane).

Parameters

vcnt

number of control points

 

vdata

2-dimensional control point data (2 * vcnt * gdouble)

 

height

height of resulting strip (y component)

 

width

width of strip (corner diameter)

 

material

material to use for faces

 

Returns

strip object


g3d_primitive_mesh ()

G3DObject *
g3d_primitive_mesh (guint32 m,
                    guint32 n,
                    gboolean wrap_m,
                    gboolean wrap_n,
                    G3DMaterial *material);

Generate a mesh consisting of m * n vertices. The vertex data is initialized with (0.0, 0.0, 0.0) and has to be set to something useful.

Parameters

m

number of vertices in m direction

 

n

number of vertices in n direction

 

wrap_m

wrap around in m direction

 

wrap_n

wrap around in n direction

 

material

material to use for faces

 

Returns

mesh object


g3d_primitive_cylinder ()

G3DObject *
g3d_primitive_cylinder (G3DFloat radius,
                        G3DFloat height,
                        guint32 sides,
                        gboolean top,
                        gboolean bottom,
                        G3DMaterial *material);

Generates an object containing a cylinder.

Parameters

radius

the radius of the cylinder

 

height

the height of the side faces

 

sides

number of side faces (number of circle segments)

 

top

add top faces

 

bottom

add bottom faces

 

material

material to use for faces

 

Returns

cylinder object


g3d_primitive_tube ()

G3DObject *
g3d_primitive_tube (G3DFloat r_in,
                    G3DFloat r_out,
                    G3DFloat height,
                    guint32 sides,
                    gboolean top,
                    gboolean bottom,
                    G3DMaterial *material);

Generates an object containing a tube (a cylinder with a hole).

Parameters

r_in

inner radius

 

r_out

outer radius

 

height

the height of the side faces

 

sides

number of side faces (number of circle segments)

 

top

add top faces

 

bottom

add bottom faces

 

material

material to use for faces

 

Returns

tube object


g3d_primitive_sphere ()

G3DObject *
g3d_primitive_sphere (G3DFloat radius,
                      guint32 vseg,
                      guint32 hseg,
                      G3DMaterial *material);

Generates an object containing a sphere.

Parameters

radius

radius

 

vseg

number of vertical segments

 

hseg

number of horizontal segments

 

material

material to use for faces

 

Returns

sphere object