---
name: "sipp_primitives"
section: "3"
platform: "linux"
package: "sipp-dev"
version: "3.1-11"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/sipp_primitives"
---

# sipp\_primitives(3)

a collection of object primitives for SIPP.

## NAME

primitives - a collection of object primitives for SIPP.

## SYNOPSIS

*#include \<primitives.h\>*

\[g\]cc \[*flags*\] *files* -lsipp -lm \[ *libraries* \]

## DESCRIPTION

SIPP gives the user access to a number of rather low level functions to create polygons, surfaces and objects. This manual describes a set of functions that use the low level functions in SIPP to create geometric primitives. Each primitive is a complete SIPP object.

Each object primitive has a last argument that describes what kind of texture coordinates should be assigned to the surface of the object. This texture parameter should be one of: *NATURAL*, *CYLINDRICAL*, *SPHERICAL* or *WORD*. See the user manual for a detailed description of the meaning of the different values.

## PRIMITIVES

- *Object \*sipp\_torus(bigradius, smallradius, res1, res2, surface, shader, texture)*

  *double  bigradius;*\
   *double  smallradius;*\
   *int     res1;*\
   *int     res2;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_torus()* creates a torus centered about the origin and with the z-axis pointing up through the ring. *NATURAL* texture mapping is a two dimensional mapping with the *x* coordinate going around the "small" circle and the *y* coordinate going around the "large" circle.

- *Object \*sipp\_cone(bot\_rad, ,top\_rad, length, resolution, surface,shader, texture)*

  *double  bot\_rad;*\
   *double  top\_rad;*\
   *double  length;*\
   *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_cone()* creates a, possibly truncated, cone centered about the origin and with the z-axis along the cones main axis. *NATURAL* texture mapping is *CYLINDRICAL*.

- *Object \*sipp\_cylinder(radius, length, resolution, surface, shader, texture)*

  *double  radius;*\
   *double  length;*\
   *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_cylinder()* creates a cylinder centered about the origin and with the z-axis along the cylinders main axis. *NATURAL* texture mapping is *CYLINDRICAL*.

- *Object \*sipp\_ellipsoid(x\_rad, y\_rad, z\_rad, resolution, surface, shader, texture)*

  *double  x\_rad;*\
   *double  y\_rad;*\
   *double  z\_rad;*\
   *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_ellipsoid()* creates a ellipsoid centered about the origin. *NATURAL* texture mapping is *SPHERICAL*.

- *Object \*sipp\_sphere(radius, resolution, surface, shader, texture)*

  *double  radius;*\
   *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_sphere()* creates a sphere centered about the origin. *NATURAL* texture mapping is *SPHERICAL*.

- *Object \*sipp\_prism(num\_points, points, length, surface, shader, texture)*

  *int     num\_points;*\
   *Vector \*points;*\
   *double  length;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_prism()* creates a prism defined by the polygon in *points*. Only the x and y values are used and the prism will ascend and descend equally far (*length* / 2.0) from the x-y plane along the z axis. *NATURAL* texture mapping is similar to *CYLINDRICAL* but the *x* coordinate is not taken from projection on a cylinder but is evenly distributed around the perimeter. An odd thing in all the 2D mappings for the prism is that the top face will have texture coordinates (0.0, 1.0) while the bottom will get (0.0, 0.0).

- *Object \*sipp\_block(x\_size, y\_size, z\_size, surface, shader, texture)*

  *double  x\_size;*\
   *double  y\_size;*\
   *double  z\_size;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_block()* creates a rectangular block with the size defined by *x\_size*, *z\_size* and *z\_size*. The block is centered about the origin. *NATURAL* texture mapping is similar to *CYLINDRICAL* but the *x* coordinate is not taken from projection on a cylinder but is evenly distributed around the perimeter. An odd thing in all the 2D mappings for the block is that the top face will have texture coordinates (0.0, 1.0) while the bottom will get (0.0, 0.0).

- *Object \*sipp\_cube(side, surface, shader, texture)*

  *double  side;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_cube()* creates a cube with the side of length *side*.  The cube is centered about the origin. *NATURAL* texture mapping is similar to *CYLINDRICAL* but the *x* coordinate is not taken from projection on a cylinder but is evenly distributed around the perimeter. An odd thing in all the 2D mappings for the cube is that the top face will have texture coordinates (0.0, 1.0) while the bottom will get (0.0, 0.0).

