We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi. I'd like to copy the projection and modelView matrices from one PGraphics into another one so I can render different passes of the same scene no matter what camera library is in use.
I have tried using get() and set() of both matrices like this (and different alternatives like projmodelView and combinatins of set() and apply() ):
PMatrix3D modelView = ((PGraphicsOpenGL) pgSrc).modelview.get();
PMatrix3D projection = ((PGraphicsOpenGL) pgSrc).projection.get();
((PGraphicsOpenGL) pgDst).projection.set(projection);
((PGraphicsOpenGL) pgDst).modelview.set(modelView);
I also tried the pure OpenGL calls from the method copyMatrices() from here
None of them worked. I can reuse the same PGraphics for each pass, but this would be more convenient. Does anyone know how it should be done?
Thanks!
Answers
This could potentially help: https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L13584
Kf
Thanks @kfrajer, the method applyMatrix() works on the destination buffer. but somehow its not replicating the source buffer view.
I tried using the projModelView matrix from source and its transpose, but it seems that just getting the matrix breaks the source buffer camera settings (ie, the scene disappears from camera's view)