91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 453KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-06
  • 語言: 其他
  • 標(biāo)簽:

資源簡介

完成一個簡單的日地月系統(tǒng)演示程序。要求必須考慮太陽的自轉(zhuǎn)、地球 和月亮的公轉(zhuǎn)和自轉(zhuǎn);能夠演示地球上的白天黑夜和四季變化,以及月亮的圓缺效果。為了增強(qiáng)演示效果,請繪制出太陽、地球和月亮的經(jīng)緯線、赤道和軸線。為了增強(qiáng)真實(shí)感,請?jiān)谔枴⒌厍颉⒃铝恋谋砻媸褂煤线m的紋理。 紋理貼圖部分做的不太好。

資源截圖

代碼片段和文件信息

#include??
#include??
#include?
#include?
#include?
#ifndef?GL_BGR_EXT
#include?
#endif

float?sun?=0;
float?year?=?0;
float?month?=0;
float?day?=0;
GLuint?texSun;
GLuint?texPlanet;
GLuint?texMoon;

GLuint??Texture(const?char?*FileName)
{

FILE?*file?=fopen(FileName?“rb“);
fseek(filesizeof(BITMAPFILEHEADER)SEEK_SET);
BITMAPINFOHEADER?info;
fread(&info?sizeof(info)1file);
long?Width=info.biWidth;
long?Height=info.biHeight;
GLubyte*?pixels;
pixels?=?(GLubyte*)malloc(Width*Height*3);
fread(pixelsWidth*Height*31file);
fclose(file);
glTexImage2D(GL_TEXTURE_2D03WidthHeight0GL_BGR_EXTGL_UNSIGNED_BYTEpixels);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
// glEnable(GL_TEXTURE_2D);
}

void?Keyboard(unsigned?char?keyint?xint?y)
{
if(key==27)
exit(0);
}
void?Timer(int?millis)
{
float?dday=6speed?=4;
float?dsun?=?speed*dday/27.5;????????//太陽自轉(zhuǎn)?
float?dmonth=speed*dday/29.5;????????//月亮自轉(zhuǎn)?
float?dyear?=speed*dday/365.2475;????//地球公轉(zhuǎn)?
sun?=?fmod(sun+dsun360);?????????//計(jì)算太陽自轉(zhuǎn)角度?
month?=fmod(month+dmonth360);???????//計(jì)算月亮自轉(zhuǎn)和公轉(zhuǎn)角度?
year?=fmod(year+dyear360);??????????//計(jì)算地球公轉(zhuǎn)角度?
day?=?fmod(day+dday360);????????????//計(jì)算地球自轉(zhuǎn)角度?
glutPostRedisplay();
glutTimerFunc(millisTimermillis);
}
void?Reshape(int?wint?h)?
{?
????glViewport(00wh);
????glMatrixMode(GL_PROJECTION);?
????glLoadIdentity();?
????gluPerspective(30(float)w/h11000);?
????glTranslatef(00-8);
glRotatef(30100);?
????glMatrixMode(GL_MODELVIEW);?
????glLoadIdentity();?
}
void?Light(float?r)
{
float?pos[]?[4]=
{
{r001}{-r001}{0r01}{0-r01}{00r1}{00-r1}{0.90.90.90.1}
};
for?(int?i=0;i<6;++i)
{
glLightfv(GL_LIGHT0+iGL_POSITIONpos[i]);
glLightfv(GL_LIGHT0+iGL_DIFFUSEpos[6]);

glEnable(GL_LIGHT0+i);
}?

}
void?Material(float?rfloat?gfloat?b)
{
float?aa[]={rgb1};
glEnable(GL_LIGHTING);
glMaterialfv(GL_FRONTGL_DIFFUSEaa);
}
void?Color(float?rfloat?gfloat?b)
{
glDisable(GL_LIGHTING);
glColor3f(rgb);?
}


void?Wire(float?r)
{
Color(0.50.50.5);?
glutWireSphere(r*1.0052412);
}
void?Ball(float?r)
{
glTranslatef(-r00);
Color(0.90.10.9);
glutSolidSphere(r*0.1126);
}

void?Sun(float?r)
{
glEnable(GL_TEXTURE_2D);
glTexGeni(GL_S?GL_TEXTURE_GEN_MODE?GL_SPHERE_MAP);???//?設(shè)置s方向的紋理自動生成
glTexGeni(GL_T?GL_TEXTURE_GEN_MODE?GL_SPHERE_MAP);???//?設(shè)置t方向的紋理
glEnable(GL_TEXTURE_GEN_S);??????//?自動生成s方向紋理坐標(biāo)
glEnable(GL_TEXTURE_GEN_T);??????//?自動生成t方向紋理坐標(biāo)
glBindTexture(GL_TEXTURE_2DtexSun);??//選擇紋理texture[status]?
glPushMatrix();
glRotatef(90-100);?
Color(0.90.10.1);
glutSolidSphere(r2412);
Wire(r);
Ball(r);
glPopMatrix();
glDisable(GL_TEXTURE_2D);
}
void?Planet(float?r)
{
glEnable(GL_TEXTURE_2D);
glTexGeni(

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????43254??2018-09-04?17:10??test8\moon.bmp
?????文件??????345654??2018-09-04?16:56??test8\planet.bmp
?????文件???????50918??2018-09-11?12:18??test8\planet.jpg
?????文件??????172854??2018-09-04?17:10??test8\sun.bmp
?????文件????????5117??2018-09-11?12:20??test8\test8.cpp
?????文件??????275761??2018-09-11?12:20??test8\test8.exe
?????目錄???????????0??2018-09-11?12:20??test8\

評論

共有 條評論

相關(guān)資源