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 & HelpSyntax Questions › pan camera in 2d space, center on object
Page Index Toggle Pages: 1
pan camera in 2d space, center on object (Read 533 times)
pan camera in 2d space, center on object
Sep 28th, 2008, 11:50pm
 
hi

new to processing, I'm playing around with a force directed network layout. I am trying to figure out how you could "focus" on a node by way of a translation of the camera - a pan type movement - so that the node that is clicked on ends up in the center of the screen. I tried changing the node's position to the center but because of the springy forces it instantly wants to return to its previous position - what I really want is to move the center of the sketch's frame so that it coincides with that node.

i know you can manipulate a "camera" in 3d space, but is there something like that for 2d? any advice?

thanks!
Re: pan camera in 2d space, center on object
Reply #1 - Sep 29th, 2008, 12:41pm
 
You can do it simply, just do a translate ( http://processing.org/reference/translate_.html ) before drawing anything.
Re: pan camera in 2d space, center on object
Reply #2 - Oct 3rd, 2008, 7:15am
 
i think i found the solution in the Integrator class that Ben Fry made for the Visualizing Data book. I just have to figure out how to make it work for my parituclar case. Your suggestion seemed to disregard the fact that the nodes are perpetually being redrawn and moving, and the zooming in would be layered on top of that time scale. or maybe I misunderstood your suggestion...

any other ideas?
Re: pan camera in 2d space, center on object
Reply #3 - Oct 3rd, 2008, 9:36am
 
why not just change to p3d/opengl? your graphics should stay the same, but you will have camera pan/zoom ability.
Re: pan camera in 2d space, center on object
Reply #4 - Oct 3rd, 2008, 7:34pm
 
changing to P3D would be easy. Once that's done how do I pan/zoom? Sorry, I just started using Processing and some of this obvious stuff is hard to answer...I have seen libraries like arcball for this task but is there a more straightforward solution?
Re: pan camera in 2d space, center on object
Reply #5 - Oct 3rd, 2008, 10:24pm
 
it's easy!
just use the camera function
http://processing.org/reference/camera_.html

the eyeX, eyeY, eyeZ, centerX, centerY, centerZ are for the camera pos and target pos - just move all x,y values together to pan around, and the z values to zoom in and out.

Re: pan camera in 2d space, center on object
Reply #6 - Oct 3rd, 2008, 11:59pm
 
thanks for the tips, glenn.

Just checked you website and I love your work..how much post processing goes into something like the Metamorphosis music video? Is the infinite tree branching sometihng you wrote on your own or is that assembled from another source...? I have so many questions. Great stuff!

gabe
Re: pan camera in 2d space, center on object
Reply #7 - Oct 4th, 2008, 12:49am
 
'post processing' ? neverrrrrrrrrrrrrrrrrrrrrrrrr!!!!!
the ultimate sin!!
Re: pan camera in 2d space, center on object
Reply #8 - Oct 5th, 2008, 6:28am
 
ok, so it worked but once the camera pans to the new location some thing breaks down...I don't know if the problem's in my original sketch or in my understanding of 3d in processing.

the deal is that i have this force directed netowrk graph and when I click on a node the node's x & y positions are sent to the camera. One problem that I don't get is that this node, once centred, begins to trail away from this position. I imagined that it would remain fixed...

the other problem is that interaction with the graph does not work as it did after this click - you can't click on another node to "focus" on it...

could you take a look? I would be grateful. there is something wrong with my export option so I have provided a link to a zip file:

http://www.friedmanstudios.ca/chimera_obscura/processing/GraphLayout_animals2.zip
Page Index Toggle Pages: 1