PyOpenGL 서피스 만들기
7944 단어 python
#encoding=utf8
from OpenGL.GL import *
from OpenGL.GLUT import *
a=0
ctrlPoints=[]
ctrlPoints= [
[[-0.5,0.5,0],[0.5,0.5,0]],
[[-0.5,0,0.5],[0.5,0,0.5]],
[[-0.25,-0.5,0.25],[0.25,-0.5,0.25]]
]
ctrlPoints1= [
[[-0.5,0.5,0],[0.5,0.5,0]],
[[-0.5,0,0],[0.5,0,0]],
[[-0.25,-0.5,0],[0.25,-0.5,0]]
]
ctrlPoints2= [
[[-0.5,0.5,0],[-0.5,0.5,0]],
[[-0.5,0,0],[-0.5,0,0.5]],
[[-0.25,-0.5,0],[-0.25,-0.5,0.25]]
]
ctrlPoints3= [
[[0.5,0.5,0],[0.5,0.5,0]],
[[0.5,0,0],[0.5,0,0.5]],
[[0.25,-0.5,0],[0.25,-0.5,0.25]]
]
ctrlPoints4= [
[[-0.25,-0.5,0.25],[-0.25,-0.5,0]],
[[0,-0.5,0.25],[0,-0.5,0]],
[[0.25,-0.5,0.25],[0.25,-0.5,0]]
]
xaxis=0.0
yaxis=0.0
zaxis=0.0
def keyboard(key, w, h):
global xaxis,yaxis,zaxis
if (key=='x'):
glRotatef(10, 1, 0, 0)
if (key=='y'):
glRotatef(10, 0, 1, 0)
if (key=='z'):
glRotatef(10, 0, 0, 1)
def RenderScene():
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT)
glColor3f(0.0, 0.0, 0.0)
glPushMatrix()
glEnable(GL_MAP2_VERTEX_3)
glMap2f(GL_MAP2_VERTEX_3, 0, 10, 0, 10, ctrlPoints)
glMapGrid2f(10, 0.0, 10.0, 10, 0.0, 10.0)
glEvalMesh2(GL_FILL, 0, 10, 0, 10)
glEnable(GL_MAP2_VERTEX_3)
glMap2f(GL_MAP2_VERTEX_3, 0, 10, 0, 10, ctrlPoints1)
glMapGrid2f(10, 0.0, 10.0, 10, 0.0, 10.0)
glEvalMesh2(GL_FILL, 0, 10, 0, 10)
glEnable(GL_MAP2_VERTEX_3)
glMap2f(GL_MAP2_VERTEX_3, 0, 10, 0, 10, ctrlPoints2)
glMapGrid2f(10, 0.0, 10.0, 10, 0.0, 10.0)
glEvalMesh2(GL_FILL, 0, 10, 0, 10)
glEnable(GL_MAP2_VERTEX_3)
glMap2f(GL_MAP2_VERTEX_3, 0, 10, 0, 10, ctrlPoints3)
glMapGrid2f(10, 0.0, 10.0, 10, 0.0, 10.0)
glEvalMesh2(GL_FILL, 0, 10, 0, 10)
glEnable(GL_MAP2_VERTEX_3)
glMap2f(GL_MAP2_VERTEX_3, 0, 10, 0, 10, ctrlPoints4)
glMapGrid2f(10, 0.0, 10.0, 10, 0.0, 10.0)
glEvalMesh2(GL_FILL, 0, 10, 0, 10)
glFlush()
glPopMatrix()
glutSwapBuffers()
glutInit()
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE)
glutInitWindowPosition(100, 100)
glutInitWindowSize(400, 400)
glutCreateWindow("HiddenStrawberry")
mat_ambient= [0.5,0.0,1.0,0.5]
mat_diffuse= [1.0,0.6,1.0,1.0]
mat_specular= [1.0,1.0,1.0,1.0]
light_ambient= [0.1,0.1,0.1,1.0]
light_diffuse= [1.0,1.0,1.0,0.0]
light_specular= [0.5,1.0,1.0,0.0]
light_position= [-2.0,-5.0,-5.0,1.0]
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient)
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse)
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular)
glMaterialf(GL_FRONT,GL_SHININESS,60.0)
glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient)
glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse)
glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular)
glLightfv(GL_LIGHT0,GL_POSITION,light_position)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glEnable(GL_DEPTH_TEST)
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
glHint(GL_LINE_SMOOTH_HINT,GL_DONT_CARE)
glEnable(GL_BLEND)
glEnable(GL_AUTO_NORMAL)
glEnable(GL_NORMALIZE)
glFrontFace(GL_CW)
glShadeModel(GL_SMOOTH)
glEnable(GL_LINE_SMOOTH)
glutDisplayFunc(RenderScene)
glutIdleFunc(RenderScene)
glutKeyboardFunc(keyboard)
glutMainLoop()
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
로마 숫자를 정수로 또는 그 반대로 변환그 중 하나는 로마 숫자를 정수로 변환하는 함수를 만드는 것이었고 두 번째는 그 반대를 수행하는 함수를 만드는 것이었습니다. 문자만 포함합니다'I', 'V', 'X', 'L', 'C', 'D', 'M' ; 문자열이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.