Why did this happen?

Started by
2 comments, last by SonShadowCat 22 years, 4 months ago
now i made this little scene a while ago involving 2 textured cubes rotating the thing is, in addition to rotating the cubes were going all over the place here is the code
        
  glRotatef( xrotone, 1.0f, 0.0f, 0.0f);  // Rotate on the x axis by xrot

  glRotatef( yrotone, 0.0f, 1.0f, 0.0f);  // Rotate on the y axis by yrot

  glRotatef( zrotone, 0.0f, 0.0f, 1.0f);  // Rotate on the z axis by zrot


  glBindTexture(GL_TEXTURE_2D, texture[0]);  // Select a texture to use


  glBegin(GL_QUADS);  // Start drawing quads

    glNormal3f( 0.0f, 0.0f, 1.0f);  // Light facing viewer

    glTexCoord2f( 0.0f, 1.0f);  // Top left part of texture

    glVertex3f( -1.0f, 1.0f, 0.0f);  // Top left point (front face)

    glTexCoord2f( 0.0f, 0.0f);  // Bottom left part of texture

    glVertex3f( -1.0f, -1.0f, 0.0f);  // Bottom left point (front face)

    glTexCoord2f( 1.0f, 0.0f);  // Bottom right part of point

    glVertex3f( 1.0f, -1.0f, 0.0f);  // Bottom right point (front face)

    glTexCoord2f( 1.0f, 1.0f);  // Top right of texture

    glVertex3f( 1.0f, 1.0f, 0.0f);  // Top right point (front face)


    glNormal3f( 1.0f, 0.0f, 0.0f);  // Light facing right of viewer

    glTexCoord2f( 0.0f, 1.0f);  // Top left part of texture

    glVertex3f( 1.0f, 1.0f, 0.0f);  // Top Left point(right face)

    glTexCoord2f( 0.0f, 0.0f);  // Bottom left part of texture

    glVertex3f( 1.0f, -1.0f, 0.0f);  // Bottom left point (right face)

    glTexCoord2f( 1.0f, 0.0f);  // Bottom right part of point

    glVertex3f( 1.0f, -1.0f, 2.0f);  // Bottom right point (right face)

    glTexCoord2f( 1.0f, 1.0f);  // Top right of texture

    glVertex3f( 1.0f, 1.0f, 2.0f);  // Top right point (right face)


    glNormal3f( 0.0f, 0.0f, -1.0f);  // Light facing away from viewer

    glTexCoord2f( 0.0f, 1.0f);  // Top left part of texture

    glVertex3f( -1.0f, 1.0f, 2.0f);  // Top left point (back face)

    glTexCoord2f( 0.0f, 0.0f);  // Bottom left part of texture

    glVertex3f( -1.0f, -1.0f, 2.0f);  // Bottom left point (back face)

    glTexCoord2f( 1.0f, 0.0f);  // Bottom right part of point

    glVertex3f( 1.0f, -1.0f, 2.0f);  // Bottom right point (back face)

    glTexCoord2f( 1.0f, 1.0f);  // Top right of texture

    glVertex3f( 1.0f, 1.0f, 2.0f);  // Top right point (back face)


    glNormal3f( -1.0f, 0.0f, 0.0f);  // Light facing left of viewer

    glTexCoord2f( 0.0f, 1.0f);  // Top left part of texture

    glVertex3f( -1.0f, 1.0f, 0.0f);  // Top Left point(left face)

    glTexCoord2f( 0.0f, 0.0f);  // Bottom left part of texture

    glVertex3f( -1.0f, -1.0f, 0.0f);  // Bottom left point (left face)

    glTexCoord2f( 1.0f, 0.0f);  // Bottom right part of point

    glVertex3f( -1.0f, -1.0f, 2.0f);  // Bottom right point (left face)

    glTexCoord2f( 1.0f, 1.0f);  // Top right of texture

    glVertex3f( -1.0f, 1.0f, 2.0f);  // Top right point (left face)


    glNormal3f( 0.0f, 1.0f, 0.0f);  // Light facing top of viewer

    glTexCoord2f( 0.0f, 1.0f);  // Top left part of texture

    glVertex3f( 1.0f, 1.0f, 0.0f);  // Top left point (top face)

    glTexCoord2f( 0.0f, 0.0f);  // Bottom left part of texture

    glVertex3f(  1.0f, 1.0f, 2.0f);  // Bottom left point (top face)

    glTexCoord2f( 1.0f, 0.0f);  // Bottom right part of point

    glVertex3f( -1.0f, 1.0f, 2.0f);  // Bottom left point (top face)

    glTexCoord2f( 1.0f, 1.0f);  // Top right of texture

    glVertex3f( -1.0f, 1.0f, 0.0f);  // Top right point (top face)


    glNormal3f( 0.0f, -1.0f, 0.0f);  // Light facing bottom of viewer

    glTexCoord2f( 0.0f, 1.0f);  // Top left part of texture

    glVertex3f( 1.0f, -1.0f, 0.0f);  // Top left point (top face)

    glTexCoord2f( 0.0f, 0.0f);  // Bottom left part of texture

    glVertex3f(  1.0f, -1.0f, 2.0f);  // Bottom left point (top face)

    glTexCoord2f( 1.0f, 0.0f);  // Bottom right part of point

    glVertex3f( -1.0f, -1.0f, 2.0f);  // Bottom left point (top face)

    glTexCoord2f( 1.0f, 1.0f);  // Top right of texture

    glVertex3f( -1.0f, -1.0f, 0.0f);  // Top right point (top face)

  glEnd();
    
this is the code for one of the cubes plz hlp thx "Those who serve no purpose, have no purpose" Edited by - SonShadowCat on January 5, 2002 1:53:33 PM Edited by - SonShadowCat on January 5, 2002 1:53:54 PM Edited by - SonShadowCat on January 5, 2002 1:55:42 PM
--------------------------------- "Those who serve no purpose, have no purpose."- SSC Oh the possibilities!!Edited By - SonShadowCat on Your Girlfriends Birthday
Advertisement
sry, the code didnt show up right( there is alot of space between the code for mine)

"Those who serve no purpose, have no purpose"
--------------------------------- "Those who serve no purpose, have no purpose."- SSC Oh the possibilities!!Edited By - SonShadowCat on Your Girlfriends Birthday
1. Are you translating back so that you can see the cubes correctly?

2. Are you pushing/popping the matrix?

No, HTML is not an OO language.
Try loading the identity matrix each time you draw the scene.

If you''re incrementing the rotation values without reseting the matrix, everything will be rotating from the position the matrix was in last (your second cube).

This topic is closed to new replies.

Advertisement