vrj::GlBasicSimulator Class Reference

Interface for objects that wish to perform simulator function with an OpenGL application. More...

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

Inheritance diagram for vrj::GlBasicSimulator:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GlBasicSimulator ()
virtual ~GlBasicSimulator ()
virtual bool config (jccl::ConfigElementPtr element)
 Configures the basic OpenGL simulator.
virtual void draw (const float scaleFactor)
 Draws this sim device using the given information about the Window it will be drawing into.
virtual void initialize (SimViewport *simVp)
virtual void setKeyboardMouse (gadget::KeyboardMouseInterface kmInterface)
 Sets the keyboard/mouse device the simulator can use to get input from the user.
const gmtl::Matrix44f & getCameraPos ()
const gmtl::Matrix44f & getHeadPos ()
const gmtl::Matrix44f & getWandPos ()
virtual void updateProjectionData (const float positionScale, Projection *leftProj, Projection *rightProj)
 Called as part of the viewports updateProjection call.
void updateInternalData (float positionScale)
 Update internal simulator data.
bool shouldDrawProjections ()
gmtl::Vec3f getSurfaceColor ()

Static Public Member Functions

static std::string getElementType ()

Protected Member Functions

void drawObjects ()
 Draws any objects that the manager needs to display i.e.
void drawProjections (bool drawFrustum, gmtl::Vec3f surfColor, const float scaleFactor)
 Draw the projections.
void drawSimulator (const float scaleFactor)
 Draws a simulator using OpenGL commands.
void setDrawWandFunctor (GlDrawObjectFunctor *functor)
 Sets the functor used to render the wand.
void setDrawHeadFunctor (GlDrawObjectFunctor *functor)
 Sets the functor used to render the head.
void initQuadObj ()
void drawLine (gmtl::Vec3f &start, gmtl::Vec3f &end)
void drawCone (float base, float height, int slices, int stacks)
void drawBox (float size, GLenum type)
void drawWireCube (float size)
void drawSolidCube (float size)

Protected Attributes

GlDrawObjectFunctormDrawWandFunctor
 The functor to draw the wand.
GlDrawObjectFunctormDrawHeadFunctor
 The functor to draw the head.
GLUquadricObj * mQuadObj
 Quadric for drawing stuff.
SimViewportmSimViewport
bool mDrawProjections
 Should we draw projections.
gmtl::Vec3f mSurfaceColor
 Color to draw surfaces.
gadget::PositionInterface mCamera
 Proxy interfaces to devices needed.
gadget::PositionInterface mWand
gmtl::Matrix44f mCameraPos
 The data about the position of all this stuff.
gmtl::Matrix44f mHeadPos
gmtl::Matrix44f mWandPos

Detailed Description

Interface for objects that wish to perform simulator function with an OpenGL application.

Definition at line 63 of file GlBasicSimulator.h.


Constructor & Destructor Documentation

vrj::GlBasicSimulator::GlBasicSimulator (  ) 

Definition at line 69 of file GlBasicSimulator.cpp.

References setDrawHeadFunctor(), and setDrawWandFunctor().

00070    : mQuadObj(gluNewQuadric())
00071 {
00072    setDrawWandFunctor(new GlDrawRightAngleWandFunctor());
00073    setDrawHeadFunctor(new GlDrawEllipsoidHeadFunctor());
00074 }

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

Definition at line 76 of file GlBasicSimulator.cpp.

References mDrawHeadFunctor, mDrawWandFunctor, and mQuadObj.

00077 {
00078    gluDeleteQuadric(mQuadObj);
00079 
00080    if ( NULL != mDrawWandFunctor )
00081    {
00082       delete mDrawWandFunctor;
00083       mDrawWandFunctor = NULL;
00084    }
00085 
00086    if ( NULL != mDrawHeadFunctor )
00087    {
00088       delete mDrawHeadFunctor;
00089       mDrawHeadFunctor = NULL;
00090    }
00091 }


Member Function Documentation

bool vrj::GlBasicSimulator::config ( jccl::ConfigElementPtr  element  )  [virtual]

