-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatepaintGL.py
59 lines (49 loc) · 1.57 KB
/
updatepaintGL.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
from PyQt4 import QtCore, QtGui
from PyGLWidget import PyGLWidget
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
class GLWidget(PyGLWidget):
def paintGL(self):
PyGLWidget.paintGL(self)
# self.lights()
scale = 8
glColor3f(1,0,0)
#glEnable(GL_BLEND)
#glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
#gluSphere(gluNewQuadric(),0.95/scale, 20, 20)
glColor(0,0,1)
glPointSize(3)
# glDisable(GL_LIGHTING)
glBegin(GL_POINTS)
#glPoint(1,1,1)
for location in self.location:
glVertex3f(location[0]/scale,location[1]/scale,location[2]/scale)
glEnd()
for line in self.lines:
glColor(0, 1, 0)
glLineWidth(4)
glBegin(GL_LINES)
glVertex3f(line[0][0]/scale,line[0][1]/scale,line[0][2]/scale)
glVertex3f(line[1][0]/scale,line[1][1]/scale,line[1][2]/scale)
glEnd()
# glEnable(GL_LIGHTING)
def lights(self):
glMatrixMode(GL_MODELVIEW)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glEnable(GL_COLOR_MATERIAL)
light0_pos = 200.0, 200.0, 300.0, 0
diffuse0 = 1.0, 1.0, 1.0, 1.0
specular0 = 1.0, 1.0, 1.0, 1.0
ambient0 = 0, 0, 0, 1
glMatrixMode(GL_MODELVIEW)
glLightfv(GL_LIGHT0, GL_POSITION, light0_pos)
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0)
glLightfv(GL_LIGHT0, GL_SPECULAR, specular0)
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0)
def update(self,p):
self.location = p
def drawLines(self,p1,p2):
self.lines.append([p1,p2])