public void Draw(bool inAnimation) { if (inAnimation && Alive) { //projektil Gl.glPushMatrix(); Gl.glColor3ub(255, 255, 0); Gl.glTranslatef(translateX, translateY, translateZ); Gl.glRotatef(-10, 0f, 1.0f, 0f); Gl.glScalef(0.2f, 0.07f, 0.05f); projectile.Draw(id); Gl.glPopMatrix(); } }
public void Draw() { Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glPushMatrix(); Glu.gluLookAt(1.0f, 5.0f, sceneDistance, 1.0f, 3.0f, -4.0f, 0.0f, 4.0f, 0.0f); // Pomeraj objekat po z-osi Gl.glTranslatef(0.0f, 0.0f, -5.0f); Gl.glRotatef(RotationX, 1.0f, 0.0f, 0.0f); Gl.glRotatef(RotationY, 0.0f, 1.0f, 0.0f); //skaliranje texture zemlje Gl.glMatrixMode(Gl.GL_TEXTURE); Gl.glLoadIdentity(); Gl.glScalef(-10.0f, -10.0f, -10.0f); Gl.glMatrixMode(Gl.GL_MODELVIEW); //Zemlja Gl.glPushMatrix(); Gl.glColor3ub(0, 145, 45); // tamno zeleno Gl.glScalef(0.4f, 0.4f, 0.4f); Gl.glBindTexture(Gl.GL_TEXTURE_2D, textureId[(int)TextureObjects.Sand]); Gl.glNormal3f(0.0f, 1f, 0.0f); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f(10.0f, -0.5f, 10.0f); Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f(-10.0f, -0.5f, 10.0f); Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f(-10.0f, -0.5f, -10.0f); Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f(10.0f, -0.5f, -10.0f); Gl.glEnd(); Gl.glPopMatrix(); //vracanje na pocetnu matricu za teksture Gl.glMatrixMode(Gl.GL_TEXTURE); Gl.glLoadIdentity(); Gl.glMatrixMode(Gl.GL_MODELVIEW); //skaliranje texture voda Gl.glMatrixMode(Gl.GL_TEXTURE); Gl.glLoadIdentity(); Gl.glScalef(-10.0f, -10.0f, -10.0f); Gl.glMatrixMode(Gl.GL_MODELVIEW); //Voda Gl.glPushMatrix(); Gl.glColor3ub(0, 0, 45); Gl.glTranslatef(8.0f, 0f, 0.0f); Gl.glScalef(0.4f, 0.4f, 0.4f); Gl.glBindTexture(Gl.GL_TEXTURE_2D, textureId[(int)TextureObjects.Sea]); Gl.glNormal3f(0.0f, 1f, 0.0f); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f(10.0f, -0.5f, 10.0f); Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f(-10.0f, -0.5f, 10.0f); Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f(-10.0f, -0.5f, -10.0f); Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f(10.0f, -0.5f, -10.0f); Gl.glEnd(); Gl.glPopMatrix(); //vracanje na pocetnu matricu za teksture Gl.glMatrixMode(Gl.GL_TEXTURE); Gl.glLoadIdentity(); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_ADD); //Zid 1 Gl.glPushMatrix(); Gl.glColor3ub(100, 5, 0); Gl.glTranslatef(0.1f, 0.3f, 4.4f); Gl.glScalef(0.5f, 0.3f, 0.6f); wall.Draw(textureId[(int)TextureObjects.Brick]); Gl.glPopMatrix(); //Zid 2 Gl.glPushMatrix(); Gl.glColor3ub(100, 5, 0); Gl.glTranslatef(-4.1f, 0.3f, 0.0f); Gl.glScalef(0.5f, 0.3f, 0.6f); Gl.glRotatef(90, 0f, 1.0f, 0f); wall2.Draw(textureId[(int)TextureObjects.Brick]); Gl.glPopMatrix(); //Zid 3 Gl.glPushMatrix(); Gl.glColor3ub(100, 5, 0); Gl.glTranslatef(0.1f, 0.3f, -4.4f); Gl.glScalef(0.5f, 0.3f, 0.6f); wall3.Draw(textureId[(int)TextureObjects.Brick]); Gl.glPopMatrix(); tank.Draw(tankRotation); shipModel.Draw(shipScale, startAnimation); Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_DECAL); Gl.glPopMatrix(); Gl.glPushMatrix(); this.drawTextInfo(); Gl.glPopMatrix(); Gl.glFlush(); }