Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @window.event
- def on_draw():
- global Width, Height
- global ratio
- global isFramedMode, Changed
- global Horizontal, Vertical, heightOfParaboloid, P, Q
- window.clear()
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
- glEnable(GL_DEPTH_TEST)
- cx = 3
- cy = 3
- cz = 3
- p = float(-1) / float(cx)
- q = float(-1) / float(cy)
- r = float(-1) / float(cz)
- matrixShift = Matrix([(1, 0, 0, 0),
- (0, 1, 0, 0),
- (0, 0, 1, 0),
- (0.175, 0.175, 0.175, 1)])
- matrixRatio = Matrix([(1 / ratio, 0, 0, 0),
- (0, 1, 0, 0),
- (0, 0, 1, 0),
- (0, 0, 0, 1)])
- matrixPerspective = Matrix([(1, 0, 0, p),
- (0, 1, 0, q),
- (0, 1, 0, r),
- (0, 0, 0, 1)])
- matrixProjection = Matrix([(1, 0, 0, 0),
- (0, 1, 0, 0),
- (0, 0, 0, 0),
- (0, 0, 0, 1)])
- # Matrix.transpose(matrixProjection)
- # Matrix.transpose(matrixPerspective)
- # Matrix.transpose(matrixRatio)
- # Matrix.transpose(matrixShift)
- #matrixFinal = matrixRatio @ matrixShift @ matrixPerspective @ matrixProjection
- matrixFinal = matrixProjection @ matrixPerspective @ matrixShift @ matrixRatio
- #matrixFinal = matrixPerspective @ matrixShift @ matrixRatio
- Matrix.transpose(matrixFinal)
- glMatrixMode(GL_PROJECTION)
- value = (GLfloat * 16)()
- for i in range(4):
- for j in range(4):
- value[i * 4 + j] = matrixFinal[i][j]
- glLoadMatrixf(value)
- # gluPerspective(40, ratio, 0.1, 100)
- # glOrtho(-ratio, ratio, -1, 1, float(-1), float(1))
- glMatrixMode(GL_MODELVIEW)
- glEnable(GL_CULL_FACE)
- glFrontFace(GL_CW)
- glLoadIdentity()
- glPushMatrix()
- # glTranslated(-0.25, -0.25, 0)
- glScaled(0.35, 0.35, 0.35)
- glRotatef(30, 1, 0, 0)
- glRotatef(-30, 0, 1, 0)
- glRotatef(0, 0, 0, 1)
- baseCube(False)
- glPopMatrix()
- glMatrixMode(GL_MODELVIEW)
- #glDisable(GL_CULL_FACE)
- glEnable(GL_CULL_FACE)
- glFrontFace(GL_CW)
- glLoadIdentity()
- glPushMatrix()
- glTranslated(pos[0] + 0.775, pos[1] + 0.775, pos[2] + 0.775)
- glScaled(0.7, 0.7, 0.7)
- glRotatef(rot[0], 1, 0, 0)
- glRotatef(rot[1], 0, 1, 0)
- glRotatef(rot[2], 0, 0, 1)
- # baseCube(isFramedMode)
- # dodecahedron(isFramedMode)
- # if Changed:
- # resetPoints()
- EllepticalParaboloid(isFramedMode)
- Changed = False
- glPopMatrix()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement