计算机图形学课程设计报告1文档格式.docx

上传人:b****6 文档编号:17624437 上传时间:2022-12-07 格式:DOCX 页数:32 大小:39.98KB
下载 相关 举报
计算机图形学课程设计报告1文档格式.docx_第1页
第1页 / 共32页
计算机图形学课程设计报告1文档格式.docx_第2页
第2页 / 共32页
计算机图形学课程设计报告1文档格式.docx_第3页
第3页 / 共32页
计算机图形学课程设计报告1文档格式.docx_第4页
第4页 / 共32页
计算机图形学课程设计报告1文档格式.docx_第5页
第5页 / 共32页
点击查看更多>>
下载资源
资源描述

计算机图形学课程设计报告1文档格式.docx

《计算机图形学课程设计报告1文档格式.docx》由会员分享,可在线阅读,更多相关《计算机图形学课程设计报告1文档格式.docx(32页珍藏版)》请在冰豆网上搜索。

计算机图形学课程设计报告1文档格式.docx

(典型的位置为:

C:

\Windows\System32)然后建立一个OpenGL工程测试

这里以VisualStudio2005为例。

选择File->

New->

Project,然后选择Win32 

Console 

Application,选择一个名字,然后按OK。

在谈出的对话框左边点Application 

Settings,找到Empty 

project并勾上,选择Finish。

然后向该工程添加一个代码文件,取名为“OpenGL.c”,注意用.c来作为文件结尾。

建立工程。

新建一个MFC文件。

命名为plmy2.而其中的三维建模画图主要程序在程序plmyView.cpp附录下,主要步骤如下:

建立模型------着色----旋转------飞机飞行

1设置背景

voidCPlmyView:

:

OnDraw(CDC*pDC)

{

CPlmyDoc*pDoc=GetDocument();

ASSERT_VALID(pDoc);

//TODO:

adddrawcodefornativedatahere

///////////////////////////////////////

staticBOOLbBusy=FALSE;

if(bBusy)return;

bBusy=TRUE;

glClearColor(0.2f,0.2f,0.5f,1.0f);

//设置背景颜色

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

//清除颜色缓存和深度缓存

glMatrixMode(GL_MODELVIEW);

//glMatrixMode设置当前矩阵模式

glLoadIdentity();

//将当前的用户坐标系的原点移到了屏幕中心:

类似于一个复位操作

mydraw();

glFinish();

SwapBuffers(wglGetCurrentDC());

bBusy=FALSE;

////////////////////////////////////////

}

2画挂饰运动的方法

myplane()

glPushMatrix();

//入栈

glTranslatef(ABS(rx)*cosf((rangplane2+rangx)*6.283f/360.0f),

0.0f,

-ABS(rx)*sinf((rangplane2+rangx)*6.283f/360.0f));

//移动

glRotated((rangplane2+rangx),0.0,1.0,0.0);

//y

glRotated(-90.0f,0.0,1.0,0.0);

glRotated(rangx,1.0,0.0,0.0);

//绕x旋转

glShadeModel(GL_SMOOTH);

//放大缩小

glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

for(inti=0;

i<

2;

i++){

glBegin(GL_TRIANGLE_FAN);

//画图

glColor3f(1.0f,0.5f,1.0f);

glVertex3f(-0.18f,0.0f,0.0f);

glVertex3f(0.1f,0.0f,-0.1f);

glColor3f(1.0f,0.8f,1.0f);

glVertex3f(0.09f,0.0f,-0.01f);

glColor3f(1.0f,0.3f,1.0f);

glVertex3f(0.08f,-0.05f,0.0f);

glColor3f(1.0f,1.0f,1.0f);

glVertex3f(0.09f,0.0f,0.01f);

glVertex3f(0.1f,0.0f,0.1f);

glEnd();

glShadeModel(GL_FLAT);

glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);

};

glPopMatrix();

plane2()//画飞机图

4:

fly()//飞机飞翔方法

5:

OnTimer(UINTnIDEvent)//设置触发函数

图片如下:

3.系统开发环境

开发工具:

MicrosoftVisualBasic6.0

开发环境:

Windows2000Server

操作系统:

MicrosoftWindowsXP

总结

由于属于初学VC且时间有限,所以对于前台的制作难免也诸多的不足,很多东西都要马上学习查资料并进行初步调试即拿出来使用。

而制作出的前台功能单一结构简单是一大缺憾,没有时间进行精加工与进一步的调试补全源程序的不足之处使之更加完善。

不过通过这次的课程设计,使我们的自学能力与动手实践能力得到相当大的提高,编程并不是靠看书本就能学会的,而是要靠一步步的调试一条条指令的修改试运行中学习进步的,盲目的看书并不能提高自己水平。

从这次的课程设计我们知道了自己的不足,学习的知识不够充分,对于现有资源材料的利用学习率太低等方面的缺点,对今后的学习和工作进步都有非常大的帮助。

参考文献:

《计算机图形学》罗笑男,王若梅

《C++面向对象程序设计》徐孝凯,张纪勇主编

《交互式计算机图形学-自顶向下方法与OpenGL应用》(美)安杰尔著

附录:

源程序代码清单

SourceFiles:

MainFrm.cpp

plmy.cpp

plmy.rc

plmyDoc.cpp

plmyView.cpp

StdAfx.cpp

//MainFrm.cpp:

implementationoftheCMainFrameclass

//

#include"

stdafx.h"

plmy.h"

MainFrm.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

//CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame,CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame,CFrameWnd)

//{{AFX_MSG_MAP(CMainFrame)

ON_WM_CREATE()

ON_WM_GETMINMAXINFO()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

staticUINTindicators[]=

ID_SEPARATOR,//statuslineindicator

ID_INDICATOR_CAPS,

ID_INDICATOR_NUM,

ID_INDICATOR_SCRL,

//CMainFrameconstruction/destruction

CMainFrame:

CMainFrame()

addmemberinitializationcodehere

fullscreenkey=FALSE;

~CMainFrame()

intCMainFrame:

OnCreate(LPCREATESTRUCTlpCreateStruct)

if(CFrameWnd:

OnCreate(lpCreateStruct)==-1)

return-1;

//if(!

m_wndToolBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD|WS_VISIBLE|CBRS_TOP

if(!

m_wndToolBar.CreateEx(this,TBSTYLE_FLAT,WS_CHILD|CBRS_TOP

|CBRS_GRIPPER|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)||

!

m_wndToolBar.LoadToolBar(IDR_MAINFRAME))

{

TRACE0("

Failedtocreatetoolbar\n"

);

//failtocreate

}

m_wndStatusBar.Create(this)||

m_wndStatusBar.Create(this,WS_CHILD|CBRS_BOTTOM)||

m_wndStatusBar.SetIndicators(indicators,

sizeof(indicators)/sizeof(UINT)))

Failedtocreatestatusbar\n"

//定义状态栏

if(m_wndStatusBar){

m_wndStatusBar.SetPaneInfo(0,0,SBPS_STRETCH,50);

m_wndStatusBar.SetPaneInfo(1,0,0,50);

m_wndStatusBar.SetPaneInfo(2,0,SBPS_STRETCH,50);

m_wndStatusBar.SetPaneInfo(3,0,SBPS_STRETCH,50);

};

//全拼显示

fullscreenkey=TRUE;

CRectwinme,clientme;

GetWindowRect(&

winme);

RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&

clientme);

ClientToScreen(&

intfullwide=GetSystemMetrics(SM_CXSCREEN);

intfullhide=GetSystemMetrics(SM_CYSCREEN);

mefullscreen.left=winme.left-clientme.left;

mefullscreen.top=winme.top-clientme.top;

mefullscreen.right=winme.right-clientme.right+fullwide;

mefullscreen.bottom=winme.bottom-clientme.bottom+fullhide;

WINDOWPLACEMENTwinfull;

winfull.length=sizeof(WINDOWPLACEMENT);

winfull.flags=0;

winfull.showCmd=SW_SHOWNORMAL;

winfull.rcNormalPosition=mefullscreen;

SetWindowPlacement(&

winfull);

Deletethesethreelinesifyoudon'

twantthetoolbarto

//bedockable

m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);

