Пример #1
0
void	ID::Font::TextRender(const char* str, void* font, ID::Color* fg, int x, int y, int z)
{
	int		i;

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D(0, glutGet(GLUT_WINDOW_WIDTH), 0, glutGet(GLUT_WINDOW_HEIGHT));
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();

	glColor3f(fg->r, fg->g, fg->b);
	glRasterPos3i(x, y, z);
	i = 0;
	while (str[i] != 0)
	{
		if (str[i] == '\n')
		{
			y -= 20;
			glRasterPos3i(x, y, z);
		}
		else
			glutBitmapCharacter(font, str[i]);
		++i;
	}

	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
}
void DrawAxes()
{
    //Draw Axes
    glBegin(GL_LINES);
    glEnable(GL_LINE_SMOOTH);
    glColor3d(1.0, 0.0, 0.0); //red
    glVertex3f(0.0f, 0.0f, 0.0f); //x
    glVertex3f(10.0f, 0.0f, 0.0f);
    glColor3d(0.0, 1.0, 0.0); //green
    glVertex3f(0.0f, 0.0f, 0.0f); //y
    glVertex3f(0.0f, 10.0f, 0.0f);
    glColor3d(0.0, 0.0, 1.0); //blue
    glVertex3f(0.0f, 0.0f, 0.0f); //z
    glVertex3f(0.0f, 0.0f, 10.0f);

    //label axes
    void * font = GLUT_BITMAP_HELVETICA_18;
    glColor3d(1.0, 0.0, 0.0); //red
    glRasterPos3i(20.0, 0.0, -1.0);
    glutBitmapCharacter(font, 'X');
    glColor3d(0.0, 1.0, 0.0); //red
    glRasterPos3i(0.0, 20.0, -1.0);
    glutBitmapCharacter(font, 'Y');
    glColor3d(0.0, 0.0, 1.0); //red
    glRasterPos3i(-1.0, 0.0, 20.0);
    glutBitmapCharacter(font, 'Z');
    glEnd();
}
Пример #3
0
// Show text information.
void showText(int x, int y, int z) {
   glDisable(GL_LIGHTING);
   glColor3f(0.0f,0.0f,0.0f); 
   int yOffset = dataWindowHeight;  
   for(int i = 0; i < nMsg; i++) {
      yOffset -= 40;
      glRasterPos3i(x, yOffset, z);  
      glCallLists(strlen((char *) message[i]), GL_BYTE, (char *) message[i]);
      }
   glEnable(GL_LIGHTING);
   }
