Rendering textures

Texture coordinates

The texture coordinates determine which part of the image or movie is used for the texture. Shapes3D uses normalised coordinates [u,v] where

Coordinate Value Corresponds to -
      u 0.0 left edge of the image or movie
1.0 right edge of the image or movie
      v 0.0 top edge of the image or movie
1.0 bottom edge of the image or movie
normalised texture coordinates

by default the texture coordinates are [0,0]-[1,1] in other words the entire image. There are no restrictions on the texture coordinate values so you use part of image, multiple copies (tiled) or even flip the image. Changing the coordinates between frames even allows for simple texture animations.

This picture is of a textured rectangle showing the normailsed uv coordinates. The size of the rectangle has been chosen to maintaing the aspect ratio of the image used.

The are two methods to choose from depending it is being applied to all the shape parts or just some

Shape3D uv(float u0, float u1, float v0, float v1)
Shape3D uv(float u0, float u1, float v0, float v1, int parts)

Some examples

uv(parameters) Visual result
0, 2, 0, 2 normalised texture coordinates
0.5, 1.5, 0, 1 normalised texture coordinates
0, 1, 1, 0 normalised texture coordinates
0.21, 0.63, 0.08, 0.49 normalised texture coordinates

Adjusting texture coordinates

There will be times when the user will want to either rotate or flip the texture, although you could modify the original image this is not practical with movies. The solution is to re-orient the uv cordinate coordinates. Shapes3D provides 2 methods to change the texture orientation.

Shape3D uvt(TransformUV transformer)
Shape3D uvt(uvt(TransformUV transformer, int parts)

Where the parameter transformer can be one of six values.

transformer Corresponds to -
S3D.ROT0 use original UV coordinates as calculated by Shapes3D
S3D.ROT90 rotate the UV coordinates by 90°
S3D.ROT180 rotate the UV coordinates by 180°
S3D.ROT270 rotate the UV coordinates by 270°
S3D.FLIPH mirror the UV coordinates alomg horizontal direction
S3D.FLIPV mirror the UV coordinates alomg vertical direction

Texture Wrapping

The user can specify how the texture should wrap the shape. Shapes3D provides two methods to set this attribute.

Shape3D uvwrap(int wrap)
Shape3D uvwrap(uvt(int wrap,  int parts)

Where the parameter can be one of two value.

wrap Visual result
REPEAT
default value
texture wrap = REPEAT
CLAMP
default value
texture wrap = REPEAT

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)