labwindows中opengl三维编程设计.docx

上传人:b****2 文档编号:20183886 上传时间:2023-04-25 格式:DOCX 页数:31 大小:51.10KB
下载 相关 举报
labwindows中opengl三维编程设计.docx_第1页
第1页 / 共31页
labwindows中opengl三维编程设计.docx_第2页
第2页 / 共31页
labwindows中opengl三维编程设计.docx_第3页
第3页 / 共31页
labwindows中opengl三维编程设计.docx_第4页
第4页 / 共31页
labwindows中opengl三维编程设计.docx_第5页
第5页 / 共31页
点击查看更多>>
下载资源
资源描述

labwindows中opengl三维编程设计.docx

《labwindows中opengl三维编程设计.docx》由会员分享,可在线阅读,更多相关《labwindows中opengl三维编程设计.docx(31页珍藏版)》请在冰豆网上搜索。

labwindows中opengl三维编程设计.docx

labwindows中opengl三维编程设计

Fuzhu.c文件内容如下:

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include"kaifa.h"

#include"cviogl.h"

#include"fuzhu.h"

externintpanelHandle;

externcharreadBuf[100];

externstructsddd;

//externGLfloatctrlpoints[4][4][3];

externdoubleanglh,angrh,angll,angrl;

//externGLfloatctlpoints[4][4][3];

//GLfloatknots[8]={0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0};//NURBS曲面的控制向量

voidinitial(void)

{

//设置程序窗口为正常

SetPanelAttribute(panelHandle,ATTR_WINDOW_ZOOM,VAL_NO_ZOOM);

//将PIC控件转化为OPENGL控件

dd.OGLPanel=OGLConvertCtrl(panelHandle,PANEL_PICTURE);

//设置光源

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_LIGHTING_ENABLE,1);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_LIGHT_SELECT,1);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_LIGHT_ENABLE,1);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_LIGHT_DISTANCE,2.0);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_LIGHT_LATITUDE,DFLT_LIGHT_LATITUDE);

//设置坐标系的视点

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_PROJECTION_TYPE,OGLVAL_PERSPECTIVE);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_VIEW_DIRECTION,OGLVAL_USER_DEFINED);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_VIEW_LATITUDE,DFLT_VIEW_LATITUDE);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_VIEW_LONGITUDE,DFLT_VIEW_LONGITUDE);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_VIEW_CENTERX,DFLT_VIEWPOINT_X);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_VIEW_CENTERY,DFLT_VIEWPOINT_Y);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_VIEW_CENTERZ,DFLT_VIEWPOINT_Z);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_VIEW_DISTANCE,DFLT_VIEW_DISTANCE);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_BGCOLOR,OGLVAL_BLUE);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_XY_GRID_VISIBLE,OGLVAL_TRUE);

//OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_XY_PLANE_ZLOCATION,1.0);

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_XY_PLANE_VISIBLE,OGLVAL_TRUE);

//去掉坐标系显示

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_PLOTTING_ENABLE,0);

//设置OPENGL弹出属性对话框

OGLSetCtrlAttribute(panelHandle,dd.OGLPanel,OGLATTR_ENABLE_PROPERTY_POPUP,1);

//刷新OPENGL显示

OGLRefreshGraph(panelHandle,dd.OGLPanel);

}

/*voidInitSurface()

{intu,v;

for(u=0;u<4;u++)

{

for(v=0;v<4;v++){

ctlpoints[u][v][0]=2.0*((GLfloat)u-1.5);

ctlpoints[u][v][1]=2.0*((GLfloat)v-1.5);

if((u==1||u==2)&&(v==1||v==2))ctlpoints[u][v][2]=6;

elsectlpoints[u][v][2]=-6;

}

}

}

*/

AUX_RGBImageRec*LoadBMP(char*Filename)

{

FILE*File=NULL;//文件句柄

if(!

Filename)//确保文件名已提供。

{

returnNULL;//如果没提供,返回NULL

}

File=fopen(Filename,"r");//尝试打开文件

if(File)//文件存在么?

{

fclose(File);//关闭句柄

returnauxDIBImageLoad(Filename);//载入位图并返回指针

}

returnNULL;//如果载入失败,返回NULL

}

voiddrawing(intfastFlag)

