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

  • 大小: 252KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-05-18
  • 語(yǔ)言: 其他
  • 標(biāo)簽: openGL??球體??

資源簡(jiǎn)介

繪制若干OpenGL基本體素(三角形、三角形帶、四邊形、四邊形帶)構(gòu)成的球體,注意球體繪制與球體劃分的區(qū)別。 ? 可以控制改變球的數(shù)量和球的體積,來(lái)改變基本體素的數(shù)量以及頂點(diǎn)的數(shù)量。 ? 可以通過(guò)改變glPolygonMode,切換是否填充所繪制的基本體素。 ? 利用函數(shù)glutGet(GLUT_ELAPSED_TIME)(returns the time in milliseconds since glutInit or the first invocation of the function)統(tǒng)計(jì)繪制時(shí)間

資源截圖

代碼片段和文件信息

#include?
#include
#include
#include
#include?
#include?

#define?PI?3.1415926
#define?GLfloat?float
#define?GLdouble?double
#define?GLint?int

double?c=PI/180.0;
double?radius=100.0;//球半徑
int?w=500.0h=500.0;//窗口的寬和高
int?angleX=10angleY=10;//角度
double?oldcenterxoldcenterycenterxcenterycenterz;
int?num=1;
int?fill_mode=GL_LINE;//顯示面只用線表示
double?step=10;
long?timeStart=0;
time_t?t;
int?style=GL_QUAD_STRIP;//四邊形帶
int?color;
color=1;
float?thetaphirphithetarphir20;
float?xyz;
double?c80;
int?i;

void?drawSphere(int?centerxint?centeryint?centerz){

//選擇當(dāng)前操作的矩陣。GL_MODELVIEW為模型視圖矩陣
glMatrixMode(GL_MODELVIEW);
????//將當(dāng)前矩陣設(shè)置為4乘4單位矩陣
glLoadIdentity();
????//平移變換
glTranslated(centerxcenterycenterz);

????//旋轉(zhuǎn)變換從(0,0,0)到(0,1,0)逆時(shí)針?lè)较蛐D(zhuǎn)45°
glRotated(45010);
glRotated(angleY100);
glRotated(angleX001);


c80=c*80;

//定義視口,前兩個(gè)0為左下角坐標(biāo),w和h為視口的寬度和高度
glViewport(00(GLdouble)w(GLdouble)h);

for(phi=-90;phi<=90;phi+=step){
???phir???=?c*phi;
???phir20?=?c*(phi+20);

???//glPolygonMode函數(shù)用于控制多邊形的顯示方式。
????glPolygonMode(GL_FRONTfill_mode);//GL_FRONT表示顯示模式將適用于物體的前向面(也就是物體能看到的面)
?????glPolygonMode(GL_BACKfill_mode);//GL_FILL表示顯示面(GL_POINT表示只顯示頂點(diǎn)GL_LINE表示顯示線段)
????????
???//設(shè)置CCW方向?yàn)椤罢妗保?br/>???glFrontFace(GL_CCW);
???glBegin(style);
???for(theta=-180;theta<=180;theta+=step){
????thetar?=?c*theta;
????x=radius*sin(thetar)*cos(phir);
????y=radius*cos(thetar)*cos(phir);
????z=radius*sin(phir);
????//隨機(jī)分配顏色。
????if(color)
?????glColor3f((rand()%101*1.0)/100(rand()%101*1.0)/100(rand()%101*1.0)/100);
????glVertex3d(xyz);
????x=radius*sin(thetar)*cos(phir20);
????y=radius*cos(thetar)*cos(phir20);
????z=radius*sin(phir20);
????glVertex3d(xyz);
???}
???glEnd();
}


if(style==GL_TRIANGLES?||?style==GL_QUADS){
??

????for(phi=-90;phi<=90;phi+=step){
????phir???=?c*phi;
???
????glPolygonMode(GL_FRONTfill_mode);
????glPolygonMode(GL_BACKfill_mode);
????glFrontFace(GL_CCW);
????glBegin(GL_POLYGON);
????for(theta=-180;theta<=180;theta+=step){
?????thetar?=?c*theta;
?????x=radius*sin(thetar)*cos(phir);
?????y=radius*cos(thetar)*cos(phir);
?????z=radius*sin(phir);
?????//隨機(jī)分配顏色。
?????if(color)
??????glColor3f((rand()%101*1.0)/100(rand()%101*1.0)/100(rand()%101*1.0)/100);
?????glVertex3d(xyz);
????}
????glEnd();

????}
}

glPolygonMode(GL_FRONTfill_mode);
glPolygonMode(GL_BACKfill_mode);
glFrontFace(GL_CCW);
glBegin(GL_TRIANGLE_FAN);//畫扇形
glVertex3d(00radius);
z?=?radius*sin(c80);
for(theta=-180;theta<=180;theta+=step){
???thetar?=?c*theta;
???x=radius*sin(thetar)*cos(c80);
???y=radius*cos(thetar)*cos(c80);
???if(color)
????glColor3f((rand()%101*1.0)/100(rand()%101*1.0)/100(rand()%101*1.0)/100);

???glVertex3d(xyz);
}
glEnd();
glBegin(GL_TRIANGLE_FAN);
glVertex3d(00-radius);
z=-radius*sin(c80);
for(theta=-180.0;theta<=180.0;theta+=step){
???thetar?=?c*theta;
???x=r

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件?????221230??2010-11-08?11:26??lab1\Debug\lab1.exe

?????文件?????266756??2010-11-08?11:26??lab1\Debug\lab1.ilk

?????文件?????329808??2010-11-08?11:26??lab1\Debug\lab1.pch

?????文件?????418816??2010-11-08?11:26??lab1\Debug\lab1.pdb

?????文件??????28714??2010-11-08?11:26??lab1\Debug\ss.obj

?????文件??????33792??2010-11-25?19:16??lab1\Debug\vc60.idb

?????文件??????45056??2010-11-08?11:26??lab1\Debug\vc60.pdb

?????文件???????4256??2010-11-08?11:26??lab1\lab1.dsp

?????文件????????533??2010-11-08?11:25??lab1\lab1.dsw

?????文件??????41984??2010-11-25?19:16??lab1\lab1.ncb

?????文件??????53760??2010-11-25?19:16??lab1\lab1.opt

?????文件???????1722??2010-11-08?11:26??lab1\lab1.plg

?????文件???????8490??2010-11-08?11:26??lab1\ss.c

?????目錄??????????0??2010-11-30?21:02??lab1\Debug

?????目錄??????????0??2010-11-30?21:02??lab1

-----------?---------??----------?-----??----

??????????????1454917????????????????????15


評(píng)論

共有 條評(píng)論