- *Object \*sipp\_bezier\_patch(num\_vertex, vertex, num\_patch, vx\_index, res, surface, shader, texture)*

  *int     num\_vertex;*\
   *Vector  vertex\[\];*\
   *int     num\_patch;*\
   *int     vx\_index\[\];*\
   *int     res;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  This function creates one or more bezier patches. All created patches in a call will belong to the same surface.  The texture coordinates are a bit special for the bezier patches.  *CYLINDRICAL* and *SPHERICAL* coordinates are not applicable, if they are specified, SIPP will use *NATURAL* anyway. The *NATURAL* mapping is a two dimensional mapping using the surface parameters *u* and *v*. Note that these parameters range from 0 to 1 within each patch!

- *Object \*sipp\_bezier\_rotcurve(num\_vertex, vertex, num\_curve, vx\_index, res, surface, shader, texture)*

  *int     num\_vertex;*\
   *Vector  vertex\[\];*\
   *int     num\_curve;*\
   *int     vx\_index\[\];*\
   *int     res;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  This function creates a surface by rotating one or more bezier curves about the world z-axis.  The texture coordinates are a bit special for these surfaces.  *SPHERICAL* and *CYLINDRICAL* mappings are not applicable, and *NATURAL* mapping will apply to the peace of surface created by each bezier curve separately. The *NATURAL* mapping uses the curve parameter *u* along each curve as *x* coordinate and goes from 0 to 1 around the perimeter of the rotational surface on the other axis

- *Object \*sipp\_bezier\_file(file, res, surface, shader, texture)*

  *FILE   \*file;*\
   *int     res;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_bezier\_file()* reads a file containing descriptions of a set of bezier patches or bezier curves. See the user manual for a detailed description of the format of the definition file. Texture coordinates are assigned in the same way as in *sipp\_bezier\_patch()* and *sipp\_bezier\_rotcurve()*.

- *Object \*sipp\_teapot(resolution, surface, shader, texture)*

  *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  *sipp\_teapot()* creates a model of the famous "Utah Teapot". It is built as a combined object of four subobjects: body, lid, handle and spout (no, there is no bottom). Each of these subobjects are also available as separate primitive objects. The body and lid are created as Bezier rotation curves while the spout and handle are created as sets Bezier patches. Texture coordinates are assigned in the same way as for these primitives (i.e. *sipp\_bezier\_rotcurve()* and *sipp\_bezier\_patch()*.

- *Object \*sipp\_teapot\_body(resolution, surface, shader, texture)*

  *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  Create the body of the "Utah Teapot" as a separate object. See *sipp\_teapot()* for a more detailed description.

- *Object \*sipp\_teapot\_lid(resolution, surface, shader, texture)*

  *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  Create the lid of the "Utah Teapot" as a separate object. See *sipp\_teapot()* for a more detailed description.

- *Object \*sipp\_teapot\_handle(resolution, surface, shader, texture)*

  *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  Create the handle of the "Utah Teapot" as a separate object. See *sipp\_teapot()* for a more detailed description.

- *Object \*sipp\_teapot\_spout(resolution, surface, shader, texture)*

  *int     resolution;*\
   *void   \*surface;*\
   *Shader \*shader;*\
   *int     texture;*

  Create the spout of the "Utah Teapot" as a separate object. See *sipp\_teapot()* for a more detailed description.

## SEE ALSO

[sipp(3)](/sipp/3.md) - simple polygon processor, a 3d-graphics library\
 [sipp\_shaders(3)](/sipp_shaders/3.md) - a collection of shaders for SIPP.\
 [sipp\_geometric(3)](/sipp_geometric/3.md) - Vector and matrix functions for SIPP.\
 [sipp\_pixmap(3)](/sipp_pixmap/3.md) - pixmap handling code for SIPP.\
 sipp\_bitmap(3) - bitmap handling code for SIPP.

## AUTHORS

Jonas Yngvesson		(jonas-y@isy.liu.se)\
 Inge Wallin		(ingwa@isy.liu.se)

## BUGS

The format for the bezier patches and curves is prohibitively ugly.
