- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
画球 opengl(画球OpenGL)
画球 opengl(画球OpenGL)
#包括 GL /过剩。”
#包括数学。”
#包括 stdio. h
#包括程序。”
#包括 iostream。”
#包括时间。”
#定义PI 3.1415926
#定义GLfloat浮
#定义gldouble双
# int定义闪烁
双C =π/ 180;
双半径= 100;//球半径
int W = 1000,H = 800;//窗口的宽和高
int Angley X = 10,= 10;//角度
双oldcenterx,oldcentery,集中式交换,世纪,centerz;
int num = 1;//球的数量
国际fill_mode = gl_line;/ /显示面只用线表示
双步= 10;
长的开始时间= 0;
time_t T;
国际风格= gl_quad_strip;/ /四边形带
国际色彩;/ /单色,多色
浮phir,θ,φ,thetar,phir20;
x,y,z;
双C80;
int i;
颜色= 0;
无效drawsphere(int集中式交换,int世纪,int centerz){
/ /选择当前操作的矩阵gl_modelview为模型视图矩阵。
glMatrixMode(gl_modelview);
4 / 4单位矩阵乘将当前矩阵设置为
glloadidentity();
/ /平移变换
gltranslated(集中式交换,世纪,centerz);
/ /旋转变换从(0,0,0)到(0,1,0)逆时针方向旋转45°,易于观察
glrotated(45,0,1,0);
glrotated(Angley,1,0,0);
glrotated(X,0,0,1);
C80 = C * 80;
/ /定义视口,前两个0为左下角坐标,W和H为视口的宽度和高度
glviewport(0,0,(gldouble)W(gldouble)H);
为(φ= 90;φ≤90;φ=步){
phir = C *披;
phir20 = C *(φ20);
/ / glpolygonmode函数用于控制多边形的显示方式。
glpolygonmode(gl_front,fill_mode);/ / gl_front表示显示模式将适用于物体的前向面(也就是物体能看到的面)
glpolygonmode(gl_back,fill_mode);/ / gl_fill表示显示面(gl_point表示只显示顶点,gl_line表示显示线段)
/ /设置CCW方向为”正面”,
glfrontface(gl_ccw);
glBegin(风格);
为(θ= 180;θ = 180;θ=步){
thetar = C *θ;
X =半径*罪(thetar)* cos(phir);
Y =半径×cos(thetar)* cos(phir);
Z =半径*罪(phir);
/ /随机分配颜色。
如果(彩色)
/ / glColor3f(255255255);
glColor3f((rand() % 101 * 1)/ 100、(rand() % 101 * 1)/ 100、(rand() % 101 * 1)/ 100);
glvertex3d(x,y,z);
X =半径*罪(thetar)* cos(phir20);
Y =半径×cos(thetar)* cos(phir20);
Z =半径*罪(phir20);
glvertex3d(x,y,z);
}
glend();
}
如果(风格= = gl_triangles | |风格= = gl_quads){
为(φ= 90;φ≤90;φ=步){
phir = C *披;
glpolygonmode(gl_front,fill_mode);
glpolygonmode(gl_back,fill_mode);
glfrontface(gl_ccw);
glBegin(gl_polygon);
为(θ= 180;θ = 180;θ=步){
thetar = C *θ;
X =半径*罪(thetar)* cos(phir);
Y =半径×cos(thetar)* cos(phir);
Z =半径*罪(phir);
/ /随机分配颜色。
如果(彩色)
/ / glColor3f(255255255);
glcolor3f (rand ()% of 101 * 1.0) / 100 (rand ()% of 101 * 1.0) / 100 (rand ()% of 101 * 1.0) / 100);
glvertex3d (x, y, z).
}
glend ();
}
}
glpolygonmode (gl _ front, fill _ mode);
glpolygon
您可能关注的文档
- 理工女如何避开招聘会性别差异对待(How to avoid physical Gongnv fair sex differences).doc
- 班长绩效考核细则(Monitor performance appraisal rules).doc
- 理想到现实的回归(The regression of ideal and reality).doc
- 理解文化差异培养跨文化意识—浅析英语学习中的跨文化交际(To understand cultural differences and the cultivation of cross cultural awareness on English learning in intercultural communication).doc
- 理解回调机制(Understand the callback mechanism).doc
- 理论题-单选题(The theory of problem - RadioButtonList).doc
- 班级格言和班训以及班规 - jsq51890803的日志 - 网易博客(The class motto and training classes and class - jsq51890803 log - NetEase blog).doc
- 琥珀的品种及划分(The variety and division of amber).doc
- 瑜伽师资素质研讨(Yoga teacher quality research).doc
- 瑞士的幼儿园制度(The Swiss kindergarten system).doc
- 畜禽新品种配套系审定和畜禽遗传资源鉴定办法(New varieties of livestock and poultry supporting the Department of examination and identification of the genetic resources of livestock and poultry measures).doc
- 电路设计经验总结(Circuit design experience).doc
- 略论美国小都市区(On the metropolitan area).doc
- 略谈特种加工技术—激光焊接(On the special processing technology of laser welding).doc
- 番发广场装修改造工程设计(Punfet square renovation project design).doc
- 疾走!改善酸性身体(Improve the body acidic scurry!).doc
- 病历书写与教学查房(Medical writing and teaching rounds).doc
- 病史及症状(History and symptoms).doc
- 病理生理大题11(Question 11 pathophysiology).doc
- 病因辩证(The cause of dialectic).doc
文档评论(0)