Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

vrj::GlBasicSimulator Class Reference

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

#include <GlBasicSimulator.h>

Inheritance diagram for vrj::GlBasicSimulator:

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

Collaboration graph
[legend]
List of all members.

Public Methods

 GlBasicSimulator ()
virtual ~GlBasicSimulator ()
virtual bool config (jccl::ConfigElementPtr element)
 Configures the basic OpenGL simulator. More...

virtual void draw (const float scaleFactor)
 Draws this sim device using the given information about the Window it will be drawing into. More...

virtual void initialize (SimViewport *simVp)
virtual void setEventWindow (gadget::EventWindowInterface ewInterface)
 Sets the event window the simulator can use to get input from the user. More...

gmtl::Matrix44f getCameraPos ()
gmtl::Matrix44f getHeadPos ()
gmtl::Matrix44f getWandPos ()
virtual void updateProjectionData (const float positionScale, Projection *leftProj, Projection *rightProj)
 Called as part of the viewports updateProjection call. More...

void updateInternalData (float positionScale)
 Update internal simulator data. More...

bool shouldDrawProjections ()
gmtl::Vec3f getSurfaceColor ()

Static Public Methods

std::string getElementType ()

Protected Methods

void drawObjects ()
 Draws any objects that the manager needs to display i.e. More...

void drawProjections (bool drawFrustum, gmtl::Vec3f surfColor, const float scaleFactor)
 Draw the projections. More...

void drawSimulator (const float scaleFactor)
 Draws a simulator using OpenGL commands. More...

void setDrawWandFunctor (GlDrawObjectFunctor *functor)
 Set the functor used to draw the wand. More...

void initQuadObj ()
void drawLine (gmtl::Vec3f &start, gmtl::Vec3f &end)
void drawSphere (float radius, int slices, int stacks)
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. More...

GLUquadricObj * mQuadObj
 Quadric for drawing stuff. More...

SimViewportmSimViewport
bool mDrawProjections
 Should we draw projections. More...

gmtl::Vec3f mSurfaceColor
 Color to draw surfaces. More...

gadget::PositionInterface mCamera
 Proxy interfaces to devices needed. More...

gadget::PositionInterface mWand
gmtl::Matrix44f mCameraPos
 The data about the position of all this stuff. More...

gmtl::Matrix44f mHeadPos
gmtl::Matrix44f mWandPos

Detailed Description

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

Definition at line 62 of file GlBasicSimulator.h.


Constructor & Destructor Documentation

vrj::GlBasicSimulator::GlBasicSimulator  
 

Definition at line 64 of file GlBasicSimulator.cpp.

References setDrawWandFunctor.

00064                                    : mQuadObj(NULL)
00065 {
00066    //setDrawWandFunctor(new GlDrawConeWandFunctor());
00067    setDrawWandFunctor(new GlDrawRightAngleWandFunctor());
00068 }

virtual vrj::GlBasicSimulator::~GlBasicSimulator   [inline, virtual]
 

Definition at line 67 of file GlBasicSimulator.h.

00067 {}


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 75 of file GlBasicSimulator.cpp.

References mCamera, mDrawProjections, mSurfaceColor, and mWand.

00076 {
00077    vprASSERT(element.get() != NULL);
00078    vprASSERT(element->getID() == std::string("default_simulator"));
00079 
00080    std::string camera_proxy_str = element->getProperty<std::string>("camera_pos");
00081    std::string wand_proxy_str = element->getProperty<std::string>("wand_pos");
00082 
00083    mCamera.init(camera_proxy_str);
00084    mWand.init(wand_proxy_str);      // Configure the wand to use
00085 
00086    if(!mCamera.isConnected())
00087    {
00088       vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
00089          << clrOutNORM(clrRED,"ERROR:")
00090          << "GlBasicSimulator:: Fatal Error: Camera not found named: "
00091          << camera_proxy_str.c_str() << vprDEBUG_FLUSH;
00092       vprASSERT(false);
00093    }
00094 
00095    // Get drawing parameters
00096    mDrawProjections = element->getProperty<bool>("draw_projections");
00097    mSurfaceColor[0] = element->getProperty<float>("surface_color", 0);
00098    mSurfaceColor[1] = element->getProperty<float>("surface_color", 1);
00099    mSurfaceColor[2] = element->getProperty<float>("surface_color", 2);
00100 
00101    return true;
00102 }

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

