第五章_OpenGL光照与材质(二)_第1页
第五章_OpenGL光照与材质(二)_第2页
第五章_OpenGL光照与材质(二)_第3页
第五章_OpenGL光照与材质(二)_第4页
第五章_OpenGL光照与材质(二)_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、第五章 光照与材质5.8 全局环境光每个光源可以有自己的环境光,但也可以有不来自于任何光源的环境光,指定环境光的方法是:利用参数GL_LIGHT_MODEL_AMBIENT来调用函数glLightModel*()。如:float model_ambient = 0.2 , 0.2 , 0.2 , 1.0 ; glLightModelfv(GL_LIGHT_MODEL_AMBIENT , model_ambient ) ;上述代码为场景中的物体提供了软弱的白色环境光,所以即使场景中没有任何光源,也可以看到场景中的物体。【综合示例EP5-5】场景中绘制一组静物模型,然后加入一个简单的光照,先使用光

2、源自己的环境光,再统一使用全局环境光。代码如下:#include stdafx.hint nAngleY=0;/ 沿Y轴旋转的角度int nAngleX=0;/ 沿X轴旋转的角度int nAngleZ=0;/ 沿Z轴旋转的角度void CALLBACK ClockwiseRotateByX()nAngleX-;void CALLBACK CounterClockwiseRotateByX()nAngleX+;void CALLBACK ClockwiseRotateByZ()nAngleZ-;void CALLBACK CounterClockwiseRotateByZ()nAngleZ+;v

3、oid CALLBACK ClockwiseRotateByY()nAngleY-;void CALLBACK CounterClockwiseRotateByY()nAngleY+;void myinit (void) /* 将背景清为白色 */glClearColor (0.0, 0.0,0.0, 1.0);glShadeModel (GL_SMOOTH); GLfloat ambient = 0.5, 0.0, 0.0, 1.0 ; GLfloat specular = 1.0, 1.0, 0.0, 1.0 ; GLfloat diffuse = 0.5, 0.5, 0.5, 1.0 ;

4、 GLfloat light_position = 1.0, 1.0, 1.0, 0.0 ; GLfloat model_ambient = 0.3, 0.0, 0.3, 1.0 ; GLfloat mat_specular = 1.0, 1.0, 1.0, 1.0 ; GLfloat mat_shininess = 128.0 ; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT1, GL_POSI

5、TION, light_position); /glLightfv (GL_LIGHT1, GL_AMBIENT, ambient); glLightfv (GL_LIGHT1, GL_SPECULAR, specular); glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuse); / 指定全局环境光 glLightModelfv(GL_LIGHT_MODEL_AMBIENT,model_ambient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); glDepthFunc(GL_LEQUAL); glEnable(G

6、L_DEPTH_TEST);glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); void CALLBACK reshape(GLsizei w, GLsizei h) if (!h) return; glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w = h) glOrtho (-500.0, 500.0, -500.0*(GLfloat)h/(GLfloat)w, 500.0*(GLfloat)h/(GLfloat)w, -500, 500);

7、 else glOrtho (-500.0*(GLfloat)w/(GLfloat)h, 500.0*(GLfloat)w/(GLfloat)h, -500.0, 500.0, -500, 500); glMatrixMode(GL_MODELVIEW);void CALLBACK display(void)glLoadIdentity(); glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);/清除背景glRotated(nAngleX,1,0,0);glRotated(nAngleY,0,1,0);glRotated(nAngleZ,0,0,

8、1); glLineStipple(1, 0x3F07); / 指定点划格式 glEnable(GL_LINE_STIPPLE); / 进入点划模式glBegin(GL_LINES);/ X轴:红 glColor3f (1.0, 0, 0); glVertex3d(-490,0,0);glVertex3d(490,0,0);/ Y轴:绿 glColor3f (0.0, 1.0, 0); glVertex3d(0,-490,0);glVertex3d(0,490,0);/ Z轴:蓝 glColor3f (0.0, 0.0, 1); glVertex3d(0,0,-490);glVertex3d(

9、0,0,490);glEnd(); glDisable(GL_LINE_STIPPLE);/离开点划模式 glColor3f (1.0, 0.0, 0); glPushMatrix();/ 车体glTranslatef(0,210,0);auxSolidBox(600, 20, 400);glPopMatrix();glPushMatrix();/ 左前腿glTranslatef(-260,100,180);auxSolidBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 左后腿glTranslatef(-260,100,-180);auxSoli

10、dBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 右前腿glTranslatef(260,100,180);auxSolidBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 右后腿glTranslatef(260,100,-180);auxSolidBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 球glTranslatef(-200,260,0);auxSolidSphere(40);glPopMatrix();glPushMatrix();/ 八面体g

11、lTranslatef(-200,260,160);auxSolidOctahedron(40);glPopMatrix();glPushMatrix();/ 圆锥体glTranslatef(-60,220,120);glRotatef(-90,1,0,0);auxSolidCone(60, 100);glPopMatrix(); glPushMatrix();/glTranslatef(60,270,0);glRotatef(40,0,1,0); auxSolidTeapot(70);glPopMatrix();glPushMatrix();/glTranslatef(240,360,0);

12、 auxSolidCylinder(40,140);glPopMatrix();auxSwapBuffers(); int _tmain(int argc, _TCHAR* argv) auxInitDisplayMode (AUX_DOUBLE | AUX_RGBA); auxInitPosition (0, 0, 1000, 700); auxInitWindow (全局环境光); myinit ();auxKeyFunc (AUX_LEFT, ClockwiseRotateByY); auxKeyFunc (AUX_RIGHT, CounterClockwiseRotateByY); a

13、uxKeyFunc (AUX_UP, ClockwiseRotateByX); auxKeyFunc (AUX_DOWN, CounterClockwiseRotateByX); auxKeyFunc (AUX_D, ClockwiseRotateByZ); auxKeyFunc (AUX_d, ClockwiseRotateByZ); auxKeyFunc (AUX_U, CounterClockwiseRotateByZ); auxKeyFunc (AUX_u, CounterClockwiseRotateByZ);auxReshapeFunc(reshape);/回调函数 auxMain

14、Loop(display); return 0;5.9 近视点和无穷远视点在无穷远点的情况下,场景中所有顶点到视点的方向都相同。采用近视点时(local viewpoint),结果的真实感会更强,但需计算每个顶点的方向,因此总体性能将下降。默认情况下,认为视点位于无穷远处,位置将影响镜面反射区计算,也就是说,顶点的镜面反射亮度取决于该顶点的法线、顶点相对于光源的方向和顶点相对于视点的方向。指定方法是:glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER , GL_TRUE) ;上述代码把视点放在坐标系的( 0 ,0 ,0 )处,若把视点放到无穷远处,则执行如下代码

15、glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER , GL_FALSE) ;上述代码可在EP5-5中实现。【综合示例EP5-6】场景中绘制一组静物模型,使用透视投影实现。把实验五中的投影方式,由平行投影改为透视投影。转动场景时,物体显示会出现不正常。其中一个关键是要加入面剔除功能,第二个关键是对于茶壶而言,其面的定义是按顺时针的,这与一般物体的定义不同。下面的关键代码已用粗体标出。#include stdafx.hint nAngleY=0;/ 沿Y轴旋转的角度int nAngleX=0;/ 沿X轴旋转的角度int nAngleZ=0;/ 沿Z轴旋转的角度vo

16、id CALLBACK ClockwiseRotateByX()nAngleX-;void CALLBACK CounterClockwiseRotateByX()nAngleX+;void CALLBACK ClockwiseRotateByZ()nAngleZ-;void CALLBACK CounterClockwiseRotateByZ()nAngleZ+;void CALLBACK ClockwiseRotateByY()nAngleY-;void CALLBACK CounterClockwiseRotateByY()nAngleY+;void myinit (void) /* 将

17、背景清为白色 */glClearColor (0.0, 0.0,0.0, 1.0);glClearDepth(1.0f);/ 深度范围在【,】之间glShadeModel (GL_SMOOTH);/ 光源属性值 GLfloat ambient = 0.5, 0.0, 0.0, 1.0 ; GLfloat specular = 1.0, 1.0, 0.0, 1.0 ; GLfloat diffuse = 0.5, 0.5, 0.5, 1.0 ; GLfloat light_position = 1.0, 1.0, 1.0, 0.0 ; / 材质属性值 GLfloat mat_specular =

