/********************************************************************* * * * FLY * * --E#Y#E-- * * ===MUSCLE=== * * * *********************************************************************/ /* Header Files */ #include "move.h" /* Motor */ char code02; float zylscale1; float zylscale2; float angle2; /* Plane */ float roll1; float pitch1; float yaw1; float xPlane1; float yPlane1; float zPlane1; /* Cockpit */ float viewZ; float rootY; float nightV; float scaPlane; /*-------------------------------------------------------------------------*/ /* Init Color */ struct v_color { float r; float g; float b; float a; }v1; /* Textures Coordinate */ struct v_texture { float s; float t; float p; float q; }v2; /* Init Triangles */ struct v_triangles { float x; float y; float z; float w; }v3; /*---------------------------------------------------------------------------*/ /* Matrix */ float matrixLook(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) { return TRUE; } /*---------------------------------------------------------------------------*/ /* CameraLook */ void CameraLook() { /* X / Y / Z / W */ float vcircle[DC] = { v3.x, 0.0, 0.0, 0.0, 0.0, 0.0,v3.y, 0.0, 0.0, 0.0, 0.0, 0.0,v3.z, 0.0, 0.0, 0.0, 0.0, 0.0,v3.w, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}; /* R / G / B / A */ float vcolor[DC] = { v1.r, 0.0, 0.0, 0.0, 0.0, 0.0,v1.g, 0.0, 0.0, 0.0, 0.0, 0.0,v1.b, 0.0, 0.0, 0.0, 0.0, 0.0,v1.a, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}; /* S / T / P / Q */ float tcircle[DC] = { v2.s, 0.0, 0.0, 0.0, 0.0, 0.0,v2.t, 0.0, 0.0, 0.0, 0.0, 0.0,v2.p, 0.0, 0.0, 0.0, 0.0, 0.0,v2.q, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}; /* X / Y / Z / W */ glLoadMatrixf(vcircle); glMultMatrixf(vcircle); /* R / G / B / A */ glLoadMatrixf(vcolor); glMultMatrixf(vcolor); /* S / T / P / Q */ glLoadMatrixf(tcircle); glMultMatrixf(tcircle); /* Identity */ glLoadIdentity(); glTranslatef(0.0, 0.0, 0.0); /* Camera Look */ gluLookAt(0.0f, 2.0f, 20.0f, 0.0f, 2.0f,-20.0f, 0.0f, 5.0f, 0.0f); } /*---------------------------------------------------------------------------*/ /* PlaneView */ void PlaneView() { /* Rotation */ glRotatef(-roll1, 0.0f, 0.0f, 1.0f); glRotatef(-yaw1, 0.0f, 1.0f, 0.0f); glRotatef(-pitch1, 1.0f, 0.0f, 0.0f); /* Translate */ glTranslatef(-xPlane1, -yPlane1, -zPlane1); } /*---------------------------------------------------------------------------*/ /* Scale Plane */ void ScalePlane() { /* Variables */ const float xScaling = 1.0f; const float yScaling = 1.0f; const float zScaling = 1.0f; /* Scaling */ glScalef(xScaling +scaPlane, yScaling +scaPlane, zScaling +scaPlane); } /*---------------------------------------------------------------------------*/ /* Trans Plane */ void TransPlane() { /* Plane */ float xPlane = 0.0; float yPlane = 0.0; float zPlane = 0.0; /* Achse */ const float vf = 0.0; const float fsin = sin(-vf); const float fcos = cos(-vf); const float fminus = 1.0f - fcos; /* Translate */ glTranslatef(xPlane - 1.0f, yPlane + 1.0f, zPlane + viewZ + 17.499f); /* Translate X */ glTranslatef((xPlane * xPlane) * fminus + fcos, (xPlane * yPlane) * fminus - (zPlane * fsin), (xPlane * zPlane) * fminus + (yPlane * fsin)); /* Translate Y */ glTranslatef((yPlane * xPlane) * fminus + (zPlane * fsin), (yPlane * yPlane) * fminus + fcos, (yPlane * zPlane) * fminus - (xPlane * fsin)); /* Translate Z */ glTranslatef((zPlane * xPlane) * fminus - (yPlane * fsin), (zPlane * yPlane) * fminus + (zPlane * fsin), (zPlane * zPlane) * fminus + fcos); } /*---------------------------------------------------------------------------*/ /* Motor Speed */ void motorSpeed(float dt, float speed, float maxSpeed, float minSpeed) { /* Angle */ angle2 += 25.0f * dt; if(angle2 > 360.0f) { angle2 -= 360.0f; } /* Line */ if(code02) { zylscale1 += speed; zylscale2 -= speed; } else { zylscale1 -= speed; zylscale2 += speed; } /* Limit */ if(zylscale1 >= maxSpeed) { code02 = FALSE; } else if(zylscale1 <= minSpeed) { code02 = TRUE; } } /*---------------------------------------------------------------------------*/ /* Point Grid */ void motorGrid(float dt) { /* Motor */ float speedM = 0.002f; float maxLimit = -0.00f; float minLimit = -0.03f; /* Speed */ motorSpeed(dt, speedM, maxLimit, minLimit); } /*---------------------------------------------------------------------------*/ /* Render Cockpit */ void Motor() { /* PlaneView */ CameraLook(); ScalePlane(); TransPlane(); /* Enable Anti-aliasing */ glEnable(GL_LINE_SMOOTH); /* Size */ glLineWidth(2.0); glPointSize(20.0); /* Raudis */ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_QUADS); glColor4f(0.10f, 0.10f, 0.10f, 1.0f); glVertex3f( -0.4f, -0.399f, -0.1f ); glVertex3f( 0.4f, -0.399f, -0.1f ); glVertex3f( 0.4f, -0.399f, -0.9f ); glVertex3f( -0.4f, -0.399f, -0.9f ); glEnd(); /* 9 Zylinder */ glRotatef(-zylscale1, 0.1f, 0.0f, 0.0f); glRotatef(-zylscale2, 0.1f, 0.0f, 0.0f); glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); glBegin(GL_POINTS); glColor4f(0.30f, 0.30f, 0.30f, 1.0f); glVertex3f( 0.30f, -0.40f -zylscale1, -0.20f ); glVertex3f( 0.00f, -0.37f -zylscale2, -0.20f ); glVertex3f(-0.30f, -0.40f -zylscale1, -0.20f ); glVertex3f( 0.30f, -0.37f -zylscale2, -0.50f ); glVertex3f( 0.00f, -0.40f -zylscale1, -0.50f ); glVertex3f(-0.30f, -0.37f -zylscale2, -0.50f ); glVertex3f( 0.30f, -0.40f -zylscale1, -0.80f ); glVertex3f( 0.00f, -0.37f -zylscale2, -0.80f ); glVertex3f(-0.30f, -0.40f -zylscale1, -0.80f ); glEnd(); /* 3 x 3 Zylinder */ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_TRIANGLES); glColor4f(0.00f, 0.50f, 1.00f, 1.0f); glVertex3f( 0.30f, -0.40f -zylscale1, -0.20f ); glVertex3f( 0.00f, -0.37f -zylscale2, -0.20f ); glVertex3f(-0.30f, -0.40f -zylscale1, -0.20f ); glVertex3f( 0.30f, -0.37f -zylscale2, -0.50f ); glVertex3f( 0.00f, -0.40f -zylscale1, -0.50f ); glVertex3f(-0.30f, -0.37f -zylscale2, -0.50f ); glVertex3f( 0.30f, -0.40f -zylscale1, -0.80f ); glVertex3f( 0.00f, -0.37f -zylscale2, -0.80f ); glVertex3f(-0.30f, -0.40f -zylscale1, -0.80f ); glColor4f( 1.00f, 1.00f, 1.00f, 1.0f); glEnd(); /* Disable Anti-aliasing */ glDisable(GL_LINE_SMOOTH); glFlush(); } /*---------------------------------------------------------------------------*/ /* Render Terminal */ void Terminal() { /* PlaneView */ CameraLook(); TransPlane(); /* Line */ glLineWidth(1.0); glPointSize(15.0); /* Render Cockpit */ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glBegin(GL_QUADS); /* Terminal */ glColor4f( 1.0f, 1.0f, 1.0f, 1.0f); glVertex3f(-2.0f, 20.55f + rootY, 0.5f -viewZ ); glVertex3f( 2.0f, 20.55f + rootY, 0.5f -viewZ ); glVertex3f( 2.0f, 20.50f + rootY, 0.5f -viewZ ); glVertex3f(-2.0f, 20.50f + rootY, 0.5f -viewZ ); glEnd(); /* Render Quads */ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glBegin(GL_QUADS); /* Terminal */ glColor4f( 0.05f, 0.10f, 0.15f, 0.9f); glVertex3f(-2.0f, 20.50f + rootY, 0.5f -viewZ ); glVertex3f( 2.0f, 20.50f + rootY, 0.5f -viewZ ); glVertex3f( 2.0f, 20.55f + rootY, 0.5f -viewZ ); glVertex3f(-2.0f, 20.55f + rootY, 0.5f -viewZ ); glColor4f( 0.0f, 0.0f, 0.0f, 1.0f); glVertex3d(-2.0f, 20.50f + rootY, 0.5f -viewZ ); glVertex3d( 2.0f, 20.50f + rootY, 0.5f -viewZ ); glVertex3d( 2.0f, 21.50f + rootY, 0.5f -viewZ ); glVertex3d(-2.0f, 21.50f + rootY, 0.5f -viewZ ); /* Night Look */ glColor4f( 0.8f, 0.4f, 0.1f, 0.0f -nightV); glVertex3d(-2.0f,-1.0f, 0.5f -viewZ ); glVertex3d( 2.0f,-1.0f, 0.5f -viewZ ); glVertex3d( 2.0f, 1.0f, 0.5f -viewZ ); glVertex3d(-2.0f, 1.0f, 0.5f -viewZ ); glColor4f( 1.00f, 1.00f, 1.00f, 1.0f); glEnd(); /* Disable */ //glDisable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); glFlush(); } /*---------------------------------------------------------------------------*/ /* Process Event */ void process_event2(XEvent report) { KeySym key; key = XLookupKeysym(&report.xkey, 0); /* Keyboard Control Keys */ switch(key) { /* Left / Right / Roll */ case XK_Left: roll1 += sRoll; break; case XK_Right: roll1 -= sRoll; break; /* Up / Down / Pitch */ case XK_Up: pitch1 += sPitch; break; case XK_Down: pitch1 -= sPitch; break; /* e / q / Yaw */ case XK_e: yaw1 += sYaw; break; case XK_q: yaw1 -= sYaw; break; /* a / d / xPlane */ case XK_a: xPlane1 -= sPlaneX; break; case XK_d: xPlane1 += sPlaneX; break; /* w / s / yPlane */ case XK_w: yPlane1 += sPlaneY; break; case XK_s: yPlane1 -= sPlaneY; break; /* b / Space / zPlane */ case XK_b: zPlane1 += sPlaneZ; break; case XK_space: zPlane1 -= sPlaneZ; break; /* x / y / # View */ case XK_x: viewZ = value0; break; case XK_y: viewZ = -value5; break; /* m / n / Night View */ case XK_m: nightV = +value4; break; case XK_n: nightV = -value4; break; /* F1 / F2 / Terminal */ case XK_F1: rootY = -value20; break; case XK_F2: rootY = +value20; break; /* F3 / F4 / Zoom Plane */ case XK_F3: scaPlane = -value1; break; case XK_F4: scaPlane = value0; break; /* ESC / Exit */ case XK_Escape: closeWin(); break; } } /*---------------------------------------------------------------------------*/