




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、電子科技大學(xué)信息與軟件工程學(xué)院三維圖形程序設(shè)計(jì)綜合實(shí)驗(yàn)標(biāo)準(zhǔn)實(shí)驗(yàn)報(bào)告(實(shí)驗(yàn))課程名稱三維圖形程序設(shè)計(jì)電子科技大學(xué)教務(wù)處制表實(shí)驗(yàn)?zāi)康陌幢壤笮±L制太陽(yáng)系(太陽(yáng)、地球、月亮)自動(dòng)紋理映射地球以及月亮的自轉(zhuǎn)地球以及月亮的公轉(zhuǎn)#include windows.h”#include #include #include #define SunSize 0.6#define EarthSize 0.2#define MoonSize 0.1GLUquadricObj* g_quadratic_sun;GLUquadricObj* g_quadratic_earth;GLUquadricObj* g_quadr
2、atic_moon;GLuint sun_texture;GLuint earth_texture;GLuint moon_texture;GLfloat year = 0.0; /degreesGLfloat day = 0.0;GLfloat moonAroundEarth = 0.0;/月亮繞地球的速度GLfloat moonItsSelf = 0.0;/月球自轉(zhuǎn)的速度GLfloat EarthOrbitRadius = 1.0; /地球軌道半徑GLfloat MoonOrbitRadius = 0.3;/月亮軌道半徑?#pragma comment( lib, opengl32.lib
3、) OpenGL32.lib While Linking ( NEW ) #pragma comment( lib, glu32.lib) GLu32.lib While Linking ( NEW ) #pragma comment( lib, glaux.lib) GLaux.lib While Linking ( NEW )讀取BMP類型的圖形文件tAUX_RGBImageRec *LoadBMP(const char Filename) Image FILE *File = NULL;Handleif (!Filename)A Filename Was Givenreturn NULL
4、;NULLFile = fopen(Filename, r);See If The File Existsif (File)File Exist?fclose(File);Handlereturn auxDIBImageLoad(Filename);And Return A Pointerreturn NULL;Return NULL /加載綁定紋理GLuint LoadGLTexture(const char *filename) Convert To Textures AUX_RGBImageRec *pImage;/ Search For/ Search For/ Search For/
5、 Loads A Bitmap/ File/ Make Sure/ If Not Return/ Check To/ Does The/ Close The/ Load The Bitmap/ If Load Failed/ Load Bitmaps And/ Create Storage/ Texture IDSpace For The Texture GLuint texture = 0;pImage = LoadBMP(filename);/ Loads TheBitmap Specified By filename/ Load The Bitmap, Check For Errors,
6、 If Bitmaps Not Found Quitif (pImage != NULL & pImage-data != NULL)/ If Texture ImageExistsglGenTextures(1, &texture);/ Create TheTexture/ Typical Texture Generation Using Data From The BitmapglBindTexture(GL_TEXTURE_2D, texture);glTexImage2D(GL_TEXTURE_2D, 0, 3, pImage-sizeX, pImage-sizeY, 0, GL_RG
7、B, GL_UNSIGNED_BYTE, pImage-data);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);/ Free The/ Free The Imagefree(pImage-data);Texture Image Memory free(pImage);Structurereturn texture;/ Return TheStatus void RenderScen
8、e(void) glPushMatrix();glEnable(GL_TEXTURE_2D);gluLookAt(0.0, 0.0, -4.0,0.0, 0.0,1.0,0.0, 1.0,0.0);繪制太陽(yáng)glColor3f(1.0, 1.0, 0.0);glBindTexture(GL_TEXTURE_2D, sun_texture); gluSphere(g_quadratic_sun, SunSize, 32, 32);glPushMatrix();地球公轉(zhuǎn)glRotatef(year, 0.0, 1.0, 0.0);glTranslatef(EarthOrbitRadius, 0.0,
9、 0.0);glRotatef(-year, 0.0, 1.0, 0.0);glPushMatrix();地球自轉(zhuǎn) glRotatef(day, 0.25, 1.0, 0.0);繪制地球glColor3f(0.0, 0.0, 1.0);glBindTexture(GL_TEXTURE_2D, earth_texture);/綁定紋理 gluSphere(g_quadratic_earth, EarthSize, 32, 32);glPopMatrix();月球公轉(zhuǎn)glRotatef(moonAroundEarth, 0.0, 1.0, 0.0);glTranslatef(MoonOrbitRa
10、dius, 0.0, 0.0);glRotatef(-moonAroundEarth, 0.0, 1.0, 0.0);/月球自轉(zhuǎn) glRotatef(moonItsSelf, 0.0, 1.0, 0.0);/繪制月球glColor3f(0.8, 0.8, 0.0);glBindTexture(GL_TEXTURE_2D, moon_texture);gluSphere(g_quadratic_moon, MoonSize, 32, 32);glPopMatrix();glPopMatrix();glDisable(GL_TEXTURE_2D);void Init(void)glEnable(G
11、L_DEPTH_TEST);glClearColor(0.0, 0.0, 0.0, 0.0);glLoadIdentity();幾何曲面的產(chǎn)生sun_texture = LoadGLTexture(sunmap.bmp);g_quadratic_sun = gluNewQuadric();gluQuadricNormals(g_quadratic_sun, GLU_SMOOTH); earth_texture = LoadGLTexture(earthmap1k.bmp);g_quadratic_earth = gluNewQuadric();gluQuadricNormals(g_quadr
12、atic_earth, GLU_SMOOTH);moon_texture = LoadGLTexture(moonmap4k.bmp);g_quadratic_moon = gluNewQuadric();gluQuadricNormals(g_quadratic_moon, GLU_SMOOTH);glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);glEnable(GL_TEXTURE_GEN_S);glEnable(GL_TEXTUR
13、E_GEN_T);glMatrixMode(GL_MODELVIEW);glLoadIdentity();void Display(void)glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();RenderScene();glFlush();glutSwapBuffers();void Reshape(int x, int y)if (y = 0) return;glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(40.0, (GLdouble)x / (GLdouble)y, 0.5, 20.0);glMatrixMode(GL_MODELVIEW);glViewport(0, 0, x, y);Display();void Idle(void)day += 4;year += 0.5;moonItsSelf += 10;moonAroundEarth += 0.4;Display();int main(int argc, char* argv)glu
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 門頭裝修廠家供貨合同協(xié)議
- 集體合同線上簽訂協(xié)議模板
- 預(yù)制墻板合同協(xié)議
- 門票優(yōu)惠協(xié)議書模板
- 防水維修清包工合同協(xié)議
- 食品購(gòu)銷協(xié)議合同協(xié)議
- 防水保溫勞務(wù)合同協(xié)議
- 項(xiàng)目開(kāi)發(fā)協(xié)議合同書
- 餐廳買菜協(xié)議書模板
- 門崗合同協(xié)議
- 工藝工法QC超高層建筑工程管井立管倒裝法施工工法附圖
- 鋼屋架制作與安裝施工方案
- GB/T 1633-2000熱塑性塑料維卡軟化溫度(VST)的測(cè)定
- GB/T 11032-2020交流無(wú)間隙金屬氧化物避雷器
- 煤礦爆破工培訓(xùn)
- 水車租賃合同范本(3篇)
- 空港新城特勤消防站施工組織設(shè)計(jì)
- 北師大版三年級(jí)數(shù)學(xué)下冊(cè)競(jìng)賽卷
- 2022山東歷史高考答題卡word版
- 中醫(yī)醫(yī)院兒科建設(shè)與管理指南(試行)
- Q∕SY 1143-2008 三維地質(zhì)建模技術(shù)要求
評(píng)論
0/150
提交評(píng)論