Configures the basic OpenGL simulator.

Precondition:
element is a valid configuration element.
Postcondition:
It should be configured.

Implements vrj::DrawSimInterface.

Definition at line 98 of file GlBasicSimulator.cpp.

References mCamera, mDrawProjections, mSurfaceColor, and mWand.

00099 {
00100    vprASSERT(element.get() != NULL);
00101    vprASSERT(element->getID() == std::string("default_simulator"));
00102 
00103    std::string camera_proxy_str = element->getProperty<std::string>("camera_pos");
00104    std::string wand_proxy_str = element->getProperty<std::string>("wand_pos");
00105 
00106    mCamera.init(camera_proxy_str);
00107    mWand.init(wand_proxy_str);      // Configure the wand to use
00108 
00109    if(!mCamera.isConnected())
00110    {
00111       vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
00112          << clrOutNORM(clrRED,"ERROR:")
00113          << "GlBasicSimulator:: Fatal Error: Camera not found named: "
00114          << camera_proxy_str.c_str() << vprDEBUG_FLUSH;
00115       vprASSERT(false);
00116    }
00117 
00118    // Get drawing parameters
00119    mDrawProjections = element->getProperty<bool>("draw_projections");
00120    mSurfaceColor[0] = element->getProperty<float>("surface_color", 0);
00121    mSurfaceColor[1] = element->getProperty<float>("surface_color", 1);
00122    mSurfaceColor[2] = element->getProperty<float>("surface_color", 2);
00123 
00124    return true;
00125 }

static std::string vrj::GlBasicSimulator::getElementType (  )  [inline, static]

Definition at line 78 of file GlBasicSimulator.h.

00079    {
00080       return std::string("default_simulator");
00081    }

void vrj::GlBasicSimulator::draw ( const float  scaleFactor  )  [virtual]

Draws this sim device using the given information about the Window it will be drawing into.

Implements vrj::GlSimInterface.

Definition at line 131 of file GlBasicSimulator.cpp.

References drawSimulator().

00132 {
00133    drawSimulator(scaleFactor);
00134 }

virtual void vrj::GlBasicSimulator::initialize ( SimViewport simVp  )  [inline, virtual]

Implements vrj::DrawSimInterface.

Definition at line 89 of file GlBasicSimulator.h.

References mSimViewport.

00090    {
00091       mSimViewport = simVp;
00092    }

void vrj::GlBasicSimulator::setKeyboardMouse ( gadget::KeyboardMouseInterface  kmInterface  )  [virtual]

Sets the keyboard/mouse device the simulator can use to get input from the user.

Implements vrj::GlSimInterface.

Definition at line 141 of file GlBasicSimulator.cpp.

00142 {
00143    boost::ignore_unused_variable_warning(kmInterface);
00144 }

const gmtl::Matrix44f& vrj::GlBasicSimulator::getCameraPos (  )  [inline]

Definition at line 101 of file GlBasicSimulator.h.

References mCameraPos.

Referenced by updateProjectionData().

00102    {
00103       return mCameraPos;
00104    }

const gmtl::Matrix44f& vrj::GlBasicSimulator::getHeadPos (  )  [inline]

Definition at line 106 of file GlBasicSimulator.h.

References mHeadPos.

Referenced by drawSimulator().

00107    {
00108       return mHeadPos;
00109    }

const gmtl::Matrix44f& vrj::GlBasicSimulator::getWandPos (  )  [inline]

Definition at line 111 of file GlBasicSimulator.h.

References mWandPos.

Referenced by drawSimulator().

00112    {
00113       return mWandPos;
00114    }

void vrj::GlBasicSimulator::updateProjectionData ( const float  positionScale,
Projection leftProj,
Projection rightProj 
) [virtual]

Called as part of the viewports updateProjection call.

Reimplemented from vrj::DrawSimInterface.

Definition at line 147 of file GlBasicSimulator.cpp.

References vrj::Projection::calcViewMatrix(), getCameraPos(), vrj::User::getInterocularDistance(), vrj::Viewport::getUser(), mSimViewport, and updateInternalData().

00150 {
00151    updateInternalData(positionScale);
00152 
00153    gmtl::Matrix44f camera_pos = getCameraPos();
00154    gmtl::Vec3f camera_trans = gmtl::makeTrans<gmtl::Vec3f>(camera_pos);
00155 
00156    //mCameraProj->calcViewMatrix(camera_pos);
00157 
00158    gmtl::Matrix44f left_eye_pos, right_eye_pos;     // NOTE: Eye coord system is -z forward, x-right, y-up
00159 
00160    // -- Calculate camera (eye) Positions -- //
00161    vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL)
00162       << "[vrj::GlBasicSimulator::updateProjectionData()] Getting cam position"
00163       << std::endl << vprDEBUG_FLUSH;
00164    vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL) << "CamPos:" << camera_trans
00165                                         << std::endl << vprDEBUG_FLUSH;
00166 
00167    // Compute location of left and right eyes
00168    float interocular_dist = mSimViewport->getUser()->getInterocularDistance();
00169    interocular_dist *= positionScale;               // Scale into correct units
00170    float eye_offset = interocular_dist / 2.0f;      // Distance to move eye
00171 
00172    left_eye_pos = camera_pos * gmtl::makeTrans<gmtl::Matrix44f>( gmtl::Vec3f(-eye_offset, 0.0f, 0.0f) );
00173    right_eye_pos = camera_pos * gmtl::makeTrans<gmtl::Matrix44f>( gmtl::Vec3f(eye_offset, 0.0f, 0.0f) );
00174 
00175    leftProj->calcViewMatrix(left_eye_pos, positionScale);
00176    rightProj->calcViewMatrix(right_eye_pos, positionScale);
00177 }

void vrj::GlBasicSimulator::updateInternalData ( float  positionScale  ) 

Update internal simulator data.

Definition at line 180 of file GlBasicSimulator.cpp.

References vrj::User::getHeadPosProxy(), vrj::Viewport::getUser(), mCamera, mCameraPos, mHeadPos, mSimViewport, mWand, and mWandPos.

Referenced by updateProjectionData().

00181 {
00182    mHeadPos = mSimViewport->getUser()->getHeadPosProxy()->getData(positionScale);
00183    mWandPos = mWand->getData(positionScale);
00184 
00185    mCameraPos = mCamera->getData(positionScale);
00186    gmtl::invert(mCameraPos);
00187 }

bool vrj::GlBasicSimulator::shouldDrawProjections (  )  [inline]

Definition at line 124 of file GlBasicSimulator.h.

References mDrawProjections.

Referenced by drawSimulator().

00125    {
00126       return mDrawProjections;
00127    }

gmtl::Vec3f vrj::GlBasicSimulator::getSurfaceColor (  )  [inline]

Definition at line 129 of file GlBasicSimulator.h.

References mSurfaceColor.

Referenced by drawSimulator().

00130    {
00131       return mSurfaceColor;
00132    }

void vrj::GlBasicSimulator::drawObjects (  )  [protected]

Draws any objects that the manager needs to display i.e.

Gloves, etc.

Definition at line 192 of file GlBasicSimulator.cpp.

00193 {
00194    glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_LIGHTING_BIT );
00195    {
00196       glDisable(GL_LIGHTING);
00197       glDisable(GL_BLEND);
00198       //vjInputManager*  input_mgr = Kernel::instance()->getInputManager();
00199 
00200       // Draw all glove Proxies that have drawing flag set
00201       /* XXX: Broken because we don't have list anymore
00202       GloveProxy* cur_glove_proxy;
00203       for (int glv = 0; glv < input_mgr->getNumGloveProxies(); glv++)    // For each glove in system
00204       {
00205          cur_glove_proxy = input_mgr->getGloveProxy(glv);         // Get the glove proxy
00206          if (cur_glove_proxy->isVisible())                         // If flag set
00207             drawGlove( cur_glove_proxy );                           // draw it
00208       }
00209       */
00210 
00211       // Draw any other object that need to be seen
00212    }
00213    glPopAttrib();
00214 }