18、 1.0, 1.0, 1.0, 1.0 ; GLfloat mat_shininess = 128.0 ; / 设置材质 glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); / 设置光源 glLightfv(GL_LIGHT1, GL_POSITION, light_position); glLightfv (GL_LIGHT1, GL_AMBIENT, ambient); glLightfv (GL_LIGHT1, GL_SPECULAR

19、, specular); glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuse); glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); / 启动深度测试 glEnable(GL_DEPTH_TEST);glDepthFunc(GL_LEQUAL); / 启动自动法线glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); / 启动面剔除功能glEnable(GL_CULL_FACE); / 不渲染一些面的功能启动glFrontFace(GL_CCW);/ 指定正面的方向glCullFac

20、e(GL_BACK); / 不渲染背面 void CALLBACK reshape(GLsizei w, GLsizei h) if (!h) return; glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity();gluPerspective(60.0,w/h,1.0f,2000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity();void CALLBACK display(void)glLoadIdentity(); glClear (GL_COLOR_BUF

21、FER_BIT|GL_DEPTH_BUFFER_BIT);/清除背景glTranslatef(0,0,-1200);glRotated(nAngleX,1,0,0);glRotated(nAngleY,0,1,0);glRotated(nAngleZ,0,0,1); glLineStipple(1, 0x3F07); / 指定点划格式 glEnable(GL_LINE_STIPPLE); / 进入点划模式glBegin(GL_LINES);/ X轴:红 glColor3f (1.0, 0, 0); glVertex3d(-490,0,0);glVertex3d(490,0,0);/ Y轴:绿

22、glColor3f (0.0, 1.0, 0); glVertex3d(0,-490,0);glVertex3d(0,490,0);/ Z轴:蓝 glColor3f (0.0, 0.0, 1); glVertex3d(0,0,-490);glVertex3d(0,0,490);glEnd(); glDisable(GL_LINE_STIPPLE);/离开点划模式glFrontFace(GL_CCW); glColor3f (1.0, 0.0, 0); glPushMatrix();/ 车体glTranslatef(0,210,0);auxSolidBox(600, 20, 400);glPop

23、Matrix();glPushMatrix();/ 左前腿glTranslatef(-260,100,180);auxSolidBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 左后腿glTranslatef(-260,100,-180);auxSolidBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 右前腿glTranslatef(260,100,180);auxSolidBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 右后腿glTranslatef(

24、260,100,-180);auxSolidBox(25, 200, 25);glPopMatrix();glPushMatrix();/ 球glTranslatef(-200,360,0);auxSolidSphere(40);glPopMatrix();glPushMatrix();/ 八面体glTranslatef(-200,360,160);auxSolidOctahedron(40);glPopMatrix();glPushMatrix();/ 圆锥体glTranslatef(-60,300,120);glRotatef(-90,1,0,0);auxSolidCone(60, 100

25、);glPopMatrix();glFrontFace(GL_CW);glPushMatrix();/glTranslatef(60,300,0);glRotatef(40,0,1,0); auxSolidTeapot(70);glPopMatrix();glFrontFace(GL_CCW);glPushMatrix();/glTranslatef(240,362,0); auxSolidCylinder(40,140);glPopMatrix();auxSwapBuffers(); int _tmain(int argc, _TCHAR* argv) auxInitDisplayMode

26、(AUX_DOUBLE | AUX_RGBA|AUX_DEPTH); auxInitPosition (0, 0, 1000, 700); auxInitWindow (透视投影下的光照); myinit ();auxKeyFunc (AUX_LEFT, ClockwiseRotateByY); auxKeyFunc (AUX_RIGHT, CounterClockwiseRotateByY); auxKeyFunc (AUX_UP, ClockwiseRotateByX); auxKeyFunc (AUX_DOWN, CounterClockwiseRotateByX); auxKeyFun

27、c (AUX_D, ClockwiseRotateByZ); auxKeyFunc (AUX_d, ClockwiseRotateByZ); auxKeyFunc (AUX_U, CounterClockwiseRotateByZ); auxKeyFunc (AUX_u, CounterClockwiseRotateByZ);auxReshapeFunc(reshape);/回调函数 auxMainLoop(display); return 0;5.10材质OpenGL用材料对光的红、绿、蓝三原色的反射率来近似定义材料的颜色。象光源一样,材料颜色也分成环境、漫反射和镜面反射成分,它们决定了材料

28、对环境光、漫反射光和镜面反射光的反射程度(或者说成反射系数与前面的理论对应)。在进行光照计算时,材料对环境光的反射率与每个进入光源的环境光相乘,对漫反射光的反射率与每个进入光源的漫反射光相乘,对镜面光的反射率与每个进入光源的镜面反射光相乘。对环境光与漫反射光的反射程度决定了材料的颜色,对镜面反射光的反射率通常是白色或灰色。镜面反射高光最亮的地方将变成具有光源镜面光强度的颜色。例如一个光亮的红色塑料球,球的大部分表现为红色,光亮的高光将是白色的。5.10.1 材质RGB值和光源RGB值的关系对于光源,R、G、B值等于R、G、B对其最大强度的百分比。若光源颜色的R、G、B值都是1.0,则是最强的白

29、光;若值变为0.5,颜色仍为白色,但强度为原来的一半,于是表现为灰色;若RG1.0,B0.0,则光源为黄色。对于材质,R、G、B值为材质对光的R、G、B成分的反射率。比如,一种材质的R1.0、G0.5、B0.0,则材质反射全部的红色成分,一半的绿色成分,不反射蓝色成分。也就是说,若OpenGL的光源颜色为(LR、LG、LB),材质颜色为(MR、MG、MB),那么,在忽略所有其他反射效果的情况下,最终到达眼睛的光的颜色为(LR*MR、LG*MG、LB*MB)。 对于两束光,相应的值分别为(R1、G1、B1)和(R2、G2、B2),则OpenGL将各个颜色成分相加,得到(R1+R2、G1+G2、B

30、1+B2),若任一成分的和值大于1(超出了设备所能显示的亮度)则约简到1.0。5.10.2 材质定义材质的定义与光源的定义类似。其函数为:void glMaterialifv(GLenum face,GLenum pname,TYPE param);定义光照计算中用到的当前材质。face可以是GL_FRONT、GL_BACK、GL_FRONT_AND_BACK,它表明当前材质应该应用到物体的哪一个面上;pname说明一个特定的材质;param是材质的具体数值,若函数为向量形式,则param是一组值的指针,反之为参数值本身。非向量形式仅用于设置GL_SHINESS。pname参数值具体内容见表5

31、-2。另外,参数GL_AMBIENT_AND_DIFFUSE表示可以用相同的RGB值设置环境光颜色和漫反射光颜色。GL_SHINESS值介于0,128之间,值越大,光斑越小,越集中。表5-2 材质参数介绍参数名缺省值说明GL_AMBIENT(0.2, 0.2, 0.2, 1.0)材料的环境光颜色GL_DIFFUSE(0.8, 0.8, 0.8, 1.0)材料的漫反射光颜色GL_AMBIENT_AND_DIFFUSE材料的环境光和漫反射光颜色GL_SPECULAR(0.0, 0.0, 0.0, 1.0)材料的镜面反射光颜色GL_SHINESS0.0镜面指数(光亮度)GL_EMISSION(0.0

32、, 0.0, 0.0, 1.0)材料的辐射光颜色GL_COLOR_INDEXES(0, 1, 1)材料的环境光、漫反射光和镜面光颜色【综合示例EP5-7】材质的综合示例。#include stdafx.hint nAngleY=0;/ 沿Y轴旋转的角度int nAngleX=0;/ 沿X轴旋转的角度int nAngleZ=0;/ 沿Z轴旋转的角度void CALLBACK ClockwiseRotateByX()nAngleX-;void CALLBACK CounterClockwiseRotateByX()nAngleX+;void CALLBACK ClockwiseRotateByZ(

33、)nAngleZ-;void CALLBACK CounterClockwiseRotateByZ()nAngleZ+;void CALLBACK ClockwiseRotateByY()nAngleY-;void CALLBACK CounterClockwiseRotateByY()nAngleY+;void myinit (void) /* 将背景清为白色 */glClearColor (0.0, 0.0,0.0, 1.0);glShadeModel (GL_SMOOTH); GLfloat ambient = 0.0, 0.0, 0.0, 1.0 ; GLfloat specular

34、= 1.0, 1.0, 0.0, 1.0 ; GLfloat diffuse = 1.0, 1.0, 1.0, 1.0 ; GLfloat light_position = 1.0, 1.0, 1.0, 0.0 ; GLfloat lmodel_ambient = 0.4, 0.4, 0.4, 1.0 ; GLfloat mat_specular = 1.0, 1.0, 1.0, 1.0 ; GLfloat mat_shininess = 128.0 ; glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRO

35、NT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT1, GL_POSITION, light_position); glLightfv (GL_LIGHT1, GL_AMBIENT, ambient); glLightfv (GL_LIGHT1, GL_SPECULAR, specular); glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuse); / 指定全局环境光 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient); / 指定视点:GL_TRUE:

36、视点位于(,),GL_FALSE:视点在无穷远glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_FALSE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT1); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST);glEnable(GL_AUTO_NORMAL); glEnable(GL_NORMALIZE); void CALLBACK reshape(GLsizei w, GLsizei h) if (!h) return; glViewport(0, 0, w, h

37、); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w = h) glOrtho (-500.0, 500.0, -500.0*(GLfloat)h/(GLfloat)w, 500.0*(GLfloat)h/(GLfloat)w, -500, 500); else glOrtho (-500.0*(GLfloat)w/(GLfloat)h, 500.0*(GLfloat)w/(GLfloat)h, -500.0, 500.0, -500, 500); glMatrixMode(GL_MODELVIEW);void CALLBACK dis