Definition at line 76 of file GlBasicSimulator.h.

00077    {
00078       return std::string("default_simulator");
00079    }

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 108 of file GlBasicSimulator.cpp.

References drawSimulator.

00109 {
00110    drawSimulator(scaleFactor);
00111 }

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

Implements vrj::DrawSimInterface.

Definition at line 87 of file GlBasicSimulator.h.

References mSimViewport.

00088    {
00089       mSimViewport = simVp;
00090    }

void vrj::GlBasicSimulator::setEventWindow gadget::EventWindowInterface    ewInterface [virtual]
 

Sets the event window the simulator can use to get input from the user.

Implements vrj::GlSimInterface.

Definition at line 117 of file GlBasicSimulator.cpp.

00118 {
00119    boost::ignore_unused_variable_warning(ewInterface);
00120 }

gmtl::Matrix44f vrj::GlBasicSimulator::getCameraPos   [inline]
 

Definition at line 98 of file GlBasicSimulator.h.

References mCameraPos.

Referenced by updateProjectionData.

00099    { return mCameraPos; }

gmtl::Matrix44f vrj::GlBasicSimulator::getHeadPos   [inline]
 

Definition at line 101 of file GlBasicSimulator.h.

References mHeadPos.

Referenced by drawSimulator.

00102    { return mHeadPos; }

gmtl::Matrix44f vrj::GlBasicSimulator::getWandPos   [inline]
 

Definition at line 104 of file GlBasicSimulator.h.

References mWandPos.

Referenced by drawSimulator.

00105    { return mWandPos; }

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 123 of file GlBasicSimulator.cpp.

References getCameraPos, mSimViewport, and updateInternalData.

00125 {
00126    updateInternalData(positionScale);
00127 
00128    gmtl::Matrix44f camera_pos = getCameraPos();
00129    gmtl::Vec3f camera_trans = gmtl::makeTrans<gmtl::Vec3f>(camera_pos);
00130 
00131    //mCameraProj->calcViewMatrix(camera_pos);
00132 
00133    gmtl::Matrix44f left_eye_pos, right_eye_pos;     // NOTE: Eye coord system is -z forward, x-right, y-up
00134 
00135    // -- Calculate camera (eye) Positions -- //
00136    vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL)
00137       << "vjDisplay::updateProjections: Getting cam position" << std::endl
00138       << vprDEBUG_FLUSH;
00139    vprDEBUG(vprDBG_ALL, vprDBG_HEX_LVL) << "CamPos:" << camera_trans << std::endl << vprDEBUG_FLUSH;
00140 
00141    // Compute location of left and right eyes
00142    float interocular_dist = mSimViewport->getUser()->getInterocularDistance();
00143    interocular_dist *= positionScale;               // Scale into correct units
00144    float eye_offset = interocular_dist / 2.0f;      // Distance to move eye
00145 
00146    left_eye_pos = camera_pos * gmtl::makeTrans<gmtl::Matrix44f>( gmtl::Vec3f(-eye_offset, 0.0f, 0.0f) );
00147    right_eye_pos = camera_pos * gmtl::makeTrans<gmtl::Matrix44f>( gmtl::Vec3f(eye_offset, 0.0f, 0.0f) );
00148 
00149    leftProj->calcViewMatrix(left_eye_pos, positionScale);
00150    rightProj->calcViewMatrix(right_eye_pos, positionScale);
00151 }

void vrj::GlBasicSimulator::updateInternalData float    positionScale
 

Update internal simulator data.

Definition at line 154 of file GlBasicSimulator.cpp.

References mCamera, mCameraPos, mHeadPos, mSimViewport, mWand, and mWandPos.

Referenced by updateProjectionData.

00155 {
00156    mHeadPos = mSimViewport->getUser()->getHeadPosProxy()->getData(positionScale);
00157    mWandPos = mWand->getData(positionScale);
00158 
00159    mCameraPos = mCamera->getData(positionScale);
00160    gmtl::invert(mCameraPos);
00161 }

