PDA

View Full Version : rotating VBO about x,y axes



wmelgaard
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;
}
glUnmapBuffer(GL_ARRAY_BUFFER);

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

glColor3fv(color[32]);
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);
glBindBuffer(GL_ARRAY_BUFFER,vbobuffers[i]);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_POINTS, 0, cardcount[GRID]);
glDisableClientState(GL_VERTEX_ARRAY);
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().

wmelgaard
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