Graphics Reference
In-Depth Information
C: void SetCenter( float x, float y, float z=0.0f);
vec3 GetCenter() const ;
.
protected :
D: void DrawPrimitive( eLevelOfDetail lod, UWB _ DrawHelper& draw _ helper ) const ;
void SetupDrawAttributes(UWB _ DrawHelper& draw _ helper) const ;
E: vec3 m _ center; float m _ radius;
// the end points on the line
};
Source files.
uwbgl _ PrimitiveCircle1.h
/.cpp files in the Common
Files/Primitives subfolder of
the UWBGL _ D3D _ Lib5 project.
void UWB _ PrimitiveCircle::Update( float elapsed _ seconds)
vec3 adjust _ vec = m _ velocity * elapsed _ seconds;
m _ center += adjust _ vec;
A1:
void UWB _ PrimitiveCircle::MouseDownVertex( int vertexID, float x, float y)
if (0 == vertexID) // SetCenter(x,y); SetRadius(0);
else // compute radius from (x,y) to center and call SetRadius()
void UWB _ PrimitiveCircle::MoveTo( float x, float y) { SetCenter(x,y); }
.
B1:
Listing 7.12. (cont.)
The CModel class. To support the primitive-editing functionality, we understand
that the application state must support instances of the point, line, and circle primi-
tives. However, unlike in Tutorial 7.1 where we worked with three distinct objects
and therefore had to be constantly aware of which primitive was currently active,
in this case, with the support of the Primitive hierarchy, all primitives have iden-
tical public methods, and the application only need to work with the interface of
the Primitive class. Listing 7.13 shows the details of the CModel class. Let's
first examine the private representation at label F. Besides the peripheral support
information of world size, stopwatch, and draw helper, we see three instances of
concrete Primitives (point, line, and circle) and the m _ pCurrentObject pointer
to the virtual Primitive class. The CModel class interacts with the controller via
this pointer exclusively, enforcing a uniform implementation for the editing of
all primitives. At labels A and A1, we see that CModel allows the setting of the
currently active primitive (by pointing the m _ pCurrentObject pointer to the cor-
responding object). After setting the currently active primitive, labels B and B1
show that the implementation of the set/get attribute functions are simply mapped
to calling the corresponding primitive functions. Label C shows the declaration of
functions for editing the geometric information of the primitives. At label C1, we
Search WWH ::




Custom Search