bool vrj::GlBasicSimulator::shouldDrawProjections   [inline]
 

Definition at line 114 of file GlBasicSimulator.h.

References mDrawProjections.

Referenced by drawSimulator.

00115    { return mDrawProjections; }

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

Definition at line 117 of file GlBasicSimulator.h.

References mSurfaceColor.

Referenced by drawSimulator.

00118    { return mSurfaceColor; }

void vrj::GlBasicSimulator::drawObjects   [protected]
 

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

Gloves, etc.

Definition at line 166 of file GlBasicSimulator.cpp.

00167 {
00168    glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_LIGHTING_BIT );
00169    {
00170       glDisable(GL_LIGHTING);
00171       glDisable(GL_BLEND);
00172       //vjInputManager*  input_mgr = Kernel::instance()->getInputManager();
00173 
00174       // Draw all glove Proxies that have drawing flag set
00175       /* XXX: Broken because we don't have list anymore
00176       GloveProxy* cur_glove_proxy;
00177       for (int glv = 0; glv < input_mgr->getNumGloveProxies(); glv++)    // For each glove in system
00178       {
00179          cur_glove_proxy = input_mgr->getGloveProxy(glv);         // Get the glove proxy
00180          if (cur_glove_proxy->isVisible())                         // If flag set
00181             drawGlove( cur_glove_proxy );                           // draw it
00182       }
00183       */
00184 
00185       // Draw any other object that need to be seen
00186    }
00187    glPopAttrib();
00188 }

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 198 of file GlBasicSimulator.cpp.

References drawLine, and vrjDBG_DRAW_MGR.

Referenced by drawSimulator.

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

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 307 of file GlBasicSimulator.cpp.

References drawProjections, drawSphere, getHeadPos, getSurfaceColor, getWandPos, mDrawWandFunctor, mSimViewport, and shouldDrawProjections.

Referenced by draw.

