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.
Page Index Toggle Pages: 1
Matrix access (Read 1140 times)
Matrix access
May 27th, 2005, 6:44pm
 
Does anyone know how to access the individual elements of the current matrix??

It used to be Code:
g.m01, g.m02, g.m03... etc. 



printMatrix(); gives the current status to the monitor. I just need the variable names.

Thanks.
Re: Matrix access
Reply #1 - May 27th, 2005, 7:56pm
 
I believe it's this:
this.g.m00
but i could only output: m00,m01, m02, m10, m11, m12..
don't know if that's all you need...
Re: Matrix access
Reply #2 - May 27th, 2005, 8:02pm
 

I had the same problem, only a few seem available, and if I'm right they're wrong.

doing a printMatrix(); followed by print(g.m02); gives different results, and the latter always seems to fire back 0!

Is it anything to do with the sketchmode (P3D, OpenGl etc.) refering to a differnet set of matrix variables?
Re: Matrix access
Reply #3 - May 28th, 2005, 9:56pm
 
PGraphicsGL extends PGraphics3 so...


PGraphicsGL gl = (PGraphicsGL) g; (or cast as a PGraphics3 would do)

 gl.projection.m00, gl.projection.m10, gl.projection.m20, gl.projection.m30,
 gl.projection.m01 etc.


I'm testing this as it seem correct (they exist in the OpenGL lib, but if anyone spots anything let me know!

Thanks.
Re: Matrix access
Reply #4 - May 28th, 2005, 10:08pm
 

Nope! That's not working

The projectionFloats are also protected.

Can someone help!
Re: Matrix access
Reply #5 - May 29th, 2005, 12:54am
 
I was working on this example from the technotes Translating (2D) mouse coordinates to 3D http://www.pitaru.com/processing/mouse_3d/solution/

I tried to compile the example Fjen's example http://www.pitaru.com/processing/mouse_3d/solution/ but it doesn't work anymore. Maybe there's another way to do it in BETA.
Re: Matrix access
Reply #6 - May 29th, 2005, 9:50am
 
The only problems you should experience when porting across are loop(); becomes draw(); and then the ax, ay, az transform can be achieved using modelX,Y and Z and ScreenX,Y and Z, although I've got a slight problem with this, hence the desire to access the matrix directly.

Oh, yeah! you also need to change the mode to OPENGL and import or use P3D in the size statement

I've posted a BETA version of this code elsewhere on this forum that should run under OPENGL (much faster!).

here to be precise:

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Contribution_3DOpenGL;action=display;num=1117291938
Re: Matrix access
Reply #7 - Jul 1st, 2005, 6:07am
 
k, so the api for this is now finalized.. as of rev 92 or later, you first call loadMatrix() to make sure you have good values, then you can use g.m00, g.m01 etc to get the transform matrix.
Re: Matrix access
Reply #8 - Jul 1st, 2005, 2:20pm
 

That's great Ben, thanks!
Page Index Toggle Pages: 1