Пример #4
0
void World::drawScreenText()
{
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // black
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear buffers
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Drawable::WHITE);
	glColor3f(1.0f, 1.0f, 1.0f); // white 

	const unsigned char *uString = (const unsigned char *)(screenText);
	gluLookAt(20, 0, 0, 0, 4, 0, 0, 0, 1);
	glRasterPos3i(0, 0, 0);
	glutBitmapString(GLUT_BITMAP_HELVETICA_18, uString);
}
Пример #5
0
void Sprint( int x, int y, char *st)
{
	int l,i;

	l=strlen( st );
	glRasterPos3i( x, y, -1);
	for( i=0; i < l; i++)
		{
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, st[i]);
	}

}
Пример #6
0
void HUDConsole::putline(const char* s){
  mYCursor -= 20;
  
  int twidth = glutBitmapLength(GLUT_BITMAP_9_BY_15, (const GLubyte*)s);
  
  glColor4f(0.0, 0.0, 0.0, 0.7);
  glRecti(10, mYCursor-5, twidth + 28, mYCursor+15);
  
  glColor4f(1.0, 1.0, 1.0, 1.0);
  glRasterPos3i(18, mYCursor, 0);
  for(const char* p=s; *p; p++)
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *p);
}
Пример #7
0
//-----------------------------------------------------------------------------
//! ワイド文字列の描画
//-----------------------------------------------------------------------------
void  GLFont::DrawStringW(s32 x, s32 y, s32 z, wchar_t* format, ...)
{
	SelectObject(Hdc, Hfont);
	wchar_t buf[256];
	va_list ap;
	int	Length = 0;
	_list = 0;

	// ポインタがNULLの場合は終了
	if( format == NULL )
	{
		return;
	}

	// 文字列変換
	va_start(ap, format);
	vswprintf_s(buf, format, ap);
	va_end(ap);
	
	Length = wcslen(buf);
	_list   = glGenLists(Length);


	

	for( s32 i=0; i<Length; i++ )
	{
		// 文字のビットマップをディスプレイリストとして作成
		wglUseFontBitmapsW(Hdc, buf[i], 1, _list + (DWORD)i );
		/*glNewList(_list + i, GL_COMPILE);
		
		glEndList();*/
	}

	
	glDisable(GL_LIGHTING);		// 文字色を出すために光源を無効化
	// 描画位置の設定
	glRasterPos3i(x, y, z);
	// ディスプレイリストで描画
	for( s32 i=0; i<Length; i++ )
	{
		glCallList( _list+i);
	}
	glEnable(GL_LIGHTING);		// 光源を有効化
	// ディスプレイリスト破棄
	glDeleteLists(_list, Length);
	_list   = 0;
	//Length  = 0;
}
Пример #8
0
void GL_ortho_projection( int width, int height )
{
    if ( height == 0 )
        height = 1;

    glViewport( 0, 0, ( GLint )width, ( GLint )height );

    //
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity( );
    glOrtho( 0, width, 0, height, -1, 1 );

    //
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity ();
    glRasterPos3i( 0, 0, 0 );
    glTranslatef ( 0.375f, 0.375f, 0.f );
}
Пример #9
0
/* draw the helix shape */
void DrawStuff (void) 
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glColor3f (0.8, 0.3, 0.6);

	glPushMatrix ();

	/* set up some matrices so that the object spins with the mouse */
	glTranslatef (0.0,0.0,-300.0);
  glRotatef (rotate_frame[1], 1.0, 0.0, 0.0);
  glRotatef (rotate_frame[0], 0.0, 0.0, 1.0);
  


  //change thread, if necessary
  if (move_end[0] != 0.0 || move_end[1] != 0.0 || tangent_end[0] != 0.0 || tangent_end[1] != 0.0)
  {
    GLdouble model_view[16];
    glGetDoublev(GL_MODELVIEW_MATRIX, model_view);

    GLdouble projection[16];
    glGetDoublev(GL_PROJECTION_MATRIX, projection);

    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);

    
    double winX, winY, winZ;

    //change end positions
    gluProject(positions[1](0), positions[1](1), positions[1](2), model_view, projection, viewport, &winX, &winY, &winZ);
    winX += move_end[0];
    winY += move_end[1];
    move_end[0] = 0.0;
    move_end[1] = 0.0;
    gluUnProject(winX, winY, winZ, model_view, projection, viewport, &positions[1](0), &positions[1](1), &positions[1](2));
