3D Graphics Programming with QuickDraw 3D
TQ3GroupObject
class. As you've seen, the TQ3GroupObject
class is a subclass of the TQ3ShapeObject
, which is itself a subclass of the TQ3SharedObject
class. As a result, a group object is associated with a reference count, which is incremented or decremented whenever you create or dispose of an instance of that group.The objects you put into in a group are not copied into the group. Instead, references to the objects are maintained in the group. Accordingly, you can include in a group only shared objects (that is, the types of objects that have reference counts). A group can contain other groups, because groups are shared objects. QuickDraw3D provides functions that you can use to add objects to a group or remove objects from a group. It also provides functions that you can use to access objects by their position in the group.
kQ3ShapeTypeGroup
, a type of shape object. You can create a group of that type (by calling the Q3Group_New
function) and you can put any kinds of shared objects into it (for example, by calling the Q3Group_AddObject
function). In addition, QuickDraw3D provides three subclasses of groups: light groups, display groups, and information groups. These subclasses are distinguished from one another by the kinds of objects you can put into them.
Q3View_SetLightGroup
function. See the chapter "View Objects" for complete details on attaching light groups to views.
1. transforms
2. styles
3. attribute sets
4. shaders
5. geometric objects
6. groups
7. unknown objects
kQ3SharedTypeUnknown
.
TQ3GroupPosition
data type.
typedef struct TQ3GroupPositionPrivate *TQ3GroupPosition;You receive a group position for an object when you first insert the object into the group (for example, by calling
Q3Group_AddObject
). In general, however, you don't need to maintain that information, because you can use QuickDraw3D routines to walk through a group. For instance, you can get Q3Group_GetFirstPosition
. Then you can retrieve the positions of all subsequent objects in the group by calling Q3Group_GetNextPosition
.
An object's group position is valid only as long as that object is in the group. When you remove an object from a group, the corresponding group position becomes invalid. Similarly, when you remove all objects from a group (for example, by calling Q3Group_EmptyObjects
), the group positions of those objects become invalid.<8bat>s
See "Accessing Objects by Position," beginning on page 10-8 for sample code that illustrates how to traverse a group using group positions.
typedef enum TQ3DisplayGroupStateMasks { kQ3DisplayGroupStateNone = 0, kQ3DisplayGroupStateMaskIsDrawn = 1 << 0, kQ3DisplayGroupStateMaskIsInline = 1 << 1, kQ3DisplayGroupStateMaskUseBoundingBox = 1 << 2, kQ3DisplayGroupStateMaskUseBoundingSphere = 1 << 3, kQ3DisplayGroupStateMaskIsPicked = 1 << 4, kQ3DisplayGroupStateMaskIsWritten = 1 << 5 } TQ3DisplayGroupStateMasks;A group state value contains a flag, called the drawable flag, that determines whether the group is to be drawn when it is passed to a view for rendering or picking. By default, the drawable flag of a group state value is set, indicating that the group is to be drawn to a view. If the drawable flag is clear, the group is not traversed when it is encountered in a hierarchical model. This allows you to place "invisible" objects in a model that assist you in bounding complex geometric objects, for example.
An ordered display group can be constructed in such a way that the group has a hierarchical structure. This allows properties (such as attributes, styles, and transforms) to be inherited by child nodes from their parent nodes in the hierarchy. Occasionally, however, you might want to override this inheritance and allow a group contained in a hierarchical model to define its own graphics state independently of any other objects or groups in the model. To allow this feature, a group state value contains an inline flag that specifies whether or not the group should be executed inline. A group is executed inline if it does not push and pop the graphics state stack before and after it is executed (that is, if it is simply executed as a bundle of objects). By default, the inline flag of a group is not set, indicating that the group pushes and pops its graphics state.
For more information on pushing and popping the graphics state, see the descriptions of the functions Q3Push_Submit
and Q3Pop_Submit
in the chapter "View Objects."<8bat>u
A group state value contains a picking flag that determines whether the group can be picked. In general, you'll want all groups in a model to be eligible for picking. In some cases, however, you can clear the picking flag of a group's group state value in order to establish the group as a decoration in the model that cannot be picked.
Let us know what you think of these prototype pages.
Generated with Harlequin WebMaker