   Rotating cloud point around its own center
  I have a cloud of point and I want to rotate it around its own center, like rotating model. I've googled for several hours and found lots of simillar solutions, but it still doesn't work. This is my piece of code responisble for drawing:int DrawGLScene(GLvoid){glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear The Screen And The Depth Buffer glPushMatrix();glLoadIdentity();glTranslatef(0.0, 0.0, 0.0);glRotatef(xrot,1.f,0.0f,0.0f);glRotatef(yrot,0.0f,1.f,0.0f);glTranslatef(0.0, 0.0, 0.0); glBegin(GL_POINTS);glColor3f(1.0f, 0.0f, 0.0f);for(int i = 0; i < cloud.size(); ++i){glVertex3f(cloud.x, cloud.y,  cloud.z);}glEnd();glPopMatrix();xrot+=xspeed;yrot+=yspeed;return TRUE;}So the cloud of points comes from the 3D scanner, so the coords of vertexes are huge, so I normalized them by dividing by 1024 (all of them were less than 600 so I have choosen first greater pow of 2)."cloud" is a vector of vertex(class containing 3 floats x,y,x)I would like to have this cloud in the (0,0,0) and rotate around its center, not some circles.
  All rotations occur about the origin (0, 0, 0). You have to move it to the origin (so its center is at 0,0,0), rotate it and then move it back to the original position.Your cloud center is at position x, y, z then you have to do:glTranslatef(-x, -y, -z);glRotatef(...);glTranslatef(x, y, z);   ;  I calculate the center of the cloud with such a function:Vector Center(){float xmin, ymin, zmin, xmax, ymax, zmax;xmin = ymin = zmin = 99999.0f;xmax = ymax = zmax = 0.0f;for(int i = 0; i < cloud.size(); ++i){if(cloud.x < xmin)xmin = cloud.x;if(cloud.y < ymin)ymin = cloud.y;if(cloud.z < zmin)zmin = cloud.z;if(cloud.x > xmax)xmax = cloud.x;if(cloud.y > ymax)ymax = cloud.y;if(cloud.z > zmax)zmax = cloud.z;}Vector center;center.x = (xmin+xmax)/2.0;center.y = (ymin+ymax)/2.0;center.z = (zmin+zmax)/2.0;return center;}I did as you said:glTranslatef(-center.x, -center.y, -center.z);glRotatef(...);glTranslatef(center.x, center.y, center.z);draw all the point int the for loopBut there is still no effect, the cloud is floating on the screen, disappearing on the bottom of screen and appering on the top, and the same situation with left/right rotation.;  What are these lines:glTranslatef(0.0, 0.0, 0.0);Supposed to do?Quote:I did as you said:glTranslatef(-center.x, -center.y, -center.z);glRotatef(...);glTranslatef(center.x, center.y, center.z);draw all the point int the for loopBut there is still no effect, the cloud is floating on the screen, disappearing on the bottom of screen and appering on the top, and the same situation with left/right rotation.It should probably be:glTranslatef(center.x, center.y, center.z);glRotatef(...);glTranslatef(-center.x, -center.y, -center.z);