from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
dX = 0.0
dY = 0.0
alphaX = 0.0
alphaY = 0.0
alphaZ = 0.0
sf = 0.0
def init():
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(-4.0 * 64 / 48.0, 4.0 * 64 / 48, -4.0, 4.0, 0.0, 10)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
gluLookAt(4.0, 2.0, 4.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
glViewport(0, 0, 640, 480)
def axis(length):
glPushMatrix()
glBegin(GL_LINES)
glVertex3d(0, 0, 0)
glVertex3d(0, 0, length)
glEnd()
glTranslated(0, 0, length - 0.2)
glutWireCone(0.04, 0.2, 12, 9)
glPopMatrix()
def displayWire():
glClear(GL_COLOR_BUFFER_BIT)
glClearColor(0.0, 0.0, 0.0, 0.0)
glPushMatrix()
glTranslated(0.0, 0.0, 0.0)
glRotated(alphaY, 0.0, 1.0, 0.0)
glRotated(alphaX, 1.0, 0.0, 0.0)
glRotated(alphaZ, 0.0, 0.0, 1.0)
glTranslated(dY, 0.0, 1.0)
glTranslated(dX, 1.0, 0.0)
glPushMatrix()
glColor3d(0.0, 0.0, 1.0)
axis(2.0)
glRasterPos3f(0.0, 0.0, 2.3)
glRotated(-90, 1.0, 0.0, 0.0)
glColor3d(0.0, 1.0, 0.0)
axis(2.0)
glRasterPos3f(0.0, 0.0, 2.3)
glColor3d(1.0, 0.0, 0.0)
glRotated(90, 0.0, 1.0, 0.0)
axis(2.0)
glRasterPos3f(0.0, 0.0, 2.3)
glPopMatrix()
glColor3d(1.0, 1.0, 0.0)
glScaled(1.5, 1.5, 1.5)
glPushMatrix()
glColor3d(1.0, 1.0, 1.0)
glTranslated(0.0, 1.5, 0.0)
glScaled(1 + sf, 1 + sf, 1 + sf)
glRotated(360, 0, 1, 0)
glutWireSphere(0.35, 30, 30)
glPopMatrix()
glPushMatrix()
glColor3d(1.0, 1.0, 0.0)
glRotated(120, 0, 1, 0)
glScaled(1 + sf, 1 + sf, 1 + sf)
glTranslated(0.0, 0.5, 1.0)
glutWireCube(0.35)
glPopMatrix()
glPushMatrix()
glColor3d(0.0, 1.0, 1.0)
glRotated(290, 0, 1, 0)
glScaled(1 + sf, 1 + sf, 1 + sf)
glTranslated(0.0, 0.5, 1.0)
glutWireCube(0.35)
glPopMatrix()
glPushMatrix()
glColor3d(1.0, 0.0, 1.0)
glTranslated(0.0, 0.0, 0.0)
glScaled(1 + sf, 1 + sf, 1 + sf)
glRotated(-90.0, 1, 0, 0)
qobj = gluNewQuadric()
gluQuadricDrawStyle(qobj, GLU_LINE)
gluCylinder(qobj, 0.50, 0.50, 0.80, 30, 30)
glPopMatrix()
glPopMatrix()
glutSwapBuffers()
def mySpecialKey(key, x, y):
if (key == GLUT_KEY_RIGHT):
global alphaX
alphaX += 5.0
if (key == GLUT_KEY_LEFT):
global alphaZ
alphaZ -= 5.0
if (key == GLUT_KEY_UP):
global alphaY
alphaY += 5.0
if (key == GLUT_KEY_DOWN):
global alphaY
alphaY -= 5.0
glutPostRedisplay()
def keyboard(key, x, y):
if key == 'a':
global dY
dY += 0.5
glutPostRedisplay()
if __name__ == '__main__':
glutInit()
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
glutInitWindowSize(640, 640)
glutInitWindowPosition(100, 100)
glutCreateWindow("a")
glutDisplayFunc(displayWire)
glutSpecialFunc(mySpecialKey)
glutKeyboardFunc(keyboard)
init()
glutMainLoop()
没有合适的资源?快使用搜索试试~ 我知道了~
Python 实现3D建模工具.zip
共1个文件
py:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 48 浏览量
2023-07-31
22:42:21
上传
评论 2
收藏 1KB ZIP 举报
温馨提示
Python 实现3D建模工具.zip
资源推荐
资源详情
资源评论
收起资源包目录
Python 实现3D建模工具.zip (1个子文件)
py-3D.py 3KB
共 1 条
- 1
资源评论
小嗷犬
- 粉丝: 2w+
- 资源: 1334
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- ItemApplicationTest.java
- 个人发卡源码,发卡系统,二次元发卡系统,二次元发卡源码,发卡程序,动漫发卡,PHP发卡源码,异次元发卡
- 基于matlab 决策树分类器的应用研究-乳腺癌诊断源代码+详细教程
- 2008全国电子设计竞赛优秀作品报告doc文档.zip
- 课程智能组卷系统 JAVA+Spring+SpringMVC+MyBatis
- 基于matlab LVQ神经网络的预测-人脸朝向识别源代码+详细教程
- Controlnet敏神大佬IC-Light的AI智能打光 AI这次真的大地震了
- 医院电子病历管理系统 JAVA+Spring+SpringMVC+MyBatis
- 基于matlab LVQ神经网络的分类-乳腺肿瘤诊断源代码+详细教程
- 【C#/.NET/.NET Core学习、工作、面试指南】记录、收集和总结
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功