@@ -215,6 +215,9 @@ class VisualizerArgs:
215
215
# Recording
216
216
recordPath = None # Record the window to video file given by path
217
217
218
+ # Callbacks
219
+ customRenderCallback = None # Used to render custom OpenGL objects in user code
220
+
218
221
class Recorder :
219
222
def __init__ (self , recordPath , resolution ):
220
223
import subprocess
@@ -245,6 +248,8 @@ def __init__(self, args=VisualizerArgs()):
245
248
self .outputQueue = []
246
249
self .outputQueueMutex = Lock ()
247
250
self .clock = pygame .time .Clock ()
251
+ self .projectionMatrix = None
252
+ self .viewMatrix = None
248
253
249
254
# Window
250
255
self .fullScreen = args .fullScreen
@@ -371,9 +376,13 @@ def __render(self, cameraPose, width, height, image=None, colorFormat=None):
371
376
top = 25.0 * self .cameraControls2D .zoom / self .aspectRatio
372
377
projectionMatrix = getOrthographicProjectionMatrixOpenGL (left , right , bottom , top , - 1000.0 , 1000.0 )
373
378
379
+ self .projectionMatrix = projectionMatrix
380
+ self .viewMatrix = viewMatrix
381
+
374
382
self .map .render (cameraPose .getPosition (), viewMatrix , projectionMatrix )
375
383
if self .showGrid : self .grid .render (viewMatrix , projectionMatrix )
376
384
if self .showPoseTrail : self .poseTrail .render (viewMatrix , projectionMatrix )
385
+ if self .args .customRenderCallback : self .args .customRenderCallback ()
377
386
378
387
if self .cameraMode in [CameraMode .THIRD_PERSON , CameraMode .TOP_VIEW ]:
379
388
modelMatrix = cameraPose .getCameraToWorldMatrix ()
@@ -539,6 +548,12 @@ def run(self):
539
548
540
549
self .__close ()
541
550
551
+ def getProjectionMatrix (self ):
552
+ return self .projectionMatrix
553
+
554
+ def getViewMatrix (self ):
555
+ return self .viewMatrix
556
+
542
557
def printHelp (self ):
543
558
print ("Control using the keyboard:" )
544
559
print ("* Q: Quit" )
0 commit comments