void IntersectionUI::draw() { setup3DDrawing( Color(1,1,1), width, height, true ); glMatrixMode(GL_MODELVIEW); gluLookAt( 3.5 * cos( intersectionUI->getYRot() ) * cos( intersectionUI->getXRot() ), 3.5 * sin( intersectionUI->getYRot() ), 3.5 * cos( intersectionUI->getYRot() ) * sin( intersectionUI->getXRot() ), 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glDisable(GL_LIGHTING); if ( intersectionUI->m_bGrid->value() ) { glBegin(GL_LINES); // draw grid glColor3f(0.0f, 0.0f, 0.0f); for (int i = 0; i <= 10; i++) { float s = -2.0f + i / 2.5f; glVertex3f(s, 0.0f, -2.0f); glVertex3f(s, 0.0f, 2.0f); glVertex3f(-2.0f, 0.0f, s); glVertex3f( 2.0f, 0.0f, s); } glEnd(); // draw (X,Y,Z) axes glLineWidth(3.0f); glBegin(GL_LINES); glColor3f(1.0f, 0.0f, 0.0f); glVertex3f(-2.0f, 0.0f, 0.0f); glVertex3f( 2.0f, 0.0f, 0.0f); glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(0.0f, -2.0f, 0.0f); glVertex3f(0.0f, 2.0f, 0.0f); glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(0.0f, 0.0f, -2.0f); glVertex3f(0.0f, 0.0f, 2.0f); glEnd(); glLineWidth(1.0f); } // compute ray origin from parameters Point3 pAt( intersectionUI->m_dXAt->value(), intersectionUI->m_dYAt->value(), intersectionUI->m_dZAt->value() ); // compute ray direction from parameters Vector3 dir; dir[0] = cos(intersectionUI->getPhi()) * cos(intersectionUI->getTheta()); dir[1] = sin(intersectionUI->getPhi()); dir[2] = cos(intersectionUI->getPhi()) * sin(intersectionUI->getTheta()); const Point3 pE1 = pAt - dir * 2.0; const Point3 pE2 = pAt + dir * 2.0; if (intersectionUI->m_bRay->value()) { glPointSize(6.0f); glLineWidth(3.0f); glColor3f(0.5f, 0.5f, 0.0f); glBegin(GL_POINTS); glVertex3dv( &pE1[0]); glEnd(); glColor3f(0.5f, 0.0f, 0.5f); glBegin(GL_LINES); glVertex3dv( &pE1[0]); glVertex3dv( &pE2[0]); glEnd(); glLineWidth(1.0f); glPointSize(1.0f); } if (intersectionUI->m_bRayShadow->value()) { glPointSize(6.0f); glLineWidth(2.0f); glColor3f(0.1f, 0.1f, 0.0f); glBegin(GL_POINTS); glVertex3d( pE1[0], 0.0, pE1[2] ); glEnd(); glColor3f(0.0f, 0.0f, 0.0f); glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0xF0F0); glBegin(GL_LINES); glVertex3d( pE1[0], 0.0, pE1[2] ); glVertex3d( pE2[0], 0.0, pE2[2] ); glVertex3d( pE1[0], 0.0, pE1[2] ); glVertex3dv( &pE1[0]); glVertex3d( pE2[0], 0.0, pE2[2] ); glVertex3dv( &pE2[0]); glEnd(); glLineWidth(1.0f); glPointSize(1.0f); glDisable(GL_LINE_STIPPLE); } glEnable(GL_LIGHTING); glEnable( GL_BLEND ); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); const float colPlane[4] = {0.5, 0.5, 0.75, 0.5}; const float colObj[4] = {0.5, 0.25, 0.25, 0.5}; glColor4fv( colPlane ); glMaterialfv(GL_FRONT, GL_DIFFUSE , colPlane); glBegin( GL_POLYGON ); glVertex3f( -2.0, 0.0, -2.0 ); glVertex3f( 2.0, 0.0, -2.0 ); glVertex3f( 2.0, 0.0, 2.0 ); glVertex3f( -2.0, 0.0, 2.0 ); glEnd(); glBegin( GL_POLYGON ); glVertex3f( -2.0, 0.0001f, -2.0 ); glVertex3f( -2.0, 0.0001f, 2.0 ); glVertex3f( 2.0, 0.0001f, 2.0 ); glVertex3f( 2.0, 0.0001f, -2.0 ); glEnd(); glColor4fv( colObj ); glMaterialfv(GL_FRONT, GL_DIFFUSE , colObj); glMaterialfv(GL_FRONT, GL_SPECULAR, colObj); // ToDo: draw your shape here and perform the intersection // then call drawHits so you can see where the ray has hit the shape // the origin is in variable 'p' and direction in variable 'dir' shape->DrawTriangles(); //Call HitRecord hr = intersect(pE1, dir); HitRecord *hr = shape->intersect(pE1, dir); drawHits(*hr); endDrawing(); }
void SWLadder::drawObjects(QPainter *pnt) { drawLadder(pnt); drawHits (pnt); }
void SWTrack::drawObjects(QPainter *pnt) { drawHits(pnt); }
// Draws the timer, number of hits, and number of lives left - don't need to draw each separately this way void ScoreBar::drawScoreBar(sf::RenderWindow &window, sf::Clock &clock) { drawHits(window); drawLives(window); drawtimer(window, clock); }