vrj::GlDrawEllipsoidHeadFunctor Class Reference

Draw a basic ellipsoid head. More...

#include <vrj/Draw/OGL/GlDrawHeadFunctors.h>

Inheritance diagram for vrj::GlDrawEllipsoidHeadFunctor:

Inheritance graph
[legend]
Collaboration diagram for vrj::GlDrawEllipsoidHeadFunctor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GlDrawEllipsoidHeadFunctor ()
virtual ~GlDrawEllipsoidHeadFunctor ()
virtual void contextInit ()
 Called to initialize any context-specific information.
virtual void draw (vrj::User *user)
 Callback function for drawing.

Protected Member Functions

void drawSphere (const float radius, const int slices, const int stacks)

Protected Attributes

GLUquadricObj * mQuadObj

Detailed Description

Draw a basic ellipsoid head.

Definition at line 56 of file GlDrawHeadFunctors.h.


Constructor & Destructor Documentation

vrj::GlDrawEllipsoidHeadFunctor::GlDrawEllipsoidHeadFunctor (  ) 

Definition at line 44 of file GlDrawHeadFunctors.cpp.

00045    : mQuadObj(gluNewQuadric())
00046 {
00047 }

vrj::GlDrawEllipsoidHeadFunctor::~GlDrawEllipsoidHeadFunctor (  )  [virtual]

Definition at line 49 of file GlDrawHeadFunctors.cpp.

References mQuadObj.

00050 {
00051    gluDeleteQuadric(mQuadObj);
00052 }


Member Function Documentation

virtual void vrj::GlDrawEllipsoidHeadFunctor::contextInit (  )  [inline, virtual]

Called to initialize any context-specific information.

Implements vrj::GlDrawObjectFunctor.

Definition at line 64 of file GlDrawHeadFunctors.h.

00065    {;}

void vrj::GlDrawEllipsoidHeadFunctor::draw ( vrj::User user  )  [virtual]

Callback function for drawing.

Called when the object should be drawn.

Precondition:
GL context is set and ready to go.

Implements vrj::GlDrawObjectFunctor.

Definition at line 54 of file GlDrawHeadFunctors.cpp.

References drawSphere(), and vrj::User::getInterocularDistance().

00055 {
00056    // All units are in meters.
00057    const float head_height(0.254f);      // 10 inches
00058    const float head_width_scale(0.7f);
00059    const float head_depth_scale(0.8f);
00060    //const float eye_vertical(0.067f);
00061    //const float eye_horizontal(0.21f);
00062    const float interocular(user->getInterocularDistance());
00063    const float eye_radius(0.0254f * 0.5f);      // 0.5 in
00064 
00065    glPushMatrix();
00066       // Head pos is the center of the eyes, so we need to move the head offset
00067       // a bit to get it positioned correctly.  We will do this by measuring
00068       // the distance from center of head to forehead and then translate by
00069       // the negative of that.
00070       gmtl::Vec3f forehead_offset(0.0f, head_height*0.17f,
00071                                   -(head_depth_scale*head_height)*0.45f);
00072       glTranslatef(-forehead_offset[0], -forehead_offset[1],
00073                    -forehead_offset[2]);
00074 
00075       // Scale to get an ellipsoid head.
00076       glScalef(head_width_scale, 1.0f, head_depth_scale);
00077       //glEnable(GL_BLEND);
00078       //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00079       glColor4f(0.5f, 0.75f, 0.90f, 0.67f);
00080       drawSphere(head_height/2.0f, 10, 10);             // Head
00081       //glDisable(GL_BLEND);
00082    glPopMatrix();
00083 
00084    // --- Draw the eyes --- //
00085    glPushMatrix();
00086       glColor3f(0.8f, 0.4f, 0.2f);
00087       //glTranslatef(0.0f, eye_vertical, -eye_horizontal);
00088       glPushMatrix();                     // Right eye
00089          glTranslatef((interocular/2.0f), 0.0f, 0.0f);
00090          drawSphere(eye_radius, 5, 5);
00091       glPopMatrix();
00092       glPushMatrix();                     // Left eye
00093          glTranslatef(-(interocular/2.0f), 0.0f, 0.0f);
00094          drawSphere(eye_radius, 5, 5);
00095       glPopMatrix();
00096    glPopMatrix();
00097 }

void vrj::GlDrawEllipsoidHeadFunctor::drawSphere ( const float  radius,
const int  slices,
const int  stacks 
) [protected]

Definition at line 99 of file GlDrawHeadFunctors.cpp.

References mQuadObj.

Referenced by draw().

00101 {
00102   gluQuadricDrawStyle(mQuadObj, (GLenum) GLU_FILL);
00103   gluQuadricNormals(mQuadObj, (GLenum) GLU_SMOOTH);
00104   gluSphere(mQuadObj, radius, slices, stacks);
00105 }


Member Data Documentation

GLUquadricObj* vrj::GlDrawEllipsoidHeadFunctor::mQuadObj [protected]

Definition at line 76 of file GlDrawHeadFunctors.h.

Referenced by drawSphere(), and ~GlDrawEllipsoidHeadFunctor().


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:58:13 2007 for VR Juggler by  doxygen 1.5.1