EnableDocking(CBRS_ALIGN_ANY);

DockControlBar(&

m_wndToolBar);

return0;

BOOLCMainFrame:

PreCreateWindow(CREATESTRUCT&

cs)

if(!

CFrameWnd:

PreCreateWindow(cs))

returnFALSE;

ModifytheWindowclassorstylesherebymodifying

//theCREATESTRUCTcs

returnTRUE;

//CMainFramediagnostics

voidCMainFrame:

AssertValid()const

CFrameWnd:

AssertValid();

Dump(CDumpContext&

dc)const

Dump(dc);

#endif//_DEBUG

//CMainFramemessagehandlers

xyshow(intx,inty)

CStringstrsa;

if(m_wndStatusBar){

m_wndStatusBar.SetPaneText(1,"

"

strsa.Format("

x=%d"

x);

m_wndStatusBar.SetPaneText(2,strsa);

y=%d"

y);

m_wndStatusBar.SetPaneText(3,strsa);

OnGetMinMaxInfo(MINMAXINFOFAR*lpMMI)

Addyourmessagehandlercodehereand/orcalldefault

if(fullscreenkey)

lpMMI->

ptMaxSize.x=mefullscreen.Width();

ptMaxSize.y=mefullscreen.Height();

ptMaxPosition.x=mefullscreen.left;

ptMaxPosition.y=mefullscreen.top;

ptMaxTrackSize.x=mefullscreen.Width();

ptMaxTrackSize.y=mefullscreen.Height();

OnGetMinMaxInfo(lpMMI);

//plmy.cpp:

Definestheclassbehaviorsfortheapplication.

plmyDoc.h"

plmyView.h"

//CPlmyApp

BEGIN_MESSAGE_MAP(CPlmyApp,CWinApp)

//{{AFX_MSG_MAP(CPlmyApp)

ON_COMMAND(ID_APP_ABOUT,OnAppAbout)

//NOTE-theClassWizardwilladdandremovemappingmacroshere.

//DONOTEDITwhatyouseeintheseblocksofgeneratedcode!

//Standardfilebaseddocumentcommands

ON_COMMAND(ID_FILE_NEW,CWinApp:

OnFileNew)

ON_COMMAND(ID_FILE_OPEN,CWinApp:

OnFileOpen)

//Standardprintsetupcommand

ON_COMMAND(ID_FILE_PRINT_SETUP,CWinApp:

OnFilePrintSetup)

//CPlmyAppconstruction

CPlmyApp:

CPlmyApp()

addconstructioncodehere,

//PlaceallsignificantinitializationinInitInstance

//TheoneandonlyCPlmyAppobject

CPlmyApptheApp;

//CPlmyAppinitialization

BOOLCPlmyApp:

InitInstance()

AfxEnableControlContainer();

//Standardinitialization

//Ifyouarenotusingthesefeaturesandwishtoreducethesize

//ofyourfinalexecutable,youshouldremovefromthefollowing

//thespecificinitializationroutinesyoudonotneed.

#ifdef_AFXDLL

Enable3dControls();

//CallthiswhenusingMFCinasharedDLL

#else

Enable3dControlsStatic();

//CallthiswhenlinkingtoMFCstatically

//Changetheregistrykeyunderwhichoursettingsarestored.

Youshouldmodifythisstringtobesomethingappropriate

//suchasthenameofyourcompanyororganization.

SetRegistryKey(_T("

LocalAppWizard-GeneratedApplications"

));

LoadStdProfileSettings();

//LoadstandardINIfileoptions(includingMRU)

//Registertheapplication'

sdocumenttemplates.Documenttemplates

//serveastheconnectionbetweendocuments,framewindowsandviews.

CSingleDocTemplate*pDocTemplate;

pDocTemplate=newCSingleDocTemplate(

IDR_MAINFRAME,

RUNTIME_CLASS(CPlmyD

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 理化生

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1