// Gets the three coefficients of a plane equation given three points on the plane. void gltGetPlaneEquation(GLTVector3 vPoint1, GLTVector3 vPoint2, GLTVector3 vPoint3, GLTVector3 vPlane) { // Get normal vector from three points. The normal vector is the first three coefficients // to the plane equation... gltGetNormalVector(vPoint1, vPoint2, vPoint3, vPlane); // Final coefficient found by back substitution vPlane[3] = -(vPlane[0] * vPoint3[0] + vPlane[1] * vPoint3[1] + vPlane[2] * vPoint3[2]); }
void DrawJet() { GLTVector3 vNormal; // Storeage for calculated surface normal glColor3ub(128,128,128); glBegin(GL_TRIANGLES); //front bottom glNormal3f(0.0f, -1.0f, 0.0f); // glVertex3f(0.0f, 0.0f, 60.0f); // glVertex3f(-15.0f, 0.0f, 30.0f); // glVertex3f(15.0f,0.0f,30.0f); // //¡÷ºÆ√≥∏Æ ¡¶∞≈ //Right Winng GLTVector3 vPoints[3] = {{ 15.0f, 0.0f, 30.0f}, { 0.0f, 15.0f, 30.0f}, { 0.0f, 0.0f, 60.0f}}; // Calculate the normal for the plane gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); { GLTVector3 vPoints[3] = {{ 0.0f, 0.0f, 60.0f }, { 0.0f, 15.0f, 30.0f }, { -15.0f, 0.0f, 30.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } // Body of the Plane //////////////////////// { GLTVector3 vPoints[3] = {{ -15.0f, 0.0f, 30.0f }, { 0.0f, 15.0f, 30.0f }, { 0.0f, 0.0f, -56.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{ 0.0f, 0.0f, -56.0f }, { 0.0f, 15.0f, 30.0f }, { 15.0f,0.0f,30.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(15.0f,0.0f,30.0f); glVertex3f(-15.0f, 0.0f, 30.0f); glVertex3f(0.0f, 0.0f, -56.0f); /////////////////////////////////////////////// // Left wing // Large triangle for bottom of wing { GLTVector3 vPoints[3] = {{ 0.0f,2.0f,27.0f }, { -60.0f, 2.0f, -8.0f }, { 60.0f, 2.0f, -8.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{ 60.0f, 2.0f, -8.0f}, {0.0f, 7.0f, -8.0f}, {0.0f,2.0f,27.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{60.0f, 2.0f, -8.0f}, {-60.0f, 2.0f, -8.0f}, {0.0f,7.0f,-8.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{0.0f,2.0f,27.0f}, {0.0f, 7.0f, -8.0f}, {-60.0f, 2.0f, -8.0f}}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } // Tail section/////////////////////////////// // Bottom of back fin glNormal3f(0.0f, -1.0f, 0.0f); glVertex3f(-30.0f, -0.50f, -57.0f); glVertex3f(30.0f, -0.50f, -57.0f); glVertex3f(0.0f,-0.50f,-40.0f); { GLTVector3 vPoints[3] = {{ 0.0f,-0.5f,-40.0f }, {30.0f, -0.5f, -57.0f}, {0.0f, 4.0f, -57.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{ 0.0f, 4.0f, -57.0f }, { -30.0f, -0.5f, -57.0f }, { 0.0f,-0.5f,-40.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{ 30.0f,-0.5f,-57.0f }, { -30.0f, -0.5f, -57.0f }, { 0.0f, 4.0f, -57.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{ 0.0f,0.5f,-40.0f }, { 3.0f, 0.5f, -57.0f }, { 0.0f, 25.0f, -65.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{ 0.0f, 25.0f, -65.0f }, { -3.0f, 0.5f, -57.0f}, { 0.0f,0.5f,-40.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } { GLTVector3 vPoints[3] = {{ 3.0f,0.5f,-57.0f }, { -3.0f, 0.5f, -57.0f }, { 0.0f, 25.0f, -65.0f }}; gltGetNormalVector(vPoints[0], vPoints[1], vPoints[2], vNormal); glNormal3fv(vNormal); glVertex3fv(vPoints[0]); glVertex3fv(vPoints[1]); glVertex3fv(vPoints[2]); } glEnd(); }
void Lighting::gltGetPlaneEquation(GLTVector3 vPoint1, GLTVector3 vPoint2, GLTVector3 vPoint3, GLTVector3 vPlane) { gltGetNormalVector(vPoint1, vPoint2, vPoint3, vPlane); vPlane[3] = -(vPlane[0] * vPoint3[0] + vPlane[1] * vPoint3[1] + vPlane[2] * vPoint3[2]); }