k time for my new project:
im going to make a huge plane with grass texture, a small runway, and hell, why not, a small building/tower.
and im going to make it seem like a first person airplane simulation thing, with no hud though.
(as an expiriment, say, with camera)
well, the way camera works is you just move the whole world differantly. right? so when you press left, instead it rotates right, if you press forward, move the world backwards, etc
well, it sounded easy... but, of course, something goes wrong. the turning/rotating works fine and is ok, until i start to move forward/backward, and it seems like its not rotating around me anymore but still the point in the middle.
and it also doesn't move around me anymore, i don't know how it moves.
well, heres my code (again)
the input
Code:
if (keys[VK_UP])
{
xmov -= 0.05f * (float)sin(yrot*pio180);
zmov -= 0.05f * (float)cos(yrot*pio180);
}
if (keys[VK_DOWN])
{
xmov += 0.05f * (float)sin(yrot*pio180);
zmov += 0.05f * (float)cos(yrot*pio180);
}
if (keys[VK_LEFT])
{
yrot-=0.54f;
}
if (keys[VK_RIGHT])
{
yrot+=0.54f;
}
the translating/rotatin
Code:
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity();
glTranslatef(0.0f,0.0f,0.0f);// Reset The View
glTranslatef(-xmov,-ymov,-zmov);
glRotatef(yrot,0.0f,1.0f,0.0f);
glBindTexture(GL_TEXTURE_2D, texture[0]); // the GRASS texture!
glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f); // i have no idea what this does, but it was in the tutorial so i decided to try
glTexCoord2f(0.0f, 0.0f); glVertex3f(-512.0f, -1.0f, -512.0f);
glTexCoord2f(256.0f, 0.0f); glVertex3f(512.0f, -1.0f, -512.0f);
glTexCoord2f(0.0f, 256.0f); glVertex3f(512.0f, -1.0f, 512.0f);
glTexCoord2f(256.0f, 256.0f); glVertex3f(-512.0f, -1.0f, 512.0f);
glEnd();
glBindTexture(GL_TEXTURE_2D, texture[1]); // the concrete/runway texture!
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0f, -0.9f, -10.0f);
glTexCoord2f(64.0f, 0.0f); glVertex3f(10.0f, -0.9f, -10.0f);
glTexCoord2f(0.0f, 64.0f); glVertex3f(10.0f, -0.9f, 128.0f);
glTexCoord2f(64.0f, 64.0f); glVertex3f(-10.0f, -0.9f, 128.0f);
glEnd();
return TRUE; // Keep Going
}