//    std::cout << "X: " << positions[1](0) << " Y: " << positions[1](1) << " Z: " << positions[1](2) << std::endl; 

    //change tangents
    gluProject(tangents[1](0), tangents[1](1), tangents[1](2), model_view, projection, viewport, &winX, &winY, &winZ);
    winX += tangent_end[0];
    winY += tangent_end[1];
    tangent_end[0] = 0.0;
    tangent_end[1] = 0.0;
    gluUnProject(winX, winY, winZ, model_view, projection, viewport, &tangents[1](0), &tangents[1](1), &tangents[1](2));
    tangents[1].normalize();

    //change thread
    thread->setConstraints(positions, tangents);
    thread->upsampleAndOptimize_minLength(0.065);



    thread->minimize_energy();


    Point2i start;
    updateIms(start);
    vision_draw.resize(0);
    threadStereo->optimizeThread(vision_draw, start);
    threadStereo->display();

    //std::cout << "objX: " <<objX << " objY: " << objY << " objZ: " << objZ << " winX: " << winX << " winY: " << winY << " winZ: " << winZ << std::endl;
  


  }


  //Draw Axes
	glBegin(GL_LINES);
	glEnable(GL_LINE_SMOOTH);
	glColor3d(1.0, 0.0, 0.0); //red
	glVertex3f(0.0f, 0.0f, 0.0f); //x
	glVertex3f(20.0f, 0.0f, 0.0f);
	glColor3d(0.0, 1.0, 0.0); //green
	glVertex3f(0.0f, 0.0f, 0.0f); //y
	glVertex3f(0.0f, 20.0f, 0.0f);
	glColor3d(0.0, 0.0, 1.0); //blue
	glVertex3f(0.0f, 0.0f, 0.0f); //z
	glVertex3f(0.0f, 0.0f, 20.0f);

	glColor3d(0.5, 0.5, 1.0); 
	glVertex3f(positions[1](0)-positions[0](0), positions[1](1)-positions[0](1), positions[1](2)-positions[0](2)); //z
	glVertex3f(positions[1](0)-positions[0](0)+tangents[1](0)*4.0, positions[1](1)-positions[0](1)+tangents[1](1)*4.0, positions[1](2)-positions[0](2)+tangents[1](2)*4.0); //z


	glEnd( );



  //label axes
  void * font = GLUT_BITMAP_HELVETICA_18;  
  glColor3d(1.0, 0.0, 0.0); //red
  glRasterPos3i(20.0, 0.0, -1.0);
  glutBitmapCharacter(font, 'X');
  glColor3d(0.0, 1.0, 0.0); //red
  glRasterPos3i(0.0, 20.0, -1.0);
  glutBitmapCharacter(font, 'Y');
  glColor3d(0.0, 0.0, 1.0); //red
  glRasterPos3i(-1.0, 0.0, 20.0);
  glutBitmapCharacter(font, 'Z');





  
  //Draw lines from vision
  for (int i=0; i < vision_draw.size(); i++)
  {
    glline_draw_params& currP = vision_draw[i];
    glBegin(GL_LINE_STRIP);
    glColor4f(currP.color[0], currP.color[1], currP.color[2], 1.0);
    for (int j=0; j < currP.size; j++)
    {
      glVertex3f(currP.vertices[j].x-positions[0](0), currP.vertices[j].y-positions[0](1), currP.vertices[j].z-positions[0](2));
    }
    glEnd();
    
  }



  //Draw Thread
  glColor4f (0.5, 0.5, 0.2, 0.5);

	thread->getPoints(points);
	double pts_cpy[NUM_PTS][3];

	for (int i=0; i < NUM_PTS; i++)
	{
		pts_cpy[i][0] = points(i,0)-(double)positions[0](0);
		pts_cpy[i][1] = points(i,1)-(double)positions[0](1);
		pts_cpy[i][2] = points(i,2)-(double)positions[0](2);
	}

	glePolyCone_c4f (NUM_PTS, pts_cpy, 0x0, radii);





	glPopMatrix ();

	glutSwapBuffers ();
}
//***********************************
// pixel manipulations
//***********************************
void performPixelManipulation()
{
    int i;
    GLbyte *pbits = NULL;     //signed 8 bit integer
    GLbyte ptemp;             //
    GLint viewport[4];
    GLenum lastBuffer;
    unsigned long imageSize;

    unsigned int x = 64;
    unsigned int y = 64;
    unsigned int width = 220;   // width of the window
    unsigned int height =180;

    // get the viewport dimensions
    glGetIntegerv(GL_VIEWPORT, viewport);

    // calculate image size (3 components per pixel)
    imageSize = viewport[2] * viewport[3] * 3;

    // allocate memory
    pbits = (GLbyte *) malloc(imageSize);
    if(pbits == NULL)
    {
        printf("Error: couldn't allocate memory in %s!", __func__);
        exit(-1);
    }

    // read the pixels from the buffer
    glPixelStorei(GL_PACK_ALIGNMENT, 1);   //1 byte
    glPixelStorei(GL_PACK_ROW_LENGTH, 0);
    glPixelStorei(GL_PACK_SKIP_ROWS, 0);
    glPixelStorei(GL_PACK_SKIP_PIXELS, 0);

    // save the buffer setting (used for restoration later)
    glGetIntegerv(GL_READ_BUFFER, &lastBuffer);

    // switch to front buffer and read pixels
    glReadBuffer(GL_FRONT);
    glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, pbits);

    // restore buffer
    glReadBuffer(lastBuffer);

    // run through the pixels for modification
    for(i = 0; i < imageSize; i = i+3)
    {
        //ptemp = 0.333*(pbits[i] + pbits[i+1] + pbits[i+2]);   //rgb to grey scale

        //if (ptemp < 0) ptemp = abs(ptemp);  //has to check this out
        //pbits[i+2] = 0; //b
        pbits[i+1] = 0; //g

        //pbits[i]   = ptemp;  //r
        //pbits[i+1] = ptemp; //g
        //pbits[i+2] = ptemp; //b
    }

    // save buffer setting
    glGetIntegerv(GL_READ_BUFFER, &lastBuffer);

    // write pixels
    glReadBuffer(GL_FRONT);
    glRasterPos3i(x, 0, y); // offset
    glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, pbits);

    // restore buffer
    glReadBuffer(lastBuffer);
}
Пример #11
0
void setTextPosition ( int x, int y )
{
  glRasterPos3i( x, y, 1 );
}
Пример #12
0
M(void, glRasterPos3i, jint x, jint y, jint z) {
	glRasterPos3i(x, y, z);
}
Пример #13
0
static void Draw(void)
{
    GLint i, j;

    glClear(GL_COLOR_BUFFER_BIT);

    for (i = 0; i < 7; i++) {
	for (j = 0; j < 40; j++) {
	    switch (j % 7) {
	      case 0:
		(rgb) ? glColor3f(1.0, 0.0, 0.0) : glIndexi(1);
		break;
	      case 1:
		(rgb) ? glColor3f(0.0, 1.0, 0.0) : glIndexi(2);
		break;
	      case 2:
		(rgb) ? glColor3f(1.0, 1.0, 0.0) : glIndexi(3);
		break;
	      case 3:
		(rgb) ? glColor3f(0.0, 0.0, 1.0) : glIndexi(4);
		break;
	      case 4:
		(rgb) ? glColor3f(1.0, 0.0, 1.0) : glIndexi(5);
		break;
	      case 5:
		(rgb) ? glColor3f(0.0, 1.0, 1.0) : glIndexi(6);
		break;
	      case 6:
		(rgb) ? glColor3f(1.0, 1.0, 1.0) : glIndexi(7);
		break;
	    }
	    glRasterPos3i((j*3)%5, (j*3)%8, 0);

	    if (useLists) {
	    	glCallList(exp_lists[i]); 
	    } else {
		glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]);
	    }

	    if (doubleBuffer) {
		glutSwapBuffers();
	    } else {
		glFlush();
	    }

	    if (!abuse) {
		break;
	    }
	}

	if (i == 6) {
	    break;
	}

	for (j = 0; j < 40; j++) {
	    (rgb) ? glColor3f(0.0, 0.0, 0.0) : glIndexi(0);
	    glRasterPos3i((j*3)%5, (j*3)%8, 0);
	    if (useLists) {
		glCallList(exp_lists[i]); 
	    } else {
		glBitmap(80, 80, 40.0, 40.0, 0.0, 0.0, exp_bits[i]);
	    }
	    if (doubleBuffer) {
		glutSwapBuffers();
	    } else {
		glFlush();
	    }
	    if (!abuse) {
		break;
	    }
	}
    }
}
Пример #14
0
/* draw the helix shape */
void DrawStuff (void)
{
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3f (0.8, 0.3, 0.6);

    glPushMatrix ();

  /* set up some matrices so that the object spins with the mouse */
    glTranslatef (0.0,0.0,-150.0);
    glRotatef (rotate_frame[1], 1.0, 0.0, 0.0);
    glRotatef (rotate_frame[0], 0.0, 0.0, 1.0);


  //change thread, if necessary
    if (move_end[0] != 0.0 || move_end[1] != 0.0 || tangent_end[0] != 0.0 || tangent_end[1] != 0.0 || tangent_rotation_end[0] != 0 || tangent_rotation_end[1] != 0)
    {
        GLdouble model_view[16];
        glGetDoublev(GL_MODELVIEW_MATRIX, model_view);

        GLdouble projection[16];
        glGetDoublev(GL_PROJECTION_MATRIX, projection);

        GLint viewport[4];
        glGetIntegerv(GL_VIEWPORT, viewport);


        double winX, winY, winZ;


    //change end positions
        Vector3d new_end_pos;
        gluProject(positions[1](0), positions[1](1), positions[1](2), model_view, projection, viewport, &winX, &winY, &winZ);
        winX += move_end[0];
        winY += move_end[1];
        move_end[0] = 0.0;
        move_end[1] = 0.0;
        gluUnProject(winX, winY, winZ, model_view, projection, viewport, &new_end_pos(0), &new_end_pos(1), &new_end_pos(2));
    //    std::cout << "X: " << positions[1](0) << " Y: " << positions[1](1) << " Z: " << positions[1](2) << std::endl;

    //change tangents
        Vector3d new_end_tan;
        gluProject(positions[1](0)+tangents[1](0),positions[1](1)+tangents[1](1), positions[1](2)+tangents[1](2), model_view, projection, viewport, &winX, &winY, &winZ);
        winX += tangent_end[0];
        winY += tangent_end[1];
        tangent_end[0] = 0.0;
        tangent_end[1] = 0.0;
        gluUnProject(winX, winY, winZ, model_view, projection, viewport, &new_end_tan(0), &new_end_tan(1), &new_end_tan(2));
        new_end_tan -= positions[1];
        new_end_tan.normalize();

        positions[1] = new_end_pos;

        Matrix3d rotation_new_tan;
        rotate_between_tangents(tangents[1], new_end_tan, rotation_new_tan);
        rotations[1] = rotation_new_tan*rotations[1];


    //check rotation around tangent
        Vector3d tangent_normal_rotate_around = rotations[1].col(1);
        Vector3d new_end_tan_normal;
        gluProject(positions[1](0)+tangent_normal_rotate_around(0), positions[1](1)+tangent_normal_rotate_around(1), positions[1](2)+tangent_normal_rotate_around(2), model_view, projection, viewport, &winX, &winY, &winZ);
        winX += tangent_rotation_end[0];
        winY += tangent_rotation_end[1];
        tangent_rotation_end[0] = 0.0;
        tangent_rotation_end[1] = 0.0;
        gluUnProject(winX, winY, winZ, model_view, projection, viewport, &new_end_tan_normal(0), &new_end_tan_normal(1), &new_end_tan_normal(2));
        new_end_tan_normal -= positions[1];
    //project this normal onto the plane normal to X (to ensure Y stays normal to X)
        new_end_tan_normal -= new_end_tan_normal.dot(rotations[1].col(0))*rotations[1].col(0);
        new_end_tan_normal.normalize();


        rotations[1].col(1) = new_end_tan_normal;
        rotations[1].col(2) = rotations[1].col(0).cross(new_end_tan_normal);

    //change thread
        thread->set_constraints(positions[0], rotations[0], positions[1], rotations[1]);
    //thread->set_end_constraint(positions[1], rotations[1]);

    //std::cout <<"CONSTRAINT END:\n" << rotations[1] << std::endl;
        thread->minimize_energy();
        updateThreadPoints();
        findThreadInIms();


    //std::cout <<"ACTUAL END:\n" << thread->end_rot() << std::endl;

    //std::cout << "objX: " <<objX << " objY: " << objY << " objZ: " << objZ << " winX: " << winX << " winY: " << winY << " winZ: " << winZ << std::endl;



    }


  //Draw Axes
    glBegin(GL_LINES);
    glEnable(GL_LINE_SMOOTH);
    glColor3d(1.0, 0.0, 0.0); //red
    glVertex3f(0.0f, 0.0f, 0.0f); //x
    glVertex3f(10.0f, 0.0f, 0.0f);
    glColor3d(0.0, 1.0, 0.0); //green
    glVertex3f(0.0f, 0.0f, 0.0f); //y
    glVertex3f(0.0f, 10.0f, 0.0f);
    glColor3d(0.0, 0.0, 1.0); //blue
    glVertex3f(0.0f, 0.0f, 0.0f); //z
    glVertex3f(0.0f, 0.0f, 10.0f);

/*  glColor3d(0.5, 0.5, 1.0);
glVertex3f(positions[1](0)-positions[0](0), positions[1](1)-positions[0](1), positions[1](2)-positions[0](2)); //z
glVertex3f(positions[1](0)-positions[0](0)+tangents[1](0)*4.0, positions[1](1)-positions[0](1)+tangents[1](1)*4.0, positions[1](2)-positions[0](2)+tangents[1](2)*4.0); //z
*/


  //Draw Axes at End
Vector3d diff_pos = positions[1]-positions[0];
double rotation_scale_factor = 10.0;
Matrix3d rotations_project = rotations[1]*rotation_scale_factor;
glBegin(GL_LINES);
glEnable(GL_LINE_SMOOTH);
glColor3d(1.0, 0.0, 0.0); //red
glVertex3f((float)diff_pos(0), (float)diff_pos(1), (float)diff_pos(2)); //x
glVertex3f((float)(diff_pos(0)+rotations_project(0,0)), (float)(diff_pos(1)+rotations_project(1,0)), (float)(diff_pos(2)+rotations_project(2,0)));
glColor3d(0.0, 1.0, 0.0); //green
glVertex3f((float)diff_pos(0), (float)diff_pos(1), (float)diff_pos(2)); //y
glVertex3f((float)(diff_pos(0)+rotations_project(0,1)), (float)(diff_pos(1)+rotations_project(1,1)), (float)(diff_pos(2)+rotations_project(2,1)));
glColor3d(0.0, 0.0, 1.0); //blue
glVertex3f((float)diff_pos(0), (float)diff_pos(1), (float)diff_pos(2)); //z
glVertex3f((float)(diff_pos(0)+rotations_project(0,2)), (float)(diff_pos(1)+rotations_project(1,2)), (float)(diff_pos(2)+rotations_project(2,2)));


glEnd( );



  //label axes
void * font = GLUT_BITMAP_HELVETICA_18;
glColor3d(1.0, 0.0, 0.0); //red
glRasterPos3i(20.0, 0.0, -1.0);
glutBitmapCharacter(font, 'X');
glColor3d(0.0, 1.0, 0.0); //red
glRasterPos3i(0.0, 20.0, -1.0);
glutBitmapCharacter(font, 'Y');
glColor3d(0.0, 0.0, 1.0); //red
glRasterPos3i(-1.0, 0.0, 20.0);
glutBitmapCharacter(font, 'Z');


addThreadDebugInfo();



  //Draw Thread
glColor4f (0.5, 0.5, 0.2, 0.5);

  /*
  double pts_cpy[points.size()][3];
  double twist_cpy[points.size()];
  pts_cpy[0][0] = 0.0;
  pts_cpy[0][1] = 0.0;
  pts_cpy[0][2] = 0.0;
  twist_cpy[0] = -(360.0/(2.0*M_PI))*twist_angles[0];
  //std::cout << twist_cpy[0] << std::endl;

for (int i=1; i < points.size(); i++)
{
pts_cpy[i][0] = points[i](0)-(double)positions[0](0);
pts_cpy[i][1] = points[i](1)-(double)positions[0](1);
pts_cpy[i][2] = points[i](2)-(double)positions[0](2);
twist_cpy[i] = -(360.0/(2.0*M_PI))*twist_angles[i];
//std::cout << twist_cpy[i] << std::endl;
}

gleTwistExtrusion(20,
contour,
contour_norms,
NULL,
points.size(),
pts_cpy,
0x0,
twist_cpy);
*/


double pts_cpy[points.size()+2][3];
double twist_cpy[points.size()+2];
pts_cpy[1][0] = 0.0;
pts_cpy[1][1] = 0.0;
pts_cpy[1][2] = 0.0;
twist_cpy[1] = -(360.0/(2.0*M_PI))*twist_angles[0];
  //std::cout << twist_cpy[0] << std::endl;

for (int i=1; i < points.size()-1; i++)
{
    pts_cpy[i+1][0] = points[i](0)-(double)positions[0](0);
    pts_cpy[i+1][1] = points[i](1)-(double)positions[0](1);
    pts_cpy[i+1][2] = points[i](2)-(double)positions[0](2);
    twist_cpy[i+1] = -(360.0/(2.0*M_PI))*twist_angles[i];
    //std::cout << twist_cpy[i+1] - twist_cpy[i] << std::endl;
}

  //add first and last point
pts_cpy[0][0] = -rotations[0](0,0);
pts_cpy[0][1] = -rotations[0](1,0);
pts_cpy[0][2] = -rotations[0](2,0);
twist_cpy[0] = -(360.0/(2.0*M_PI))*twist_angles[0];

pts_cpy[points.size()][0] = (double)positions[1](0)-(double)positions[0](0);
pts_cpy[points.size()][1] = (double)positions[1](1)-(double)positions[0](1);
pts_cpy[points.size()][2] = (double)positions[1](2)-(double)positions[0](2);
twist_cpy[points.size()] = twist_cpy[points.size()-1];


pts_cpy[points.size()+1][0] = pts_cpy[points.size()][0]+rotations[1](0,0);
pts_cpy[points.size()+1][1] = pts_cpy[points.size()][1]+rotations[1](1,0);
pts_cpy[points.size()+1][2] = pts_cpy[points.size()][2]+rotations[1](2,0);
twist_cpy[points.size()+1] = twist_cpy[points.size()];

gleTwistExtrusion_c4f(20,
    contour,
    contour_norms,
    NULL,
    points.size()+2,
    pts_cpy,
    0x0,
    twist_cpy);



glPopMatrix ();

glutSwapBuffers ();

thread_vision.display();

}
Пример #15
0
template< > inline void glRasterPos3< int >			( int x, int y, int z )			{	glRasterPos3i(x,y,z);	};
Пример #16
0
/* draw the helix shape */
void DrawStuff (void)
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glColor3f (0.8, 0.3, 0.6);

	glPushMatrix ();

	/* set up some matrices so that the object spins with the mouse */
	glTranslatef (0.0,0.0,-300.0);
  glRotatef (rotate_frame[1], 1.0, 0.0, 0.0);
  glRotatef (rotate_frame[0], 0.0, 0.0, 1.0);


  //change thread, if necessary
  if (traj_mode == PLAYBACK)// && trajectory_play_back_ind < trajectory.size())
  {
    /*
    Thread_Motion nextMotion;
    traj_reader.get_next_motion(nextMotion);
    positions[1] += nextMotion.pos_movement;
    tangents[1] = nextMotion.tan_rotation*tangents[1];

    //change thread
    thread->setConstraints(positions, tangents);
    //thread->upsampleAndOptimize_minLength(0.065);

    thread->minimize_energy_fixedPieces();
    */
  }
   else if (move_end[0] != 0.0 || move_end[1] != 0.0 || tangent_end[0] != 0.0 || tangent_end[1] != 0.0)
  {
    GLdouble model_view[16];
    glGetDoublev(GL_MODELVIEW_MATRIX, model_view);

    GLdouble projection[16];
    glGetDoublev(GL_PROJECTION_MATRIX, projection);

    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);


    double winX, winY, winZ;

    //change end positions
    Vector3d new_end_pos;
    gluProject(positions[1](0), positions[1](1), positions[1](2), model_view, projection, viewport, &winX, &winY, &winZ);
    winX += move_end[0];
    winY += move_end[1];
    move_end[0] = 0.0;
    move_end[1] = 0.0;
    gluUnProject(winX, winY, winZ, model_view, projection, viewport, &new_end_pos(0), &new_end_pos(1), &new_end_pos(2));
