00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <vrj/Draw/OGL/Config.h>
00034
00035 #include <gmtl/Vec.h>
00036
00037 #include <vrj/Kernel/User.h>
00038 #include <vrj/Draw/OGL/GlDrawHeadFunctors.h>
00039
00040
00041 namespace vrj
00042 {
00043
00044 GlDrawEllipsoidHeadFunctor::GlDrawEllipsoidHeadFunctor()
00045 : mQuadObj(gluNewQuadric())
00046 {
00047 }
00048
00049 GlDrawEllipsoidHeadFunctor::~GlDrawEllipsoidHeadFunctor()
00050 {
00051 gluDeleteQuadric(mQuadObj);
00052 }
00053
00054 void GlDrawEllipsoidHeadFunctor::draw(vrj::User* user)
00055 {
00056
00057 const float head_height(0.254f);
00058 const float head_width_scale(0.7f);
00059 const float head_depth_scale(0.8f);
00060
00061
00062 const float interocular(user->getInterocularDistance());
00063 const float eye_radius(0.0254f * 0.5f);
00064
00065 glPushMatrix();
00066
00067
00068
00069
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
00076 glScalef(head_width_scale, 1.0f, head_depth_scale);
00077
00078
00079 glColor4f(0.5f, 0.75f, 0.90f, 0.67f);
00080 drawSphere(head_height/2.0f, 10, 10);
00081
00082 glPopMatrix();
00083
00084
00085 glPushMatrix();
00086 glColor3f(0.8f, 0.4f, 0.2f);
00087
00088 glPushMatrix();
00089 glTranslatef((interocular/2.0f), 0.0f, 0.0f);
00090 drawSphere(eye_radius, 5, 5);
00091 glPopMatrix();
00092 glPushMatrix();
00093 glTranslatef(-(interocular/2.0f), 0.0f, 0.0f);
00094 drawSphere(eye_radius, 5, 5);
00095 glPopMatrix();
00096 glPopMatrix();
00097 }
00098
00099 void GlDrawEllipsoidHeadFunctor::drawSphere(const float radius,
00100 const int slices, const int stacks)
00101 {
00102 gluQuadricDrawStyle(mQuadObj, (GLenum) GLU_FILL);
00103 gluQuadricNormals(mQuadObj, (GLenum) GLU_SMOOTH);
00104 gluSphere(mQuadObj, radius, slices, stacks);
00105 }
00106
00107 }