3D Graphics Programming with QuickDraw 3D
An attribute is defined as an attribute type and some associated data. You apply an attribute to an object by creating an instance of a specific attribute type, defining its data, and then attaching it to the object. QuickDraw3D defines many types of attributes, including diffuse color, specular color, transparency color, surface normals, and surface tangents.
In general, however, attributes are not applied to objects individually. Instead, you usually create an attribute set, which is a collection of zero or more different attribute types and their associated data. For example, to create a transparent red triangle, you create an attribute set, add both color and transparency attributes to it, and then attach the attribute set to the triangle. An attribute set is of type TQ3AttributeSet
, a type of TQ3SetObject
.
The basic attributes types are defined by constants. See "Attribute Types" on page 5-14 for a complete description of these attribute types.
typedef enum TQ3AttributeTypes { kQ3AttributeTypeNone = 0, kQ3AttributeTypeSurfaceUV = 1, kQ3AttributeTypeShadingUV = 2, kQ3AttributeTypeNormal = 3, kQ3AttributeTypeAmbientCoefficient = 4, kQ3AttributeTypeDiffuseColor = 5, kQ3AttributeTypeSpecularColor = 6, kQ3AttributeTypeSpecularControl = 7, kQ3AttributeTypeTransparencyColor = 8, kQ3AttributeTypeSurfaceTangent = 9, kQ3AttributeTypeHighlightState = 10, kQ3AttributeTypeSurfaceShader = 11 } TQ3AttributeTypes;You can attach a set of attributes to a view, to a group of objects, to a single geometric object, to a face of an object, or to a vertex of an object. In addition, you can attach edge and corner attributes to meshes. For each of these levels, QuickDraw3D defines a set of natural attributes. For example, the surface normal attribute (which defines the normal vector at a point) makes no sense when applied to a view or a nonpolygonal geometric object. It does, however, make sense to include the surface normal attribute in a set of face or vertex attributes. Accordingly, the surface normal attribute is contained in the natural sets of attributes for faces and vertices, but not for views, groups, or nonpolygonal geometric objects. Table 5-1 lists the natural attributes that can be assigned to objects in the QuickDraw3D object hierarchy.
You can, if you wish, include in the attribute set of any kind of object attributes that are not natural to that object. For instance, you can put a surface normal attribute into an attribute set attached to a view. You can then access that unnatural attribute in precisely the same way you access any other attribute in the set. The only difference between natural and unnatural attributes is that unnatural attributes in an attribute set are not inherited by objects lower down in the class hierarchy. See "Attribute Inheritance" on page 5-6 for details.<8bat>s
Surface normals assigned to faces are ignored by renderers, as are the surface normals that are computed geometrically from the points that make up the face.<8bat>u
Attribute inheritance always occurs in this order:
1. view
2. group
3. geometric object
4. face
5. mesh edge
6. vertex
7. mesh corner
In other words, view attributes are always inherited by all groups of objects in the model, unless a group contains overriding attributes. Similarly, any attributes assigned to a geometric object are inherited by all faces of the object, unless a face contains overriding attributes.
This attribute inheritance applies only to the natural attributes contained in any attribute set. If, for example, an attribute set of a view contains a surface normal attribute (which is not a natural attribute for view attribute sets), that attribute is not inherited by any objects lower down in the hierarchy.
If you define a custom attribute, you can specify whether you want that attribute to be inherited along the attribute inheritance path by including an attribute inheritance method in your attribute metahandler. See "Defining Custom Attribute Types" on page 5-9 for a sample attribute metahandler that specifies that the temperature attribute is to be inherited. If you do not supply an attribute inheritance method, QuickDraw3D assumes you want no such inheritance for your custom attribute.
Let us know what you think of these prototype pages.
Generated with Harlequin WebMaker