Advertisement
Void-voiD

Untitled

Mar 28th, 2020
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.66 KB | None | 0 0
  1. @window.event
  2. def on_draw():
  3.     global Width, Height
  4.     global ratio
  5.     global isFramedMode, Changed
  6.     global Horizontal, Vertical, heightOfParaboloid, P, Q
  7.     window.clear()
  8.     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
  9.     glEnable(GL_DEPTH_TEST)
  10.  
  11.     cx = 3
  12.     cy = 3
  13.     cz = 3
  14.  
  15.     p = float(-1) / float(cx)
  16.     q = float(-1) / float(cy)
  17.     r = float(-1) / float(cz)
  18.  
  19.     matrixShift = Matrix([(1, 0, 0, 0),
  20.                           (0, 1, 0, 0),
  21.                           (0, 0, 1, 0),
  22.                           (0.175, 0.175, 0.175, 1)])
  23.     matrixRatio = Matrix([(1 / ratio, 0, 0, 0),
  24.                           (0, 1, 0, 0),
  25.                           (0, 0, 1, 0),
  26.                           (0, 0, 0, 1)])
  27.     matrixPerspective = Matrix([(1, 0, 0, p),
  28.                                 (0, 1, 0, q),
  29.                                 (0, 1, 0, r),
  30.                                 (0, 0, 0, 1)])
  31.     matrixProjection = Matrix([(1, 0, 0, 0),
  32.                                (0, 1, 0, 0),
  33.                                (0, 0, 0, 0),
  34.                                (0, 0, 0, 1)])
  35.     # Matrix.transpose(matrixProjection)
  36.     # Matrix.transpose(matrixPerspective)
  37.     # Matrix.transpose(matrixRatio)
  38.     # Matrix.transpose(matrixShift)
  39.     #matrixFinal = matrixRatio @ matrixShift @ matrixPerspective @ matrixProjection
  40.     matrixFinal = matrixProjection @ matrixPerspective @ matrixShift @ matrixRatio
  41.     #matrixFinal = matrixPerspective @ matrixShift @ matrixRatio
  42.     Matrix.transpose(matrixFinal)
  43.  
  44.     glMatrixMode(GL_PROJECTION)
  45.     value = (GLfloat * 16)()
  46.     for i in range(4):
  47.         for j in range(4):
  48.             value[i * 4 + j] = matrixFinal[i][j]
  49.  
  50.     glLoadMatrixf(value)
  51.     # gluPerspective(40, ratio, 0.1, 100)
  52.     # glOrtho(-ratio, ratio, -1, 1, float(-1), float(1))
  53.  
  54.     glMatrixMode(GL_MODELVIEW)
  55.  
  56.     glEnable(GL_CULL_FACE)
  57.     glFrontFace(GL_CW)
  58.  
  59.     glLoadIdentity()
  60.  
  61.     glPushMatrix()
  62.     # glTranslated(-0.25, -0.25, 0)
  63.     glScaled(0.35, 0.35, 0.35)
  64.     glRotatef(30, 1, 0, 0)
  65.     glRotatef(-30, 0, 1, 0)
  66.     glRotatef(0, 0, 0, 1)
  67.     baseCube(False)
  68.     glPopMatrix()
  69.  
  70.     glMatrixMode(GL_MODELVIEW)
  71.  
  72.     #glDisable(GL_CULL_FACE)
  73.     glEnable(GL_CULL_FACE)
  74.     glFrontFace(GL_CW)
  75.  
  76.     glLoadIdentity()
  77.  
  78.     glPushMatrix()
  79.     glTranslated(pos[0] + 0.775, pos[1] + 0.775, pos[2] + 0.775)
  80.     glScaled(0.7, 0.7, 0.7)
  81.     glRotatef(rot[0], 1, 0, 0)
  82.     glRotatef(rot[1], 0, 1, 0)
  83.     glRotatef(rot[2], 0, 0, 1)
  84.     # baseCube(isFramedMode)
  85.     # dodecahedron(isFramedMode)
  86.     # if Changed:
  87.     #     resetPoints()
  88.     EllepticalParaboloid(isFramedMode)
  89.     Changed = False
  90.  
  91.     glPopMatrix()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement