Esempio n. 1
0
void TQuadraticLengthEvaluator::setQuad(const TQuadratic &quad) {
  const TPointD &p0 = quad.getP0();
  const TPointD &p1 = quad.getP1();
  const TPointD &p2 = quad.getP2();

  TPointD speed0(2.0 * (p1 - p0));
  TPointD accel(2.0 * (p2 - p1) - speed0);

  double a = accel * accel;
  double b = 2.0 * accel * speed0;
  m_c      = speed0 * speed0;

  m_constantSpeed = isAlmostZero(a);  // => b isAlmostZero, too
  if (m_constantSpeed) {
    m_c = sqrt(m_c);
    return;
  }

  m_sqrt_a_div_2 = 0.5 * sqrt(a);

  m_noSpeed0 = isAlmostZero(m_c);  // => b isAlmostZero, too
  if (m_noSpeed0) return;

  m_tRef   = 0.5 * b / a;
  double d = m_c - 0.5 * b * m_tRef;

  m_squareIntegrand = (d < TConsts::epsilon);
  if (m_squareIntegrand) {
    m_f = (b > 0) ? -sq(m_tRef) : sq(m_tRef);
    return;
  }

  m_e = d / a;

  double sqrt_part = sqrt(sq(m_tRef) + m_e);
  double log_arg   = m_tRef + sqrt_part;

  m_squareIntegrand = (log_arg < TConsts::epsilon);
  if (m_squareIntegrand) {
    m_f = (b > 0) ? -sq(m_tRef) : sq(m_tRef);
    return;
  }

  m_primitive_0 = m_sqrt_a_div_2 * (m_tRef * sqrt_part + m_e * log(log_arg));
}
Esempio n. 2
0
void CUI::displayHUD(void)
{
	width = (GLfloat)glutGet(GLUT_WINDOW_WIDTH);
	height = (GLfloat)glutGet(GLUT_WINDOW_HEIGHT);
	glEnable(GL_TEXTURE_2D);
	if (data->drawHUD && data->gameState == PLAYING)
	{
		if (data->camera->speed >= 8.0f)
			glBindTexture(GL_TEXTURE_2D, speed8());
		else if (data->camera->speed >= 6.0f)
			glBindTexture(GL_TEXTURE_2D, speed6());
		else if (data->camera->speed >= 4.0f)
			glBindTexture(GL_TEXTURE_2D, speed4());
		else if (data->camera->speed >= 2.0f)
			glBindTexture(GL_TEXTURE_2D, speed2());
		else
			glBindTexture(GL_TEXTURE_2D, speed0());

		glBegin(GL_QUADS);
		glTexCoord2f(0, 0);
		glVertex2f(10, height-10);
		glTexCoord2f(1, 0);
		glVertex2f(40, height-10);
		glTexCoord2f(1, 1);
		glVertex2f(40, height-110);
		glTexCoord2f(0, 1);
		glVertex2f(10, height-110);
		glEnd();
	}
	if (data->gameState == LOOSE)
	{
		glBindTexture(GL_TEXTURE_2D, loose());
		glBegin(GL_QUADS);
		glColor3f(1.0f, 1.0f, 1.0f);
		glTexCoord2f(1, 1);
		glVertex2f(0, 0);
		glTexCoord2f(1, 0);
		glVertex2f(0, height);
		glTexCoord2f(0, 0);
		glVertex2f(width, height);
		glTexCoord2f(0, 1);
		glVertex2f(width, 0);
		glEnd();

	}
	if (data->gameState == WIN)
	{
		glBindTexture(GL_TEXTURE_2D, win());
		glBegin(GL_QUADS);
		glColor3f(1.0f, 1.0f, 1.0f);
		glTexCoord2f(1, 1);
		glVertex2f(0, 0);
		glTexCoord2f(1, 0);
		glVertex2f(0, height);
		glTexCoord2f(0, 0);
		glVertex2f(width, height);
		glTexCoord2f(0, 1);
		glVertex2f(width, 0);
		glEnd();

	}
	glDisable(GL_TEXTURE_2D);
}