void vrj::GlBasicSimulator::drawProjections ( bool  drawFrustum,
gmtl::Vec3f  surfColor,
const float  scaleFactor 
) [protected]

Draw the projections.

Postcondition:
Draws the projections. If withApex, then it draws the frustums with different colors. If !withApex, then just draws the surfaces in all white.

Definition at line 224 of file GlBasicSimulator.cpp.

References drawLine(), vrj::DisplayManager::getAllDisplays(), vrj::Projection::getFrustumApexAndCorners(), vrj::DisplayManager::updateProjections(), and vrjDBG_DRAW_MGR().

Referenced by drawSimulator().

00225 {
00226    const float ALPHA_VALUE(0.25f);
00227 
00228    DisplayManager* display_man = vrj::GlDrawManager::instance()->getDisplayManager();
00229    display_man->updateProjections(scaleFactor);                     // Update all projections for drawing
00230 
00231    std::vector<Display*> disps = display_man->getAllDisplays();
00232 
00233    gmtl::Vec3f apex, ur, lr, ul, ll;
00234    Projection* proj; proj = NULL;
00235 
00236    for (unsigned int i=0;i<disps.size();i++)
00237    {
00238       for (unsigned int v=0;v<disps[i]->getNumViewports();v++)
00239       {
00240          Viewport* view_port = disps[i]->getViewport(v);
00241 
00242          if (view_port->isSurface())
00243          {
00244             for(unsigned proj_num=0;proj_num<2;++proj_num)
00245             {
00246                // Get a pointer to the surface
00247                SurfaceViewport* surf_vp = dynamic_cast<SurfaceViewport*>(view_port);
00248                vprASSERT(surf_vp != NULL);
00249                proj = NULL;
00250                if(0 == proj_num)
00251                   proj = surf_vp->getLeftProj();
00252                else
00253                   proj = surf_vp->getRightProj();
00254 
00255                // Create color values that are unique
00256                // Basically count in binary (skipping 0), and use the first 3 digits.  That will give six colors
00257                int red_on = (i & 0x1); int green_on = ((i >> 1) & 0x1); int blue_on = ((i >> 2) & 0x1);
00258 
00259                float red(0.0f), green(0.0f), blue(0.0f);
00260                if (red_on > 0) red = 1.0f;
00261                if (green_on > 0) green = 1.0f;
00262                if (blue_on > 0) blue = 1.0f;
00263 
00264                if ((!red_on) && (!blue_on) && (!green_on))      // Case of 0's (black is bad)
00265                   red = blue = green = 0.75f;
00266 
00267                gmtl::Vec3f surf_color;
00268                gmtl::Vec3f apex_color;
00269                if (drawFrustum)
00270                {
00271                   surf_color = gmtl::Vec3f(red,blue,green);
00272                }
00273                else
00274                {
00275                   surf_color = surfColor;
00276                }
00277                apex_color = surf_color;
00278                if(1 == proj_num)  // Right eye
00279                {
00280                   apex_color = gmtl::Vec3f(1.0f, 1.0f, 1.0f) - apex_color;    // Invert it
00281                }
00282 
00283                // Compute scaled colors for the corners
00284                // ll is going to be lighter and upper right is going to be darker
00285                const float ll_scale(0.10f);
00286                const float ul_scale(0.55f);
00287                const float ur_scale(1.0f);
00288                gmtl::Vec4f ll_clr(ll_scale*surf_color[0],ll_scale*surf_color[1],ll_scale*surf_color[2],ALPHA_VALUE);
00289                gmtl::Vec4f ul_clr(ul_scale*surf_color[0],ul_scale*surf_color[1],ul_scale*surf_color[2],ALPHA_VALUE);
00290                gmtl::Vec4f lr_clr(ul_scale*surf_color[0],ul_scale*surf_color[1],ul_scale*surf_color[2],ALPHA_VALUE);
00291                gmtl::Vec4f ur_clr(ur_scale*surf_color[0],ur_scale*surf_color[1],ur_scale*surf_color[2],ALPHA_VALUE);
00292 
00293                // Draw the thingy
00294                proj->getFrustumApexAndCorners(apex, ur, lr, ul, ll);
00295                vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL) << "apex: " << apex
00296                                                            << std::endl << vprDEBUG_FLUSH;
00297 
00298                glColor4fv(&(apex_color[0]));
00299                glPushMatrix();
00300                   if (drawFrustum)
00301                   {
00302                      drawLine(apex, ur); drawLine(apex, lr); drawLine(apex, ul); drawLine(apex, ll);
00303                   }
00304 
00305                   glColor4fv(&(ur_clr[0]));
00306                   // Draw the outline
00307                   drawLine(ur, lr); drawLine(lr, ll); drawLine(ll, ul); drawLine(ul, ur);
00308 
00309                   // Draw the surface
00310                   glEnable(GL_BLEND);
00311                   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00312                   glBegin(GL_TRIANGLES);
00313                   glColor4fv(ll_clr.mData);  glVertex3fv(ll.mData);
00314                   glColor4fv(lr_clr.mData);  glVertex3fv(lr.mData);
00315                   glColor4fv(ur_clr.mData);  glVertex3fv(ur.mData);
00316 
00317                   glColor4fv(ur_clr.mData); glVertex3fv(ur.mData);
00318                   glColor4fv(ul_clr.mData); glVertex3fv(ul.mData);
00319                   glColor4fv(ll_clr.mData); glVertex3fv(ll.mData);
00320                   glEnd();
00321                   glDisable(GL_BLEND);
00322                glPopMatrix();
00323             }
00324          }  // if surface
00325       }  // for viewports
00326    }  // for disps
00327 }

void vrj::GlBasicSimulator::drawSimulator ( const float  scaleFactor  )  [protected]

Draws a simulator using OpenGL commands.

Note:
This is called internally by the library.

*

Definition at line 333 of file GlBasicSimulator.cpp.

References vrj::GlDrawObjectFunctor::draw(), drawProjections(), getHeadPos(), getSurfaceColor(), vrj::Viewport::getUser(), getWandPos(), mDrawHeadFunctor, mDrawWandFunctor, mSimViewport, and shouldDrawProjections().

Referenced by draw().

00334 {
00335    glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_LIGHTING_BIT);
00336    {
00337       // Test to see wethere there is lighting active
00338       GLboolean lighting_on, light0_on;
00339       glGetBooleanv(GL_LIGHTING, &lighting_on);
00340       glGetBooleanv(GL_LIGHT0, &light0_on);
00341 
00342       bool use_lighting_in_sim = (lighting_on == GL_TRUE);
00343 
00344       //vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << "lighting on: " << ((lighting_on == GL_TRUE)?"Y":"N")
00345       //                       << "  light0_on:" << ((light0_on == GL_TRUE)?"Y":"N") << std::endl << vprDEBUG_FLUSH;
00346 
00347       //-----------------set up materials....
00348       float mat_ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
00349       float mat_shininess[] = {50.0f};
00350       float mat_diffuse[] = {.7f, .7f, .7f, 1.0f};
00351       float mat_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
00352       //-----------------Call Materials.....
00353       glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
00354       glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
00355       glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
00356       glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
00357       //----------------Enable Materials.....
00358       glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
00359       glEnable(GL_COLOR_MATERIAL);
00360 
00361       glDisable(GL_TEXTURE_2D);
00362       glDisable(GL_TEXTURE_1D);
00363 
00364       // Draw base coordinate axis
00366       if(lighting_on)
00367       {
00368          glDisable(GL_LIGHTING);
00369       }
00370 
00371       glPushMatrix();
00372          glLoadIdentity();
00373          gmtl::Vec3f x_axis(scaleFactor,0.0f,0.0f); gmtl::Vec3f y_axis(0.0f, scaleFactor, 0.0f);
00374          gmtl::Vec3f z_axis(0.0f, 0.0f, scaleFactor); gmtl::Vec3f origin(0.0f, 0.0f, 0.0f);
00375          glBegin(GL_LINES);
00376             glColor3f(1.0f, 0.0f, 0.0f); glVertex3fv(origin.mData); glVertex3fv(x_axis.mData);
00377             glColor3f(0.0f, 1.0f, 0.0f); glVertex3fv(origin.mData); glVertex3fv(y_axis.mData);
00378             glColor3f(0.0f, 0.0f, 1.0f); glVertex3fv(origin.mData); glVertex3fv(z_axis.mData);
00379          glEnd();
00380       glPopMatrix();
00381       //*/
00382 
00383       if(use_lighting_in_sim)
00384       {
00385          glEnable(GL_LIGHTING);
00386          glEnable(GL_NORMALIZE);
00387       }
00388 
00389       // Draw the user's head
00390       glPushMatrix();
00391          glLoadIdentity();
00392          glMultMatrixf(getHeadPos().mData);
00393          glScalef(scaleFactor, scaleFactor, scaleFactor);
00394          glEnable(GL_NORMALIZE);
00395          mDrawHeadFunctor->draw(mSimViewport->getUser());
00396       glPopMatrix();
00397 
00398       // Draw the wand
00399       glPushMatrix();
00400          glLoadIdentity();
00401          glMultMatrixf(getWandPos().mData);
00402          glScalef(scaleFactor,scaleFactor,scaleFactor);
00403          glEnable(GL_NORMALIZE);
00404          mDrawWandFunctor->draw(mSimViewport->getUser());
00405       glPopMatrix();
00406 
00407        // Draw a The display surfaces
00408       if(use_lighting_in_sim)
00409       {
00410          glDisable(GL_LIGHTING);
00411       }
00412 
00413       glPushMatrix();
00414          glLoadIdentity();
00415          drawProjections(shouldDrawProjections(), getSurfaceColor(), scaleFactor);
00416       glPopMatrix();
00417    }
00418    glPopAttrib();
00419 }

