Ejemplo n.º 1
0
void drawCurve( const Curve& curve, float framesize )
{
    // Save current state of OpenGL
    glPushAttrib( GL_ALL_ATTRIB_BITS );

    // Setup for line drawing
    glDisable( GL_LIGHTING ); 
    glColor4f( 1, 1, 1, 1 );
    glLineWidth( 1 );
    
    // Draw curve
    glBegin( GL_LINE_STRIP );
    for( unsigned i = 0; i < curve.size(); ++i )
    {
        glVertex( curve[ i ].V );
    }
    glEnd();

    glLineWidth( 1 );

    // Draw coordinate frames if framesize nonzero
    if( framesize != 0.0f )
    {
        Mat4f M;

        for( unsigned i = 0; i < curve.size(); ++i )
        {
            M.setCol( 0, Vec4f( curve[i].N, 0 ) );
            M.setCol( 1, Vec4f( curve[i].B, 0 ) );
            M.setCol( 2, Vec4f( curve[i].T, 0 ) );
            M.setCol( 3, Vec4f( curve[i].V, 1 ) );

            glPushMatrix();
            glMultMatrixf( M.getPtr() );
            glScaled( framesize, framesize, framesize );
            glBegin( GL_LINES );
            glColor3f( 1, 0, 0 ); glVertex3d( 0, 0, 0 ); glVertex3d( 1, 0, 0 );
            glColor3f( 0, 1, 0 ); glVertex3d( 0, 0, 0 ); glVertex3d( 0, 1, 0 );
            glColor3f( 0, 0, 1 ); glVertex3d( 0, 0, 0 ); glVertex3d( 0, 0, 1 );
            glEnd();
            glPopMatrix();
        }
    }
    
    // Pop state
    glPopAttrib();
}
Ejemplo n.º 2
0
void cameraProto::setGl() {
  //// Set up a perspective view, with square aspect ratio
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
  // extern void gluPerspective (GLdouble fov_y, GLdouble aspect, GLdouble zNear, GLdouble zFar);
    gluPerspective((GLdouble)fov_, (GLdouble)1.0, (GLdouble)near_clip_, (GLdouble)far_clip_);
    // Rotate the image
    glMatrixMode( GL_MODELVIEW );  // Current matrix affects objects position_s
    glLoadIdentity();              // Initialize to the identity
    
  Mat4f modelView;
  current_quat_.get(modelView);

  gluLookAt(0,  0,  current_dist_,
            0,  0,  0,
            0,  1,  0);
  
  glMultMatrixf(modelView.getPtr());
  glTranslatef(this->look_at_.x, this->look_at_.y,this->look_at_.z);
}
Ejemplo n.º 3
0
 void                setUniform      (int loc, const Mat4f& v) { if (loc >= 0) glUniformMatrix4fv(loc, 1, false, v.getPtr()); }