Hello Guest

drawing and movement problems

  • 0 Replies
  • 3959 Views
drawing and movement problems
« on: March 20, 2007, 21:37:08 »
i drew this room where i could navigate in and it works. but then i tried adding a sphere in the middle and whenever i move, the sphere moves with me....

my code looks like this
      GL11.glTranslatef(-cameraPos[0], -cameraPos[1], -cameraPos[2]);
        // This draws my room
        GL11.glPushMatrix();
        {      GL11.glTranslatef(0f, 0f, 0f);
       
           for (int loop_m = 0; loop_m < numTriangles ;loop_m++)
           {   if(loop_m == 0 || loop_m == 1)
                 filter = 0;
              else if(loop_m ==2 || loop_m == 3)
                 filter = 1;
              //else if( loop_m == 5 || loop_m == 6)
              //   filter = 2;
              else
                 filter = 3;
              GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture[filter]);
               if(loop_m != 2 && loop_m != 3)
               {GL11.glBegin(GL11.GL_TRIANGLES);
                   GL11.glNormal3f( 0.0f, 0.0f, 1.0f);
                   x_m = sector1.triangle[loop_m].vertex[0].x;
                   y_m = sector1.triangle[loop_m].vertex[0].y;
                   z_m = sector1.triangle[loop_m].vertex[0].z;
                   u_m = sector1.triangle[loop_m].vertex[0].u;
                   v_m = sector1.triangle[loop_m].vertex[0].v;
                   GL11.glTexCoord2f(u_m,v_m); GL11.glVertex3f(x_m,y_m,z_m);
   
                   x_m = sector1.triangle[loop_m].vertex[1].x;
                   y_m = sector1.triangle[loop_m].vertex[1].y;
                   z_m = sector1.triangle[loop_m].vertex[1].z;
                   u_m = sector1.triangle[loop_m].vertex[1].u;
                   v_m = sector1.triangle[loop_m].vertex[1].v;
                   GL11.glTexCoord2f(u_m,v_m); GL11.glVertex3f(x_m,y_m,z_m);
   
                   x_m = sector1.triangle[loop_m].vertex[2].x;
                   y_m = sector1.triangle[loop_m].vertex[2].y;
                   z_m = sector1.triangle[loop_m].vertex[2].z;
                   u_m = sector1.triangle[loop_m].vertex[2].u;
                   v_m = sector1.triangle[loop_m].vertex[2].v;
                   GL11.glTexCoord2f(u_m,v_m); GL11.glVertex3f(x_m,y_m,z_m);
               GL11.glEnd();
              
               }
              
           }
        }
        GL11.glPopMatrix();
        
            //this draws my sphere
        GL11.glPushMatrix();
        {   GL11.glTranslatef(0f, 0f, 0f);
           GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture[2]);
           ball.draw(0.3f, 16, 16);
        }
        GL11.glPopMatrix();

how can i keep the sphere from moving and have it stay in one spot?