void ofxMarchingCubes::debugDraw(){
	glColor3f(1.0f, 1.0f, 1.0f);
	drawFilled();
	glLineWidth(2.0f);
	glColor3f(0.0f, 0.0f, 0.0f);
	drawWireFrame();
	drawCube();
	//drawGrid();
}
Esempio n. 2
0
void
drawScene(void)
{

  int i;
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LEQUAL);

  glClearColor(0.0, 0.0, 0.0, 0.0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();

  glRotatef(ax, 1.0, 0.0, 0.0);
  glRotatef(-ay, 0.0, 1.0, 0.0);

  /* all the good stuff follows */

  if (stencilOn) {
    glEnable(GL_STENCIL_TEST);
    glClear(GL_STENCIL_BUFFER_BIT);
    glStencilMask(1);
    glStencilFunc(GL_ALWAYS, 0, 1);
    glStencilOp(GL_INVERT, GL_INVERT, GL_INVERT);
  }
  glColor3f(1.0, 1.0, 0.0);
  for (i = 0; i < 6; i++) {
    drawWireframe(i);
    if (stencilOn) {
      glStencilFunc(GL_EQUAL, 0, 1);
      glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
    }
    glColor3f(0.0, 0.0, 0.0);
    drawFilled(i);

    glColor3f(1.0, 1.0, 0.0);
    if (stencilOn) {
      glStencilFunc(GL_ALWAYS, 0, 1);
      glStencilOp(GL_INVERT, GL_INVERT, GL_INVERT);
    }
    glColor3f(1.0, 1.0, 0.0);
    drawWireframe(i);
  }
  glPopMatrix();

  if (stencilOn)
    glDisable(GL_STENCIL_TEST);

  /* end of good stuff */

  glutSwapBuffers();
}
Esempio n. 3
0
  void Arrow::draw ( const Point& from, const Point& to ) const
  {
    Vector v = to - from;
    double length = v.length();
    Vector n = v;
    n.normalize();
    Vector x( 1, 0, 0 );	// Canonical direction for drawing the arrow
    double theta = n * x;
    Vector r = x.cross( v ); // Rotation vector
    double rl = r.length();
    if ( fabs( rl ) > 1e-6 )
      r.normalize();
    else
      r = Vector( 0, 0, 1 );	// theta == 0 anyway

    // Also, figure out how to rotate the arrow head so that it is
    // normal to the view normal, i.e., so you can always see the side
    // of the arrow head. Start by applying the orienting rotation to
    // the canonical arrow head normal.
    Matrix m( Matrix::ROTATION, r[X], r[Y], r[Z], -acos( theta ) );
    Vector z( 0, 0, 1 );// Canonical arrow head normal
    Vector zr = m * z;
    Vector y( 0, 1, 0 );//The "other" direction (in the plane of n)
    Vector yr = m * y;
    double dz = zr * view_normal_;
    double dy = yr * view_normal_;
    double phi = atan2( dy, dz );

    glPushMatrix();

    glTranslated( from[X], from[Y], from[Z] );
    glRotated( -180 * phi / M_PI, n[X], n[Y], n[Z] );
    glRotated( 180 * acos( theta ) / M_PI, r[X], r[Y], r[Z] );

    switch ( style_ ) {
    case lC::OPEN:
      drawOpen( length ); break;
    case lC::HOLLOW:
      drawHollow( length ); break;
    case lC::FILLED:
      drawFilled( length ); break;
    }

    glPopMatrix();
  }
Esempio n. 4
0
  void Arrow::draw ( const Point& from, const Point& to ) const
  {
    Vector v = to - from;
    double theta = v.orientation();
    double length = v.length();

    glPushMatrix();

    glTranslated( from.p_[X], from.p_[Y], 0. );
    glRotated( theta, 0., 0., 1. );

    switch ( style_ ) {
    case lC::OPEN:
      drawOpen( length ); break;
    case lC::HOLLOW:
      drawHollow( length ); break;
    case lC::FILLED:
      drawFilled( length ); break;
    }

    glPopMatrix();
  }