//    std::cout << "X: " << positions[1](0) << " Y: " << positions[1](1) << " Z: " << positions[1](2) << std::endl;

    //change tangents
    Vector3d new_end_tan;
    gluProject(tangents[1](0), tangents[1](1), tangents[1](2), model_view, projection, viewport, &winX, &winY, &winZ);
    winX += tangent_end[0];
    winY += tangent_end[1];
    tangent_end[0] = 0.0;
    tangent_end[1] = 0.0;
    gluUnProject(winX, winY, winZ, model_view, projection, viewport, &new_end_tan(0), &new_end_tan(1), &new_end_tan(2));
    new_end_tan.normalize();




    if (traj_mode == RECORD)
    {
      traj_recorder.add_motion_to_list(positions[1], new_end_pos, tangents[1], new_end_tan);
    }

    positions[1] = new_end_pos;
    tangents[1] = new_end_tan;


    //change thread
    thread->setConstraints(positions, tangents);
    //thread->upsampleAndOptimize_minLength(0.065);

    thread->minimize_energy_fixedPieces();



    //std::cout << "objX: " <<objX << " objY: " << objY << " objZ: " << objZ << " winX: " << winX << " winY: " << winY << " winZ: " << winZ << std::endl;



  }


  //Draw Axes
	glBegin(GL_LINES);
	glEnable(GL_LINE_SMOOTH);
	glColor3d(1.0, 0.0, 0.0); //red
	glVertex3f(0.0f, 0.0f, 0.0f); //x
	glVertex3f(20.0f, 0.0f, 0.0f);
	glColor3d(0.0, 1.0, 0.0); //green
	glVertex3f(0.0f, 0.0f, 0.0f); //y
	glVertex3f(0.0f, 20.0f, 0.0f);
	glColor3d(0.0, 0.0, 1.0); //blue
	glVertex3f(0.0f, 0.0f, 0.0f); //z
	glVertex3f(0.0f, 0.0f, 20.0f);

	glColor3d(0.5, 0.5, 1.0);
	glVertex3f(positions[1](0)-positions[0](0), positions[1](1)-positions[0](1), positions[1](2)-positions[0](2)); //z
	glVertex3f(positions[1](0)-positions[0](0)+tangents[1](0)*4.0, positions[1](1)-positions[0](1)+tangents[1](1)*4.0, positions[1](2)-positions[0](2)+tangents[1](2)*4.0); //z


	glEnd( );



  //label axes
  void * font = GLUT_BITMAP_HELVETICA_18;
  glColor3d(1.0, 0.0, 0.0); //red
  glRasterPos3i(20.0, 0.0, -1.0);
  glutBitmapCharacter(font, 'X');
  glColor3d(0.0, 1.0, 0.0); //red
  glRasterPos3i(0.0, 20.0, -1.0);
  glutBitmapCharacter(font, 'Y');
  glColor3d(0.0, 0.0, 1.0); //red
  glRasterPos3i(-1.0, 0.0, 20.0);
  glutBitmapCharacter(font, 'Z');




  //Draw Thread
  glColor3f (0.5, 0.5, 0.2);

	thread->getPoints(points);
	double pts_cpy[NUM_PTS][3];

	for (int i=0; i < NUM_PTS; i++)
	{
		pts_cpy[i][0] = points(i,0)-(double)positions[0](0);
		pts_cpy[i][1] = points(i,1)-(double)positions[0](1);
		pts_cpy[i][2] = points(i,2)-(double)positions[0](2);
	}
	glePolyCone (NUM_PTS, pts_cpy, 0x0, radii);





	glPopMatrix ();

	glutSwapBuffers ();
}
Пример #17
0
/////////////////////////////////////////////////////////
// Render
//
void GEMglRasterPos3i :: render(GemState *state) {
	glRasterPos3i (x, y, z);
}