A Shape is a geometrical mesh consisting of vertices that are rendered using a single Shader. It specifies several types of properties:
- Coordinate positioning, mapping this shape's vertex coordinates to those of its parent. 'view' describes the technique to use and establishes the properties required to calculate the transformation, such as 'location' position, 'lookat' or 'rotation' orientation, and 'scale' factor.
- Rendering instructions. Most are set by the .render? method, especially the shader to use and the values for the uniform values it requires. 'draw' indicates what sort of geometry to draw.
- Vertices data. These names of these properties are determined by the shader. Common vertex properties are: 'positions', 'normals' and 'uvs'. A shape can make use of vertex data from another shape using the 'shape' property.
- Boundary shape that encloses all vertices, used for culling and collision detection.
For example:
+Shape render?: [] shader: @'selflit.acn' draw: 'Polygon' positions: +Xyzs" 0.0, 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, -1.0, -1.0, -1.0, 0.0, -3.0" colors: +Colors" 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0"
To reuse a shape, subtype it.
Methods
- New
- Create a new Shape
Instance Properties (see Region)
A shape must specify all vertex attribute properties required by the rendering shader and may also specify its required uniform properties. See Shader for more details.
- boundary
- TBD - the bounding box, sphere or cylinder for clipping and other purposes
- colors
- A Colors collection holding the r,g,b,a values of the shape's vertices.
- draw
- A symbol specifying the graphical primitive to use when rendering the vertices.
If not specified, the default is 'Triangles'.
- Points
- Individual points
- Lines
- Line segments from vertex pairs
- LineStrip
- Series of connected line segments
- LineLoop
- Series of connected line segments, plus one connecting last vertex to first
- Triangles
- Triangles from vertex triples
- TriangleStrip
- Connected triangles: 0,1,2 2,1,3 2,3,4 ...
- TriangleFan
- Connected triangles: 0,1,2 0,2,3 0,3,4 ...
- LinesAdjacency
- Adjacent line segments for a Geometry Shader
- LineStripAdjacency
- Adjacent line strips for a Geometry Shader
- TrianglesAdjacency
- Adjacent triangles for a Geometry Shader
- TriangleStripAdjacency
- Adjacent triangle strips for a Geometry Shader
- Patches
- Vertices used in a Tessalation Shader
- indices
- Integers that hold index values indicating the order to draw the vertices using the 'draw' primitive. Each index value maps to a vertex whose attributes are stored at that position in the vertex properties. This is economical when the shape's vertices are used by multiple faces. If not specified, the vertices are drawn in the order specified in the vertex properties.
- normals
- An Xyzs collection holding the x,y,z normals for the shape's vertices.
- orientation
- A Quat specifying the rotation used to orient the shape in its parent's coordinate system. If not specified, no rotation takes place.
- origin
- The location of this shape's 0,0,0 position in the shape's parent's coordinate system. This can be used to specify where to render this shape within its parent group's space. If not specified, +Xyz(0,0,0) is assumed.
- positions
- An Xyzs collection holding the x,y,z positions of the shape's vertices.
- render?
- The method that is performed before rendering the shape. The method should return 'false' if the shape is not to be rendered. This method will have the render context as 'self', enabling the shape to make use of shared uniforms (minimize use of '+' new here).
- scale
- An Xyz vector specifying how much to re-size the shape's vertices when rendering in the parent group, The default is no scaling: +Xyz(1.,1.,1.)
- shader
- The shader used when rendering this shape.
- transparent
- If true, the shape uses translucent colors (their alpha is less than 1). Specifying this is necessary to proper rendering.
- uvs
- A Uvs collection holding the u,v texture coordinates for the shape's vertices.