Next: , Previous: Physics, Up: Functions



12.9 Primitives

Primitives are cool...

Example
     

12.9.1 (build-cube)

Returns

primitiveid-number

Description

A simple cube, texture mapped placement per face images/cube.jpg

Example
      (define mynewcube (build-cube))
     

12.9.2 (build-polygins verts-number type-number)

Returns

primitiveid-number

Description

Builds a raw polygon primitive with size vertices (everything is initially set to zero). Type is a number that refers to the way the vertices are interpreted to build polygons, and can be one of the following: 0=TRISTRIP, 1=QUADS, 2=TRILIST, 3=TRIFAN, 4=POLYGON

Example
      (define mynewshape (build-polygons 100 0))
     

12.9.3 (build-sphere slices-number stacks-number)

Returns

primitiveid-number

Description

A sphere with the resolution specified, texture mapped in normal "world map" style. images/sphere.jpg

Example
      (define mynewshape (build-sphere 10 10))
     

12.9.4 (build-plane)

Returns

primitiveid-number

Description

A single quad plane, texture mapped from 0->1 in both dimensions. images/plane.jpg

Example
      (define mynewshape (build-plane))
     

12.9.5 (build-seg-plane vertsx-number vertsy-number)

Returns

primitiveid-number

Description

A tesselated poly plane, texture mapped from 0->1 in both dimensions.

Example
      (define mynewshape (build-plane))
     

12.9.6 (build-cylinder hsegments rsegments)

Returns

primitiveid-number

Description

A capped cylinder, texture map wrapped around, and badly wrapped around the ends. images/cylinder.jpg

Example
      (define mynewshape (build-cylinder 10 10))
     

12.9.7 (build-line numpoints-number)

Returns

primitiveid-number

Description

Builds a line consisting of numpoints points. The geometry is constantly camera facing and is texture mapped so the texture is stretched along the line from start to finish. You use the pdata functions to edit the postions and widths of the lines. If used lit, the normals are faked to approximate a circular cross section. Additionally, if solid rendering is cleared with (hint-none) and (hint-wire) is activated, a faster constant width line will be drawn - width specified by the (line-width) command. images/line.jpg

Example
      (define mynewshape (build-line 10))
     

12.9.8 (build-text text-string)

Returns

primitiveid-number

Description

Builds a sequence of planes, texture mapped so that a font texture can be used to display text. Might also be useful for more abstract things. The font assumed to be non proportional - there is an example font shipped with fluxus images/text.jpg Ok, so this isn't a very good font texture :)

Example
      (texture (texture-load "font.png"))
      (define mynewshape (build-text "hello"))
     

12.9.9 (build-nurbs-sphere hsegments rsegments)

Returns

primitiveid-number

Description

Builds a tesselated nurbs sphere, texture mapped in the same fashion as the poly sphere. images/nurbs-sphere.jpg

Example
      (define mynewshape (build-nurbs-sphere 10 10))
     

12.9.10 (build-nurbs-plane hsegments rsegments)

Returns

primitiveid-number

Description

Builds a tesselated nurbs plane, texture mapped in uv direction. images/nurbs-plane.jpg

Example
      (define mynewshape (build-nurbs-plane 10 10))
     

12.9.11 (build-particles count-number)

Returns

primitiveid-number

Description

Builds a particles primitive containing num points, all initially set to the origin. You use the pdata functions to edit the postions, colours and sizes. Particles come in two flavors, camera facing sprites, which are the default, can be textured and individually scaled; and points (when hint-points is set), which cannot be textured but are much faster to render, as they are hardware supported gl points. By default these point particles are square, turn on hint-anti-alias to make them circular. images/sprites.jpg

Example
      (define mynewshape (build-particles 100))
     

12.9.12 (build-locator)

Returns

primitiveid-number

Description

A locator is an empty primitive, useful for parenting to (when you don't want to have the parent object visible). This primitive can only be visualised with (hint-origin) to display it's local transform origin.

Example
      (define mynewshape (build-locator))
     

12.9.13 (build-pixels width-number height-number)

Returns

primitiveid-number

Description

Makes a new pixel primitive. A pixel primitive is used for making procedural textures, which can then be applied to other primitives. For this reason, pixel primitives probably wont be rendered much, but you can render them to preview the texture on a flat plane.

Example
      (define mynewshape (build-pixels 100 100))
     

12.9.14 (upload-pixels pixelprimitiveid-number)

Returns

void

Description

Uploads the texture data, you need to call this when you've finished writing to the pixelprim, and while it's grabbed.

Example
      (define mynewshape (build-pixels 100 100))
      (upload-pixels mynewshape)
     

12.9.15 (pixels->texture pixelprimitiveid-number)

Returns

textureid-number

Description

Returns a texture you can use exactly like a normal loaded one.

Example
      (define mynewshape (build-pixels 100 100))
      (upload-pixels mynewshape)
      (texture (pixels->texture mynewshape))
     

12.9.16 (build-blobby numinfluences subdivisionsvec boundingvec)

Returns

primitiveid-number

Description

Blobby primitives are a higher level implicit surface representation in fluxus which is defined using influences in 3 dimesional space. These infuences are then summed together, and a particular value is "meshed" (using the marching cubes algorithm) to form a smooth surface. The influences can be animated, and the smooth surface moves and deforms to adapt, giving the primitive it's blobby name. build-blobby returns a new blobby primitive. Numinfluences is the number of "blobs". Subdivisions allows you to control the resolution of the surface in each dimension, while boundingvec sets the bounding area of the primitive in local object space. The mesh will not be calculated outside of this area. Influence positions and colours need to be set using pdata-set.

Example
      (define mynewshape (build-blobby 7 (vector 30 30 30) (vector 3 3 3)))
     

12.9.17 (draw-instance primitiveid-number)

Returns

void

Description

Copies a retained mode primitive and draws it in the current state as an immediate mode primitive.

Example
      (define mynewshape (build-cube))
      (colour (vector 1 0 0))
      (draw-instance mynewshape) ; draws a copy of mynewshape
     

12.9.18 (draw-cube)

Returns

void

Description

Draws a cube in the current state in immediate mode primitive.

Example
      (define (render)
          (draw-cube))
      (every-frame (render))
     

12.9.19 (draw-plane)

Returns

void

Description

Draws a plane in the current state in immediate mode primitive.

Example
      (define (render)
          (draw-plane))
      (every-frame (render))
     

12.9.20 (draw-sphere)

Returns

void

Description

Draws a sphere in the current state in immediate mode primitive.

Example
      (define (render)
          (draw-sphere))
      (every-frame (render))
     

12.9.21 (draw-cylinder)

Returns

void

Description

Draws a cylinder in the current state in immediate mode primitive.

Example
      (define (render)
          (draw-cylinder))
      (every-frame (render))
     

12.9.22 (destroy primitiveid-number)

Returns

void

Description

Deletes a built primitive from the renderer. primitive.

Example
      (define mynewshape (build-sphere 10 10))
      (destroy mynewshape)