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
store transformation matrices? (Read 1389 times)
store transformation matrices?
Sep 30th, 2008, 8:40pm
 
was going to add as an enhancement, then dug around in dev for a bit and it looks like it may already be possible.

is it possible to store transformation matrices?  say every frame you're translating to the center, rotating PI/4, drawing, then popping that matrix.  any way to avoid the math and overhead of translate/rotate every frame?

i see PMatrix2D/3D, and PApplet.applyMatrix, but not clear if either of these could be useful.  ideal situation would be a getMatrix() call, which returns an object that could later be pushed into the stack via pushMatrix().  or something along those lines.
Re: store transformation matrices?
Reply #1 - Oct 3rd, 2008, 4:31pm
 
// 6 for 2D, 16 for 3D, let's assume 3D...
// (you could also create instance of PMatrix2D/3D instead of float arrays)
float [] store = new float[16]; // or let get() create it
float [] storeInv = new float[16];
// save it
g.modelview.get(store);
g.movelviewInv.get(storeInv);
// then use it
g.modelview.set(store);
g.modelviewInv.set(storeInv);


this approach is "slimier"/"hackier" than using applyMatrix() but avoids the work to recalculate the inverse.

provided as is, without warranty of any kind ;)
Re: store transformation matrices?
Reply #2 - Oct 3rd, 2008, 9:10pm
 
davbol wrote on Oct 3rd, 2008, 4:31pm:
provided as is, without warranty of any kind ;)

i'll be voiding your non-warranty for 0149, but that release happens to contain a get and set methods for the matrix that can be used.

and as mentioned in the top (sticky) post on this board, if you want a software feature implemented, post it in the bugs db as an 'enhancement'. software suggestions here are all but ignored.
Page Index Toggle Pages: 1