{

doubleradius,h1,h2,h3,h4,h5,angle2=20;

//dd.og.dd.og.theNurb=gluNewNurbsRenderer();

/*InitSurface();//初始化控制点

dd.og.theNurb=gluNewNurbsRenderer();//创建一个NURBS曲面对象

//修改NURBS曲面对象的属性

gluNurbsProperty(dd.og.theNurb,GLU_SAMPLING_TOLERANCE,5.0);

gluNurbsProperty(dd.og.theNurb,GLU_DISPLAY_MODE,GLU_FILL);

glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);//清屏

glPushMatrix();//入栈

glRotatef(30.0,-1.0,0.0,0.0);//旋转变换

glScalef(0.5,0.5,0.5);//缩放变换

gluBeginSurface(dd.og.theNurb);//开始曲面绘制

gluNurbsSurface(dd.og.theNurb,8,knots,8,knots,4*3,3,&ctlpoints[0][0][0],4,4,GL_MAP2_VERTEX_3);//定义曲面的数学模型,确定其形状

gluEndSurface(dd.og.theNurb);//结束曲面绘制

glPopMatrix();//出栈

glFlush();//强制刷新

*/

/*glPushMatrix();

glMap2f(GL_MAP2_VERTEX_3,0,1,3,4,0,1,12,4,&ctrlpoints[0][0][0]);//定义曲面

glEnable(GL_MAP2_VERTEX_3);//启用曲面

glEnable(GL_AUTO_NORMAL);//启用曲面法向向量计算

glEnable(GL_NORMALIZE);//启用法向归一化

glMapGrid2f(20,0.0,1.0,20,0.0,1.0);//定义参数空间的均匀网格

glPopMatrix();

*/

/* for(u=0;u<4;u++)

{

  for(v=0;v<4;v++)

{

   ctlpoints[u][v][0]=2.0*((GLfloat)u-1.5);

   ctlpoints[u][v][1]=2.0*((GLfloat)v-1.5);

   if((u==1||u==2)&&(v==1||v==2))ctlpoints[u][v][2]=6;

   elsectlpoints[u][v][2]=-6;

  }

 }*/

//glPointSize

(1);

//gluPartialDisk(dd.og.object,0,0.5,30,15,10,20);

//gluBeginSurface(dd.og.object);

//auxSolidCube(1.0);

//auxWireBox(0.1,1,0.1);

//auxWireTeapot(0.5);

//auxWireTorus(1,1);

//auxSolidIcosahedron(0.5);

//auxWireOctahedron(0.5);

//auxWireSphere

(1);

/*glBegin(GL_LINES);

glVertex2i(1,1);

glVertex2i(0.1,1);

glEnd();

*/

//创建一个新的二次曲面目标

dd.og.object=gluNewQuadric();

gluQuadricNormals(dd.og.object,GLU_SMOOTH);//使用平滑法线

gluQuadricTexture(dd.og.object,GL_TRUE);

glPushMatrix();

auxSolidBox(3.0,3.0,0.0001);

//glColor3f(21,0,21);

glTranslatef(0.0,0.0,0.75);

auxSolidBox(0.07,0.2,0.07);

glTranslatef(0.0,-0.1,0.0);

gluSphere(dd.og.object,0.06,15,10);//臀部

glRotated(150-angrl,1,0,0);

gluCylinder(dd.og.object,0.05,0.04,0.3,15,10);

glTranslatef(0.0,0.0,0.3);

gluSphere(dd.og.object,0.045,15,10);

gluCylinder(dd.og.object,0.04,0.035,0.4,15,10);

glTranslatef(0.0,0.0,0.4);

gluSphere(dd.og.object,0.04,15,10);

glTranslatef(0.02,0,0.02);

auxSolidBox(0.12,0.06,0.03);//右腿

//glRotated(210,1,0,0);

glPopMatrix();

glPushMatrix();

//glRotated(180,1,0,0);

//glRotated(180,1,0,0);

glTranslatef(0.0,0.1,0.75);

//glTranslatef(-0.02,0.2,0.72);

gluSphere(dd.og.object,0.06,15,10);

glRotated(210-angll,1,0,0);

gluCylinder(dd.og.object,0.05,0.04,0.3,15,10);

glTranslatef(0.0,0.0,0.3);

gluSphere(dd.og.object,0.045,15,10);

gluCylinder(dd.og.object,0.04,0.035,0.4,15,10);

glTranslatef(0.0,0.0,0.4);

gluSphere(dd.og.object,0.04,15,10);

glTranslatef(0.02,0,0.02);

auxSolidBox(0.12,0.06,0.03);//左腿

//glRotated(150,1,0,0);

glPopMatrix();

glPushMatrix();

glTranslatef(0.0,0.0,0.75);

//glTranslatef(-0.02,-0.1,0.72);

auxSolidBox(0.07,0.2,0.07);

glTranslatef(-0.02,0.0,0.0);

gluSphere(dd.og.object,0.07,15,10);//屁股

glPopMatrix();

glPushMatrix();

glTranslatef(0.0,0.0,0.95);

//glTranslatef(0.02,0.0,0.2);

auxSolidBox(0.1,0.2,0.4);

glTranslatef(0.0,0.0,0.15);

auxSolidBox(0.07,0.3,0.07);//身体

glPopMatrix();

glPushMatrix();

glTranslatef(0.0,-0.15,1.1);

gluSphere(dd.og.object,0.06,15,10);

glRotated(90-angrh,1,0,0);

//glRotated(90,1,0,0);

gluCylinder(dd.og.object,0.04,0.035,0.25,15,10);

glTranslatef(0.0,0.0,0.25);

gluSphere(dd.og.object,0.04,15,10);

gluCylinder(dd.og.object,0.035,0.03,0.2,15,10);

glTranslatef(0.0,0.0,0.2);

gluSphere(dd.og.object,0.035,15,10);

//glTranslatef(0.0,0.0,-0.75);

//glRotated(270,1,0,0);//右臂

glPopMatrix();

glPushMatrix();

glTranslatef(0.0,0.15,1.1);

gluSphere(dd.og.object,0.06,15,10);

glRotated(270-anglh,1,0,0);

gluCylinder(dd.og.object,0.04,0.035,0.25,15,10);

glTranslatef(0.0,0.0,0.25);

gluSphere(dd.og.object,0.04,15,10);

gluCylinder(dd.og.object,0.035,0.03,0.2,15,10);

glTranslatef(0.0,0.0,0.2);

gluSphere(dd.og.object,0.035,15,10);

glTranslatef(0.0,0.0,-0.6);

//glRotated(90,1,0,0);//左臂

glPopMatrix();

glPushMatrix();

glTranslatef(0.0,0.0,1.15);

gluSphere(dd.og.object,0.05,15,10);

gluCylinder(dd.og.object,0.04,0.03,0.05,15,10);

glTranslatef(0.0,0.0,0.1);

gluSphere(dd.og.object,0.08,15,10);//头部

/*glTranslatef(0.0,-0.1,0);

auxSolidBox(0.12,0.06,0.03);

glTranslatef(-0.02,0,0.02);

gluSphere(dd.og.object,0.04,15,10);

gluCylinder(dd.og.object,0.035,0.04,0.4,15,10);

glTranslatef(0.0,0.0,0.4);

gluSphere(dd.og.object,0.045,15,10);

gluCylinder(dd.og.object,0.04,0.05,0.3,15,10);

glTranslatef(0.0,0.0,0.3);

gluSphere(dd.og.object,0.06,15,10);//右腿

glTranslatef(0.02,0.2,-0.72);

auxSolidBox(0.12,0.06,0.03);

glTranslatef(-0.02,0,0.02);

gluSphere(dd.og.object,0.04,15,10);

gluCylinder(dd.og.object,0.035,0.04,0.4,15,10);

glTranslatef(0.0,0.0,0.4);

gluSphere(dd.og.object,0.045,15,10);

gluCylinder(dd.og.object,0.04,0.05,0.3,15,10);

glTranslatef(0.0,0.0,0.3);

gluSphere(dd.og.object,0.06,15,10);//左腿

glTranslatef(0.0,-0.1,0.01);

auxSolidBox(0.07,0.2,0.07);

glTranslatef(-0.02,0.0,0.0);

gluSphere(dd.og.object,0.07,15,10);//屁股

glTranslatef(0.02,0.0,0.2);

auxSolidBox(0.1,0.2,0.4);

glTranslatef(0.0,0.0,0.15);

auxSolidBox(0.07,0.3,0.07);//身体

glTranslatef(0.0,-0.15,0.0);

gluSphere(dd.og.object,0.06,15,10);

glRotated(90,1,0,0);

//glRotated(90,1,0,0);

gluCylinder(dd.og.object,0.04,0.035,0.25,15,10);

glTranslatef(0.0,0.0,0.25);

gluSphere(dd.og.object,0.04,15,10);

gluCylinder(dd.og.object,0.035,0.03,0.2,15,10);

glTranslatef(0.0,0.0,0.2);

gluSphere(dd.og.object,0.035,15,10);

glTranslatef(0.0,0.0,-0.75);

glRotated(270,1,0,0);//右臂

gluSphere(dd.og.object,0.06,15,10);

glRotated(270,1,0,0);

gluCylinder(dd.og.object,0.04,0.035,0.25,15,10);

glTranslatef(0.0,0.0,0.25);

gluSphere(dd.og.object,0.04,15,10);

gluCylinder(dd.og.object,0.035,0.03,0.2,15,10);

glTranslatef(0.0,0.0,0.2);

gluSphere(dd.og.object,0.035,15,10);

glTranslatef(0.0,0.0,-0.6);

glRotated(90,1,0,0);//左臂

glTranslatef(0.0,0.0,0.04);

gluSphere(dd.og.object,0.05,15,10);

gluCylinder(dd.og.object,0.04,0.03,0.05,

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

当前位置:首页 > 法律文书 > 调解书

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

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