We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › reading the modeling/view matrix in Processing
Page Index Toggle Pages: 1
reading the modeling/view matrix in Processing (Read 763 times)
reading the modeling/view matrix in Processing
Jun 25th, 2006, 6:40am
 
First question:  Is it possible to read back the transformation matrix in Processing?  I know that you can printCamera() and printProjection to display it on the screen, but is there a way to get this into an array so that you can use this information within your program?

Second question:  Is there a way to read the z-buffer in Processing?
Re: reading the modeling/view matrix in Processing
Reply #1 - Jun 25th, 2006, 12:20pm
 
1st:

http://processing.org/reference/printMatrix_.html

http://processing.org/reference/applyMatrix_.html

http://processing.org/reference/resetMatrix_.html
Re: reading the modeling/view matrix in Processing
Reply #2 - Jun 25th, 2006, 9:22pm
 
Thanks for the links, but I need to be able to get the projection and modelview matrix values into arrays or variables so that I can actual do my own computation on them, not just view them on the screen.

As for the second question, I found my answer.  I can use g.zbuffer[y*width+x].  As for properly interpreting the z-buffer values, I need to know the projection matrix.
Re: reading the modeling/view matrix in Processing
Reply #3 - Jun 25th, 2006, 11:26pm
 
The values of the matrix are stored in a PMatrix instance called modelview that is inside "g", the applet display image.

Since this is digging around in the developers back garden, I warn you that they may start to restructure things on a whim and you may find your code not working in future.

Anyway, now that you've been warned:
Code:

void setup(){
size(100,100,P3D);
println(g.modelview.m00);
}

Each of the 16 matrix entries are named m00, m01, m02, etc. See the following source for illumination.

http://dev.processing.org/source/index.cgi/trunk/processing/core/PGraphics3.java?rev=2286&view=markup
Re: reading the modeling/view matrix in Processing
Reply #4 - Jun 26th, 2006, 5:18am
 
Thank you.  That's what I was looking for.
Page Index Toggle Pages: 1