38、play(void)GLfloat no_mat = 0.0, 0.0, 0.0, 1.0 ;GLfloat mat_ambient = 0.7, 0.7, 0.7, 1.0 ;GLfloat mat_ambient_color = 0.0, 0.8, 0.0, 1.0 ;GLfloat mat_diffuse = 0.1, 0.5, 0.8, 1.0 ;GLfloat mat_specular = 1.0, 1.0, 1.0, 1.0 ;GLfloat no_shininess = 0.0 ;GLfloat low_shininess = 5.0 ;GLfloat high_shinines

39、s = 100.0 ;GLfloat mat_emission = 0.3, 0.2, 0.2, 0.0;glLoadIdentity(); glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);/清除背景glRotated(nAngleX,1,0,0);glRotated(nAngleY,0,1,0);glRotated(nAngleZ,0,0,1); glLineStipple(1, 0x3F07); / 指定点划格式 glEnable(GL_LINE_STIPPLE); / 进入点划模式glBegin(GL_LINES);/ X轴:红 glC

40、olor3f (1.0, 0, 0); glVertex3d(-490,0,0);glVertex3d(490,0,0);/ Y轴:绿 glColor3f (0.0, 1.0, 0); glVertex3d(0,-490,0);glVertex3d(0,490,0);/ Z轴:蓝 glColor3f (0.0, 0.0, 1); glVertex3d(0,0,-490);glVertex3d(0,0,490);glEnd(); glDisable(GL_LINE_STIPPLE);/离开点划模式/* (1,1) draw sphere in first row, first column *

41、diffuse reflection only; no ambient or specular */ glPushMatrix(); glTranslatef (-375, 300, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); glMaterialfv

42、(GL_FRONT, GL_EMISSION, no_mat); auxSolidSphere(100.0); glPopMatrix();/* (1,2) draw sphere in first row, second column * diffuse and specular reflection; low shininess; no ambient */ glPushMatrix(); glTranslatef (-125, 300.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glMaterialfv(GL_FRONT, G

43、L_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); auxSolidSphere(100.0); glPopMatrix();/* (1,3) draw sphere in first row, third column * diffuse and specular reflection; high s

44、hininess; no ambient */ glPushMatrix(); glTranslatef (125, 300.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_EMIS

45、SION, no_mat); auxSolidSphere(100.0); glPopMatrix();/* (1,4) draw sphere in first row, fourth column * diffuse reflection; emission; no ambient or specular reflection */ glPushMatrix(); glTranslatef (375, 300.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat

46、_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); auxSolidSphere(100.0); glPopMatrix();/* (2,1) draw sphere in second row, first column * ambient and diffuse reflection; no specular */ glPush

47、Matrix(); glTranslatef (-375, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); auxSolidSphere(100.

48、0); glPopMatrix();/* (2,2) draw sphere in second row, second column * ambient, diffuse and specular reflection; low shininess */ glPushMatrix(); glTranslatef (-125, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_

49、SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, low_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); auxSolidSphere(100.0); glPopMatrix();/* (2,3) draw sphere in second row, third column * ambient, diffuse and specular reflection; high shininess */ glPushMatrix(); glTranslatef

50、(125, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, no_mat); auxSolidSphere(100.0); glPopMatrix();/* (2,4) draw sphere in second row, fourth column * ambient and diffuse reflection; emission; no specular */ glPushMatrix(); glTranslatef (375, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambi

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论