• Advertisement

Archived

This topic is now archived and is closed to further replies.

Why did this happen?

This topic is 5861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

  • Advertisement