00308 {
00309    // All units are in meters
00310    // Note: All the wand and head data in the sim viewport class
00311    // has already had the scale factor applied to it
00312    const float head_height(0.254f*scaleFactor);      // 10 inches
00313    const float head_width_scale(0.7f);
00314    const float head_depth_scale(0.8f);
00315    //const float eye_vertical(0.067f*scaleFactor);
00316    //const float eye_horizontal(0.21f*scaleFactor);
00317    const float interocular( mSimViewport->getUser()->getInterocularDistance()*scaleFactor);
00318    const float eye_radius(0.0254f*0.5f*scaleFactor);      // 0.5 in
00319 
00320    glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_LIGHTING_BIT);
00321    {
00322       // Test to see wethere there is lighting active
00323       GLboolean lighting_on, light0_on;
00324       glGetBooleanv(GL_LIGHTING, &lighting_on);
00325       glGetBooleanv(GL_LIGHT0, &light0_on);
00326 
00327       bool use_lighting_in_sim = (lighting_on == GL_TRUE);
00328 
00329       //vprDEBUG(vprDBG_ALL, vprDBG_HVERB_LVL) << "lighting on: " << ((lighting_on == GL_TRUE)?"Y":"N")
00330       //                       << "  light0_on:" << ((light0_on == GL_TRUE)?"Y":"N") << std::endl << vprDEBUG_FLUSH;
00331 
00332       //-----------------set up materials....
00333       float mat_ambient[] = {0.1f, 0.1f, 0.1f, 1.0f};
00334       float mat_shininess[] = {50.0f};
00335       float mat_diffuse[] = {.7f, .7f, .7f, 1.0f};
00336       float mat_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
00337       //-----------------Call Materials.....
00338       glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
00339       glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
00340       glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
00341       glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
00342       //----------------Enable Materials.....
00343       glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
00344       glEnable(GL_COLOR_MATERIAL);
00345 
00346       glDisable(GL_TEXTURE_2D);
00347       glDisable(GL_TEXTURE_1D);
00348 
00349       // Draw base coordinate axis
00351       if(lighting_on)
00352          glDisable(GL_LIGHTING);
00353 
00354       glPushMatrix();
00355          gmtl::Vec3f x_axis(scaleFactor,0.0f,0.0f); gmtl::Vec3f y_axis(0.0f, scaleFactor, 0.0f);
00356          gmtl::Vec3f z_axis(0.0f, 0.0f, scaleFactor); gmtl::Vec3f origin(0.0f, 0.0f, 0.0f);
00357          glBegin(GL_LINES);
00358             glColor3f(1.0f, 0.0f, 0.0f); glVertex3fv(origin.mData); glVertex3fv(x_axis.mData);
00359             glColor3f(0.0f, 1.0f, 0.0f); glVertex3fv(origin.mData); glVertex3fv(y_axis.mData);
00360             glColor3f(0.0f, 0.0f, 1.0f); glVertex3fv(origin.mData); glVertex3fv(z_axis.mData);
00361          glEnd();
00362       glPopMatrix();
00363       //*/
00364 
00365       if(use_lighting_in_sim)
00366       {
00367          glEnable(GL_LIGHTING);
00368          glEnable(GL_NORMALIZE);
00369       }
00370       // Draw the user's head
00371       glPushMatrix();
00372          glMultMatrixf(getHeadPos().mData);
00373 
00374          glPushMatrix();
00375             // Head pos is the center of the eyes, so we need to move the head offset a bit
00376             // to get it positioned correctly.  We will do this by measuring the distance from center
00377             // of head to forehead and then translate by the negative of that
00378             gmtl::Vec3f forehead_offset(0.0f, head_height*0.17f, -(head_depth_scale*head_height)*0.45f);
00379             glTranslatef(-forehead_offset[0], -forehead_offset[1], -forehead_offset[2]);
00380             glScalef(head_width_scale, 1.0f, head_depth_scale);      // Scale to get an ellipsoid head
00381             //glEnable(GL_BLEND);
00382             //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00383             glColor4f(0.5f, 0.75f, 0.90f, 0.67f);
00384             drawSphere(head_height/2.0f, 10, 10);             // Head
00385             //glDisable(GL_BLEND);
00386          glPopMatrix();
00387 
00388          // --- Draw the eyes --- //
00389          glPushMatrix();
00390             glColor3f(0.8f, 0.4f, 0.2f);
00391             //glTranslatef(0.0f, eye_vertical, -eye_horizontal);
00392             glPushMatrix();                     // Right eye
00393                glTranslatef((interocular/2.0f), 0.0f, 0.0f);
00394                drawSphere(eye_radius, 5, 5);
00395             glPopMatrix();
00396             glPushMatrix();                     // Left eye
00397                glTranslatef(-(interocular/2.0f), 0.0f, 0.0f);
00398                drawSphere(eye_radius, 5, 5);
00399             glPopMatrix();
00400          glPopMatrix();
00401       glPopMatrix();
00402 
00403       // Draw the wand
00404       glPushMatrix();
00405          glMultMatrixf(getWandPos().mData);
00406          glScalef(scaleFactor,scaleFactor,scaleFactor);
00407          glEnable(GL_NORMALIZE);
00408          mDrawWandFunctor->draw();
00409       glPopMatrix();
00410 
00411        // Draw a The display surfaces
00412       if(use_lighting_in_sim)
00413          glDisable(GL_LIGHTING);
00414 
00415       glPushMatrix();
00416          drawProjections(shouldDrawProjections(), getSurfaceColor(), scaleFactor);
00417       glPopMatrix();
00418    }
00419    glPopAttrib();
00420 }

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

Set the functor used to draw the wand.

Definition at line 139 of file GlBasicSimulator.h.

References mDrawWandFunctor.

Referenced by GlBasicSimulator.

00140    { mDrawWandFunctor = functor; }

void vrj::GlBasicSimulator::initQuadObj   [protected]
 

Definition at line 423 of file GlBasicSimulator.cpp.

References mQuadObj.

Referenced by drawCone, and drawSphere.

00424 {
00425    if (mQuadObj == NULL)
00426       mQuadObj = gluNewQuadric();
00427 }

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

Definition at line 429 of file GlBasicSimulator.cpp.

Referenced by drawProjections.

00430 {
00431    glBegin(GL_LINES);
00432       glVertex3fv(start.mData);
00433       glVertex3fv(end.mData);
00434    glEnd();
00435 }

void vrj::GlBasicSimulator::drawSphere float    radius,
int    slices,
int    stacks
[protected]
 

Definition at line 437 of file GlBasicSimulator.cpp.

References initQuadObj, and mQuadObj.

Referenced by drawSimulator.

00438 {
00439   initQuadObj();
00440   gluQuadricDrawStyle(mQuadObj, (GLenum) GLU_FILL);
00441   gluQuadricNormals(mQuadObj, (GLenum) GLU_SMOOTH);
00442   gluSphere(mQuadObj, radius, slices, stacks);
00443 }

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

Definition at line 446 of file GlBasicSimulator.cpp.

References initQuadObj, and mQuadObj.

00447 {
00448   initQuadObj();
00449   gluQuadricDrawStyle(mQuadObj, (GLenum) GLU_FILL);
00450   gluQuadricNormals(mQuadObj, (GLenum) GLU_SMOOTH);
00451   gluCylinder(mQuadObj, base, 0.0, height, slices, stacks);
00452 }

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

Definition at line 456 of file GlBasicSimulator.cpp.

Referenced by drawSolidCube, and drawWireCube.

00457 {
00458   static GLfloat n[6][3] =
00459   {
00460     {-1.0, 0.0, 0.0},
00461     {0.0, 1.0, 0.0},
00462     {1.0, 0.0, 0.0},
00463     {0.0, -1.0, 0.0},
00464     {0.0, 0.0, 1.0},
00465     {0.0, 0.0, -1.0}
00466   };
00467 
00468   static GLint faces[6][4] =
00469   {
00470     {0, 1, 2, 3},
00471     {3, 2, 6, 7},
00472     {7, 6, 5, 4},
00473     {4, 5, 1, 0},
00474     {5, 6, 2, 1},
00475     {7, 4, 0, 3}
00476   };
00477   GLfloat v[8][3];
00478   GLint i;
00479 
00480   v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2;
00481   v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2;
00482   v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2;
00483   v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2;
00484   v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2;
00485   v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2;
00486 
00487   for (i = 5; i >= 0; i--) {
00488     glBegin(type);
00489     glNormal3fv(&n[i][0]);
00490     glVertex3fv(&v[faces[i][0]][0]);
00491     glVertex3fv(&v[faces[i][1]][0]);
00492     glVertex3fv(&v[faces[i][2]][0]);
00493     glVertex3fv(&v[faces[i][3]][0]);
00494     glEnd();
00495   }
00496 }

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

Definition at line 499 of file GlBasicSimulator.cpp.

References drawBox.

00500 {
00501   drawBox(size, GL_LINE_LOOP);
00502 }

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

Definition at line 504 of file GlBasicSimulator.cpp.

References drawBox.

00505 {
00506   drawBox(size, GL_QUADS);
00507 }


Member Data Documentation

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

The functor to draw the wand.

Definition at line 154 of file GlBasicSimulator.h.

Referenced by drawSimulator, and setDrawWandFunctor.

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

Quadric for drawing stuff.

Definition at line 155 of file GlBasicSimulator.h.

Referenced by drawCone, drawSphere, and initQuadObj.

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

Definition at line 158 of file GlBasicSimulator.h.

Referenced by drawSimulator, initialize, updateInternalData, and updateProjectionData.

bool vrj::GlBasicSimulator::mDrawProjections [protected]
 

Should we draw projections.

Definition at line 161 of file GlBasicSimulator.h.

Referenced by config, and shouldDrawProjections.

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

Color to draw surfaces.

Definition at line 162 of file GlBasicSimulator.h.

Referenced by config, and getSurfaceColor.

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

Proxy interfaces to devices needed.

Definition at line 164 of file GlBasicSimulator.h.

Referenced by config, and updateInternalData.

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

Definition at line 165 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 167 of file GlBasicSimulator.h.

Referenced by getCameraPos, and updateInternalData.

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

Definition at line 168 of file GlBasicSimulator.h.

Referenced by getHeadPos, and updateInternalData.

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

Definition at line 169 of file GlBasicSimulator.h.

Referenced by getWandPos, and updateInternalData.


The documentation for this class was generated from the following files:
Generated on Sun May 2 15:11:08 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002