View Full Version : rotating VBO about x,y axes

02-17-2014, 07:32 AM
My problem is that the model is not rotating about any recognizable z coordinate. I expect it to rotate about z = ctrz.

Since my data is in a linked list instead of an array, I built the VBO using

i = 0
glBindBuffer(GL_ARRAY_BUFFER, vbobuffers[0]);
gdata = (GLfloat*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
while(data != NULL){
gdata[i] = data->x;
gdata[i+1] = data->y;
gdata[i+2] = data->z;
i += 3;
data = data->next;

then, in the mouse move callback function (dx & dy are the distances the mouse has been dragged)

glTranslatef(ctrx, ctry, ctrz);
glRotatef((theta -90*dx/WindowWidth), 0.0, 1.0, 0.0);
glRotatef((phi -90*dy/WindowHeight), 1.0, 0.0, 0.0);
glDrawArrays(GL_POINTS, 0, cardcount[GRID]);
glRotatef(-(phi -90*dy/WindowHeight), 1.0, 0.0, 0.0);
glRotatef(-(theta -90*dx/WindowWidth), 0.0, 1.0, 0.0);
glTranslatef(-ctrx, -ctry, -ctrz);

This scheme works perfectly when I am panning instead of rotating. It also works perfectly if i'm writing between glBegin() and glEnd().

02-17-2014, 09:10 AM
Incidentally, the ctrz for my current model is ~1000, and the model maximum radius is 710. My VBO rendering appears be rotating about z=0 (?) regardless of translation of ctrz = +/- 1000