00001
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "K3dDrawPlane.h"
00035
00037 void K3dDrawPlane::DrawPlanes()
00038 {
00039 for(int i=0; i<m_pGameData->GetPlaneObjSP().GetNum(); i++)
00040 {
00041
00042 K3dPlaneObj *pPlane = m_pGameData->GetPlaneObjSP().Get(i);
00043 if(pPlane->GetIsVisible() == true)
00044 {
00045 glDisable(GL_TEXTURE_2D);
00046 glColor3ubv(pPlane->GetColor()->GetColorArray());
00047 glLineWidth(pPlane->GetWidth());
00048
00049 glDisable(GL_CULL_FACE);
00050
00051 glEnable(GL_BLEND);
00052
00053 glBlendFunc(GL_ONE, GL_ONE);
00054 glPushMatrix();
00055
00056 m_kViewMatrix = *m_pGameData->GetViewMatrix();
00057 m_kModelMatrix = *pPlane->GetMatrix();
00058
00059 m_kViewMatrix.Multiply( m_kModelMatrix);
00060
00061 glLoadMatrixf(m_kViewMatrix.GetMatrix());
00062 glBegin( GL_QUADS );
00063 if(pPlane->GetVertexArray().size() == 4)
00064 {
00065 for(int iVertexId=0; iVertexId < 4; iVertexId++)
00066 {
00067 glVertex3f((GLfloat) pPlane->GetVertexArray()[iVertexId]->GetX(), (GLfloat) pPlane->GetVertexArray()[iVertexId]->GetY(), (GLfloat) pPlane->GetVertexArray()[iVertexId]->GetZ());
00068 }
00069 }
00070 else
00071 {
00072 cerr << "Error in K3dDrawPlane::DrawPlanes() -- Number of plane vertices must be 4 !!!. Current number of vertices are " << pPlane->GetVertexArray().size() << endl;
00073 }
00074 glEnd();
00075 glPopMatrix();
00076 glPushMatrix();
00077
00078 glColor3ub(255,255,0);
00079 glLineWidth(3);
00080 glBegin( GL_LINES );
00081 glVertex3f((GLfloat) pPlane->GetPosition()[0][0], (GLfloat) pPlane->GetPosition()[0][1], (GLfloat) pPlane->GetPosition()[0][2]);
00082 K3dVector3 kNormalPos = *pPlane->GetPosition() + (*pPlane->GetNormal() * pPlane->GetWidth());
00083 glVertex3f((GLfloat) kNormalPos[0], (GLfloat) kNormalPos[1], (GLfloat) kNormalPos[2]);
00084 glEnd();
00085 glLineWidth(1);
00086 glPopMatrix();
00087
00088 glDisable(GL_BLEND);
00089
00090 glEnable(GL_CULL_FACE);
00091
00092 glColor3ub( 255, 255, 255 );
00093 glEnable(GL_TEXTURE_2D);
00094 }
00095 }
00096 }