GLvoid OpenGL::DrawRadar(GLvoid) //雷达
{
static float spin=0.0f;
if((int)spin>=360)
{
spin=0.0f;
}
//以下为天空贴图
glLoadIdentity(); //重设投影矩阵
glColor3f(1.0f,1.0f,1.0f); //颜色为白色
glTranslatef(0.0f,0.0f,-30.0f); //向内平移10
glBindTexture(GL_TEXTURE_2D,Texture[6]); //选择天空纹理
glBegin(GL_QUADS);
//顶面
glTexCoord2f(0.0f,0.0f);glVertex3f(-19.0f,15.0f,-0.01f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-19.0f,10.0f,-31.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(19.0f,10.0f,-31.0f);
glTexCoord2f(1.0f,0.0f);glVertex3f(19.0f,15.0f,-0.01f);
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[7]); //选择天空纹理
glBegin(GL_QUADS);
//前面
glTexCoord2f(0.0f,0.0f);glVertex3f(-19.0f,-10.0f,-31.0f);
glTexCoord2f(1.0f,0.0f);glVertex3f(19.0f,-10.0f,-31.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(19.0f,10.0f,-31.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-19.0f,10.0f,-31.0f);
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[8]); //选择天空纹理
glBegin(GL_QUADS);
//左面
glTexCoord2f(0.0f,0.0f);glVertex3f(-19.0f,-15.0f,-0.01f);
glTexCoord2f(1.0f,0.0f);glVertex3f(-19.0f,-10.0f,-31.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(-19.0f,10.0f,-31.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-19.0f,15.0f,-0.01f);
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[9]); //选择天空纹理
glBegin(GL_QUADS);
//右面
glTexCoord2f(1.0f,0.0f);glVertex3f(19.0f,-15.0f,-0.01f);
glTexCoord2f(0.0f,0.0f);glVertex3f(19.0f,-10.0f,-31.0f);
glTexCoord2f(0.0f,1.0f);glVertex3f(19.0f,10.0f,-31.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(19.0f,15.0f,-0.01f);
glEnd();
//以下为大地贴图
glLoadIdentity(); //重设投影矩阵
glColor3f(1.0f,1.0f,1.0f); //颜色为白色
glTranslatef(0.0f,0.0f,-30.0f); //向内平移10
glBindTexture(GL_TEXTURE_2D,Texture[10]); //选择大地纹理
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);glVertex3f(-19.0f,-15.0f,-0.01f);
glTexCoord2f(0.0f,1.0f);glVertex3f(-19.0f,-10.0f,-31.0f);
glTexCoord2f(1.0f,1.0f);glVertex3f(19.0f,-10.0f,-31.0f);
glTexCoord2f(1.0f,0.0f);glVertex3f(19.0f,-15.0f,-0.01f);
glEnd();
//以下为画立方体
glLoadIdentity(); //重设投影矩阵
glTranslatef(0.0f,-7.5f,-30.0f); //向内平移10
glRotatef(225.0f,0.0f,1.0f,0.0f); //自转转spin角度
glBindTexture(GL_TEXTURE_2D,Texture[0]); //选择纹理
glColor3f(1.0f,1.0f,1.0f); //颜色为白色
glBegin(GL_QUADS);
// 前面
glTexCoord2f(0.0f, 0.0f);glVertex3f(-1.0f,-1.0f, 1.0f); //纹理和四边形的左下
glTexCoord2f(1.0f, 0.0f);glVertex3f( 1.0f,-1.0f, 1.0f); //纹理和四边形的右下
glTexCoord2f(1.0f, 1.0f);glVertex3f( 1.0f, 1.0f, 1.0f); //纹理和四边形的右上
glTexCoord2f(0.0f, 1.0f);glVertex3f(-1.0f, 1.0f, 1.0f); //纹理和四边形的左上
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[1]); //选择纹理
glBegin(GL_QUADS);
//后面
glTexCoord2f(1.0f, 0.0f);glVertex3f(-1.0f,-1.0f,-1.0f); //纹理和四边形的右下
glTexCoord2f(1.0f, 1.0f);glVertex3f(-1.0f, 1.0f,-1.0f); //纹理和四边形的右上
glTexCoord2f(0.0f, 1.0f);glVertex3f( 1.0f, 1.0f,-1.0f); //纹理和四边形的左上
glTexCoord2f(0.0f, 0.0f);glVertex3f( 1.0f,-1.0f,-1.0f); //纹理和四边形的左下
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[2]); //选择纹理
glBegin(GL_QUADS);
// 顶面
glTexCoord2f(0.0f, 1.0f);glVertex3f(-1.0f, 1.0f,-1.0f); //纹理和四边形的左上
glTexCoord2f(0.0f, 0.0f);glVertex3f(-1.0f, 1.0f, 1.0f); //纹理和四边形的左下
glTexCoord2f(1.0f, 0.0f);glVertex3f( 1.0f, 1.0f, 1.0f); //纹理和四边形的右下
glTexCoord2f(1.0f, 1.0f);glVertex3f( 1.0f, 1.0f,-1.0f); //纹理和四边形的右上
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[3]); //选择纹理
glBegin(GL_QUADS);
//底面
glTexCoord2f(1.0f, 1.0f);glVertex3f(-1.0f,-1.0f,-1.0f); //纹理和四边形的右上
glTexCoord2f(0.0f, 1.0f);glVertex3f( 1.0f,-1.0f,-1.0f); //纹理和四边形的左上
glTexCoord2f(0.0f, 0.0f);glVertex3f( 1.0f,-1.0f, 1.0f); //纹理和四边形的左下
glTexCoord2f(1.0f, 0.0f);glVertex3f(-1.0f,-1.0f, 1.0f); //纹理和四边形的右下
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[4]); //选择纹理
glBegin(GL_QUADS);
// 右面
glTexCoord2f(1.0f, 0.0f);glVertex3f( 1.0f,-1.0f,-1.0f); //纹理和四边形的右下
glTexCoord2f(1.0f, 1.0f);glVertex3f( 1.0f, 1.0f,-1.0f); //纹理和四边形的右上
glTexCoord2f(0.0f, 1.0f);glVertex3f( 1.0f, 1.0f, 1.0f); //纹理和四边形的左上
glTexCoord2f(0.0f, 0.0f);glVertex3f( 1.0f,-1.0f, 1.0f); //纹理和四边形的左下
glEnd();
glBindTexture(GL_TEXTURE_2D,Texture[5]); //选择纹理
glBegin(GL_QUADS);
// 左面
glTexCoord2f(0.0f, 0.0f);glVertex3f(-1.0f,-1.0f,-1.0f); //纹理和四边形的左下
glTexCoord2f(1.0f, 0.0f);glVertex3f(-1.0f,-1.0f, 1.0f); //纹理和四边形的右下
glTexCoord2f(1.0f, 1.0f);glVertex3f(-1.0f, 1.0f, 1.0f); //纹理和四边形的右上
glTexCoord2f(0.0f, 1.0f);glVertex3f(-1.0f, 1.0f,-1.0f); //纹理和四边形的左上
glEnd();
//以下为画支柱
glTranslatef(0.0f,1.0f,0.0f); //
glRotatef(-90.0f,1.0f,0.0f,0.0f); //绕x轴旋转-90度
glColor3f(1.0f,1.0f,0.0f); //颜色为白色
auxSolidCone(0.5f,2.0f); //辅助库物体实面园锥
//以下为画雷达
glLoadIdentity(); //重设投影矩阵
glTranslatef(0.0f,-3.8f,-30.0f); //位置
glRotatef(spin+=0.05f,0.0f,1.0f,0.0f); //雷达转动
glTranslatef(0.0f,0.0f,-0.7f); //转动轴
glRotatef(45.0f,1.0f,0.0f,0.0f); //绕x轴旋转45度
glColor3f(1.0f,0.0f,1.0f); //颜色为黄色
auxWireCone(2.0f,1.0f); //辅助库物体虚面圆锥
//以下为画导弹
glTranslatef(0.0f,-2.0f,-15.0f); //相对于雷达的位置
glRotatef(-90.0f,0.0f,1.0f,0.0f);
glColor3f(1.0f,0.0f,0.0f); //颜色为红色
auxSolidCone(0.2f,1.5f); //导弹头
}