Legacy Parameter Storage
From K-3D
Note: this information is obsoleted by Array Based Mesh Design, which should be used for all new code.
How are normals stored in K-3D? How do I associate a custom data with geometric objects?
The tag mechanism is flexible and available for whatever use you want it for; there are a few predefined keys which we adopt from RenderMan by reference; you're welcome to assign any others that you like (e.g. you could assign a temperature tag to all your geometry, and create a RenderMan shader that colors it based on the temperature). If you want to specify geometric normals and have them used in the obvious way by a RenderMan render engine, use N for the key and use k3d::ri::normal for the type. You can specify it per-vertex, per-face, per-edge (facevarying data), or per-polyhedron as you like. The only limitation that applies (and again, this is only if you're intending to generate RenderMan output) is that if you specify e.g. an N tag for one face in a polyhedron, you must specify N for all faces.
Having said all this, you really shouldn't need to specify normals - if you're wanting to create smooth curved surfaces, we have a wide variety of primitives up-to-and-including NURBS that do a much better job, and are more efficient anyway.
Note: you should be using the k3d::normal(k3d::face&) function to generate normals, it handles zero-length edges and two points/vertices at the same coordinate in space.
Note 2: RenderMan allows a modeler to assign arbitrary data parameters to geometry at different levels - vertex, varying, uniform, and constant. Data can be of any type, e.g. float, string, vertex, normal, matrix, etc., with or without arrays, and is assigned an arbitrary string name. Per-vertex color and opacity would be just one use of this powerful capability (we currently use it to assign normal vectors to geometry for simulating smooth-shading with polygons).
The current set of tags whose meanings are predefined by RenderMan include:
- N - Geometric normal vectors. Typically only necessary if you wish to simulate a curved surface with polygons (but using curved primitives is preferred).
- Cs - Surface color. This is how you would assign per-vertex color to geometry.
- Os - Surface opacity. This is how you would assign per-vertex opacity to geometry.
- s & t - Texture coordinates. These are already well-defined for most primitives; they're typically only necessary for texturing polygons.
- Pref - Commonly used for reference geometry that allows a solid surface shader to stick to geometry that is being deformed.

