Attributes

In this guide we look at how the shape's surface will be rendered, in other words what it will look like.

All the methods used to modify the shape attributes have 2 forms

attribute_name(values)
attribute_name(values, parts)
  • attribute_name : there are 7 attributes we can control and these are shown below
  • values : one or more values separated by commas to apply for this attribute
  • parts : the shape parts this attribute is to be applied to. The value of this parameter is the part bit-flags ORed together, read the previous guide for more detail.

We can now look at each attribute in turn.

Draw mode

There are 3 draw modes, S3D.SOLID, S3D.WIRE and S3D.TEXTURE

Mode Effect
S3D.SOLID The surface will be rendered with a single color.
S3D.WIRE The surface will be rendered as a wire frame of the underlying mesh.
S3D.TEXTURE Use an image or movie to texture the surface

and these can be combined by ORing these flags together so

shape.drawMode(S3D.SOLID | S3D.WIRE);

will render the shape with solid color and a wire frame. This picture shows the most useful modes and combinations of modes.

image showing draw modes

Fill

This determines the surface color to use when the drawMode is SOLID e.g.

shape.fill(color(255,255,0));

will make the surfaces yellow. if the drawMode does not include SOLID the color will be remembered but have no visual effect until a suitable drawMode is used.

Stroke

This determines the wire color to use when the drawMode is WIRE e.g.

shape.stroke(color(0,0,255));

will make the wire frame blue. if the drawMode does not include WIRE the color will be remembered but have no visual effect until a suitable drawMode is used.

Stroke Weight

This determines the wire thickness to use when the drawMode is WIRE e.g.

shape.strokeWeight(1.5);

will make the thickness of the wire frame 1.5 (the default is 1.0). if the drawMode does not include WIRE the wire thickness will be remembered but have no visual effect until a suitable drawMode is used.

Texture

This is used to specify the image used to render the sahpe's surface. There are four methods to choose from

Shape3D texture(PApplet app, String filename)
Shape3D texture(PApplet app, String filename, int parts)
Shape3D texture(PImage texture)
Shape3D texture(PImage texture, int parts)
  • app : this is the PApplet object resonsible for drawing the shape. For single window sketches it will always have the value this
  • filename : the name of the image file to use as the texture
  • texture : an image that you have previously loaded
  • parts : the shape parts the textureis to be applied to. The value of this parameter is the part bit-flags ORed together, read the previous guide for more detail.

So the following statement will use an image file to texture the whole shape.

shape.texture(this, "my_image.jpg");

Movie

To use movies as textures you must install the Video library (authored by the Processing Foundation) through the Contribution Manager.

You must preload the movie you want to use before calling one of these methods

Shape3D movie(PApplet app, PImage movie)
Shape3D movie(PApplet app, PImage movie, int parts)

The method will only accept either a preloaded image.

  • app : this is the PApplet object used to preload the movie. For single window sketches it will always have the value this
  • movie : this is the movie that you have preloaded.
  • parts : the shape parts the textureis to be applied to. The value of this parameter is the part bit-flags ORed together, read the previous guide for more detail.

Shapes3D will start and play the movie for you, in other words there is no need for the user to read and display the next frame but the user has overall control for subsequent stops and starts of the movie.

Visible

This is the simplest of the attributes it simply makes the shape (or some parts of the shape) visible or invisible.

Shape3D visible(boolean visible)
Shape3D visible(boolean visible, int parts)