void vrj::GlBasicSimulator::setDrawWandFunctor ( GlDrawObjectFunctor functor  )  [inline, protected]

Sets the functor used to render the wand.

Definition at line 153 of file GlBasicSimulator.h.

References mDrawWandFunctor.

Referenced by GlBasicSimulator().

00154    {
00155       mDrawWandFunctor = functor;
00156    }

void vrj::GlBasicSimulator::setDrawHeadFunctor ( GlDrawObjectFunctor functor  )  [inline, protected]

Sets the functor used to render the head.

Definition at line 159 of file GlBasicSimulator.h.

References mDrawHeadFunctor.

Referenced by GlBasicSimulator().

00160    {
00161       mDrawHeadFunctor = functor;
00162    }

void vrj::GlBasicSimulator::initQuadObj (  )  [protected]

void vrj::GlBasicSimulator::drawLine ( gmtl::Vec3f &  start,
gmtl::Vec3f &  end 
) [protected]

Definition at line 421 of file GlBasicSimulator.cpp.

Referenced by drawProjections().

00422 {
00423    glBegin(GL_LINES);
00424       glVertex3fv(start.mData);
00425       glVertex3fv(end.mData);
00426    glEnd();
00427 }

void vrj::GlBasicSimulator::drawCone ( float  base,
float  height,
int  slices,
int  stacks 
) [protected]

Definition at line 429 of file GlBasicSimulator.cpp.

References mQuadObj.

00430 {
00431   gluQuadricDrawStyle(mQuadObj, (GLenum) GLU_FILL);
00432   gluQuadricNormals(mQuadObj, (GLenum) GLU_SMOOTH);
00433   gluCylinder(mQuadObj, base, 0.0, height, slices, stacks);
00434 }

void vrj::GlBasicSimulator::drawBox ( float  size,
GLenum  type 
) [protected]

Definition at line 436 of file GlBasicSimulator.cpp.

Referenced by drawSolidCube(), and drawWireCube().

00437 {
00438   static GLfloat n[6][3] =
00439   {
00440     {-1.0, 0.0, 0.0},
00441     {0.0, 1.0, 0.0},
00442     {1.0, 0.0, 0.0},
00443     {0.0, -1.0, 0.0},
00444     {0.0, 0.0, 1.0},
00445     {0.0, 0.0, -1.0}
00446   };
00447 
00448   static GLint faces[6][4] =
00449   {
00450     {0, 1, 2, 3},
00451     {3, 2, 6, 7},
00452     {7, 6, 5, 4},
00453     {4, 5, 1, 0},
00454     {5, 6, 2, 1},
00455     {7, 4, 0, 3}
00456   };
00457   GLfloat v[8][3];
00458   GLint i;
00459 
00460   v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
00461   v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
00462   v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
00463   v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
00464   v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
00465   v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
00466 
00467   for (i = 5; i >= 0; i--) {
00468     glBegin(type);
00469     glNormal3fv(&n[i][0]);
00470     glVertex3fv(&v[faces[i][0]][0]);
00471     glVertex3fv(&v[faces[i][1]][0]);
00472     glVertex3fv(&v[faces[i][2]][0]);
00473     glVertex3fv(&v[faces[i][3]][0]);
00474     glEnd();
00475   }
00476 }

void vrj::GlBasicSimulator::drawWireCube ( float  size  )  [protected]

Definition at line 479 of file GlBasicSimulator.cpp.

References drawBox().

00480 {
00481   drawBox(size, GL_LINE_LOOP);
00482 }

void vrj::GlBasicSimulator::drawSolidCube ( float  size  )  [protected]

Definition at line 484 of file GlBasicSimulator.cpp.

References drawBox().

00485 {
00486   drawBox(size, GL_QUADS);
00487 }


Member Data Documentation

GlDrawObjectFunctor* vrj::GlBasicSimulator::mDrawWandFunctor [protected]

The functor to draw the wand.

Definition at line 174 of file GlBasicSimulator.h.

Referenced by drawSimulator(), setDrawWandFunctor(), and ~GlBasicSimulator().

GlDrawObjectFunctor* vrj::GlBasicSimulator::mDrawHeadFunctor [protected]

The functor to draw the head.

Definition at line 175 of file GlBasicSimulator.h.

Referenced by drawSimulator(), setDrawHeadFunctor(), and ~GlBasicSimulator().

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

Quadric for drawing stuff.

Definition at line 176 of file GlBasicSimulator.h.

Referenced by drawCone(), and ~GlBasicSimulator().

SimViewport* vrj::GlBasicSimulator::mSimViewport [protected]

Definition at line 179 of file GlBasicSimulator.h.

Referenced by drawSimulator(), initialize(), updateInternalData(), and updateProjectionData().

bool vrj::GlBasicSimulator::mDrawProjections [protected]

Should we draw projections.

Definition at line 182 of file GlBasicSimulator.h.

Referenced by config(), and shouldDrawProjections().

gmtl::Vec3f vrj::GlBasicSimulator::mSurfaceColor [protected]

Color to draw surfaces.

Definition at line 183 of file GlBasicSimulator.h.

Referenced by config(), and getSurfaceColor().

gadget::PositionInterface vrj::GlBasicSimulator::mCamera [protected]

Proxy interfaces to devices needed.

Definition at line 185 of file GlBasicSimulator.h.

Referenced by config(), and updateInternalData().

gadget::PositionInterface vrj::GlBasicSimulator::mWand [protected]

Definition at line 186 of file GlBasicSimulator.h.

Referenced by config(), and updateInternalData().

gmtl::Matrix44f vrj::GlBasicSimulator::mCameraPos [protected]

The data about the position of all this stuff.

Definition at line 188 of file GlBasicSimulator.h.

Referenced by getCameraPos(), and updateInternalData().

gmtl::Matrix44f vrj::GlBasicSimulator::mHeadPos [protected]

Definition at line 189 of file GlBasicSimulator.h.

Referenced by getHeadPos(), and updateInternalData().

gmtl::Matrix44f vrj::GlBasicSimulator::mWandPos [protected]

Definition at line 190 of file GlBasicSimulator.h.

Referenced by getWandPos(), and updateInternalData().


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