@@ -33,7 +33,10 @@ def __init__(self, color=np.array(DEFAULT_CAMERA_RGBA), scale=0.05, lineWidth=2)
33
33
[4 , 1 ],
34
34
]
35
35
36
- def render (self , modelMatrix , viewMatrix , projectionMatrix ):
36
+ def render (self , modelMatrix ):
37
+ glPushMatrix ()
38
+ glMultMatrixf (modelMatrix .transpose ())
39
+
37
40
glLineWidth (self .lineWidth )
38
41
glEnable (GL_BLEND )
39
42
glBlendFunc (GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA )
@@ -42,12 +45,6 @@ def render(self, modelMatrix, viewMatrix, projectionMatrix):
42
45
glEnable (GL_DEPTH_TEST )
43
46
glColor4fv (self .color )
44
47
45
- modelView = viewMatrix @ modelMatrix
46
- glMatrixMode (GL_MODELVIEW )
47
- glLoadMatrixf (modelView .transpose ())
48
- glMatrixMode (GL_PROJECTION )
49
- glLoadMatrixf (projectionMatrix .transpose ())
50
-
51
48
glBegin (GL_LINES )
52
49
for edge in self .edges :
53
50
p0 = self .vertices [edge [0 ]]
@@ -59,6 +56,7 @@ def render(self, modelMatrix, viewMatrix, projectionMatrix):
59
56
glDisable (GL_BLEND )
60
57
glDisable (GL_LINE_SMOOTH )
61
58
glDisable (GL_DEPTH_TEST )
59
+ glPopMatrix ()
62
60
63
61
class KeyFrameRenderer :
64
62
def __init__ (self , color = np .array (DEFAULT_KEYFRAME_RGBA ), scale = 0.05 , lineWidth = 2 ):
@@ -75,11 +73,9 @@ def render(self, keyFrameCameraToWorldMatrices, viewMatrix, projectionMatrix):
75
73
76
74
for kfId in keyFrameCameraToWorldMatrices :
77
75
modelMatrix = keyFrameCameraToWorldMatrices [kfId ]
78
- modelView = viewMatrix @ modelMatrix
79
- glMatrixMode (GL_MODELVIEW )
80
- glLoadMatrixf (modelView .transpose ())
81
- glMatrixMode (GL_PROJECTION )
82
- glLoadMatrixf (projectionMatrix .transpose ())
76
+
77
+ glPushMatrix ()
78
+ glMultMatrixf (modelMatrix .transpose ())
83
79
84
80
glBegin (GL_LINES )
85
81
for edge in self .cameraWireframe .edges :
@@ -88,6 +84,7 @@ def render(self, keyFrameCameraToWorldMatrices, viewMatrix, projectionMatrix):
88
84
glVertex3f (p0 [0 ], p0 [1 ], p0 [2 ])
89
85
glVertex3f (p1 [0 ], p1 [1 ], p1 [2 ])
90
86
glEnd ()
87
+ glPopMatrix ()
91
88
92
89
glDisable (GL_BLEND )
93
90
glDisable (GL_LINE_SMOOTH )
@@ -255,15 +252,8 @@ def append(self, position):
255
252
if self .maxLength is not None and len (self .poseTrail ) > self .maxLength :
256
253
self .poseTrail .pop (0 )
257
254
258
- def render (self , viewMatrix , projectionMatrix ):
259
- modelView = viewMatrix # pose trail is already in world coordinates -> model matrix is identity
260
-
255
+ def render (self ):
261
256
glLineWidth (self .lineWidth )
262
- glMatrixMode (GL_MODELVIEW )
263
- glLoadMatrixf (modelView .transpose ())
264
- glMatrixMode (GL_PROJECTION )
265
- glLoadMatrixf (projectionMatrix .transpose ())
266
-
267
257
glEnable (GL_BLEND )
268
258
glBlendFunc (GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA )
269
259
glEnable (GL_LINE_SMOOTH )
@@ -289,13 +279,7 @@ def __init__(self, radius=20, length=1.0, color=np.array(DEFAULT_GRID_RGBA), ori
289
279
self .lineWidth = lineWidth
290
280
self .bounds = [- radius * length , radius * length ]
291
281
292
- def render (self , viewMatrix , projectionMatrix ):
293
- modelView = viewMatrix # grid is defined in world coordinates
294
- glMatrixMode (GL_MODELVIEW )
295
- glLoadMatrixf (modelView .transpose ())
296
- glMatrixMode (GL_PROJECTION )
297
- glLoadMatrixf (projectionMatrix .transpose ())
298
-
282
+ def render (self ):
299
283
glLineWidth (self .lineWidth )
300
284
glEnable (GL_BLEND )
301
285
glBlendFunc (GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA )
@@ -389,15 +373,11 @@ def __init__(self, projectionMatrix, color=np.array(DEFAULT_FRUSTUM_RGBA)):
389
373
]
390
374
]
391
375
392
- def render (self , modelMatrix , viewMatrix , projectionMatrix , render2d ):
393
- modelView = viewMatrix @ modelMatrix
376
+ def render (self , modelMatrix , render2d ):
377
+ glPushMatrix ()
378
+ glMultMatrixf (modelMatrix .transpose ())
394
379
395
380
glLineWidth (1 )
396
- glMatrixMode (GL_MODELVIEW )
397
- glLoadMatrixf (modelView .transpose ())
398
- glMatrixMode (GL_PROJECTION )
399
- glLoadMatrixf (projectionMatrix .transpose ())
400
-
401
381
glEnable (GL_DEPTH_TEST )
402
382
glEnable (GL_BLEND )
403
383
glBlendFunc (GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA )
@@ -413,6 +393,7 @@ def render(self, modelMatrix, viewMatrix, projectionMatrix, render2d):
413
393
glEnd ()
414
394
415
395
glDisable (GL_DEPTH_TEST )
396
+ glPopMatrix ()
416
397
417
398
def createPlaneMesh (scale , position , color ):
418
399
# 3 ---- 2
0 commit comments