Graphics Reference
In-Depth Information
Approach. To introduce the PrimitiveList class, a Primitive subclass
that has a collection of Primitive references; examine how to work with
this class.
Figure 7.12 is a screenshot of running Tutorial 7.4. This tutorial extends Tuto-
rial 7.3 by supporting the creation of any number of point, line, and circle primi-
tives with motion and by supporting the collision between these primitives.
Figure 7.12.
Tutorial
7.4.
UWBGL_D3D_Lib7
Change summary. See p. 517
for a summary of changes to
the library.
When we examine the supporting library for this tutorial, we see that only two
files are added to the Common Files/Primitives subfolder: uwbgl _ Primitive
List.h/cpp . These two files implement the UWB _ PrimitiveList class. List-
ing 7.21 shows that UWB _ PrimitiveList is a subclass of the Primitive class.
At label D, we notice that this class has an array of references to Primitive .
With the corresponding interface methods at label B, this class can behave just
like a linked list of Primitive pointers. The functions defined at label A ensure
the update of all primitives in the list when appropriate and proper support of col-
lision functionality. The overrides at label C ensure that all primitives in this list
can be drawn when the Primitive::Draw() function is called.
class UWB _ PrimitiveList : public UWB _ Primitive {
A:
virtual void Update( float elapsed _ seconds);
virtual const UWB _ BoundingVolume * GetBoundingVolume( eLevelOfDetail lod ) const ;
void DrawChildBoundingVolumes(... UWB _ DrawHelper * , UWB _ Color color) const ;
B:
int Count() const ;
UWB _ Primitive * PrimitiveAt( int index);
Source file.
uwbgl _ PrimitiveList1.h
file in the Common Files/
Primitives
void Append(UWB _ Primitive * pPrimitive);
void DeletePrimitiveAt( int index);
protected :
.
subfolder
of
the
UWBGL _ D3D _ Lib7 project.
virtual void DrawPrimitive( eLevelOfDetail lod, UWB _ DrawHelper& draw _ helper ) const ;
virtual void SetupDrawAttributes(UWB _ DrawHelper& draw _ helper) const ;
C:
UWB _ PointerArray<UWB _ Primitive * >m _ list;
UWB _ BoundingBox m _ bounds;
D:
// union of all primitive bounds
};
Listing 7.21. The UWB _ PrimitiveList class (Tutorial 7.4).
 
Search WWH ::




Custom Search