Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: rotating VBO about x,y axes

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    29

    rotating VBO about x,y axes

    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().

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    29
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •