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 › Update: PeasyCam 0.3.0
Pages: 1 2 3 
Update: PeasyCam 0.3.0 (Read 8239 times)
Update: PeasyCam 0.3.0
Feb 18th, 2009, 9:16pm
 
PeasyCam provides a dead-simple mouse-driven camera for 3D Processing sketches.

Notable changes in version 0.3.0:
  • Camera movements have a bit of "momentum" now, which gives it kind of a pleasing feel.
  • You can now query the camera for its current state, and set it to a saved state. The state is serializable, so you could, e.g., construct a tour, then play it back. State changes are optionally animated.
General information about PeasyCam:

Code:
PeasyCam camera;

void setup() {
camera = new PeasyCam(this, 0, 0, 0, 50);
}

That's it. Now a mouse left-drag will rotate the camera around the subject, a right drag will zoom in and out, and a middle-drag (command-left-drag on mac) will pan. A double-click restores the camera to its original position. The shift key constrains rotation and panning to one axis or the other.

The PeasyCam is positioned on a sphere whose radius is the given distance from the look-at point. Rotations are around axes that pass through the looked-at point.

PeasyCam is impervious to gimbal lock, and has no known "singularities" or discontinuities in its behavior. It relies on the excellent Apache Commons Math geometry package for its rotations.
Re: Update: PeasyCam 0.3.0
Reply #1 - Mar 3rd, 2009, 6:08pm
 
Thanks Jonathan, Is there any way to set a max zoom value?  For example, if you zoom in too far, you end up inside the cube, sphere, etc.  Is there any way to say, stop at a distance of 50 (or something)?  I don't want to end up inside the object.
Re: Update: PeasyCam 0.3.0
Reply #2 - Mar 3rd, 2009, 6:13pm
 
jeffg wrote on Mar 3rd, 2009, 6:08pm:
Thanks Jonathan, Is there any way to set a max zoom value  For example, if you zoom in too far, you end up inside the cube, sphere, etc.  Is there any way to say, stop at a distance of 50 (or something)  I don't want to end up inside the object.


Excellent idea! Watch this space for a reply.
Re: Update: PeasyCam 0.3.0
Reply #3 - Mar 3rd, 2009, 6:46pm
 
Another thing I'm trying to do...
I like the double click feature, but I'd like to control where it is navigated (instead of the start).  Let's say I have 5 objects on the screen.  I'd like to double click on any object and have it set as the center (focus) point and "fly" me to it.

So sort of like a double click camera.lookAt with an option for long animationTimeInMillis transition..
Re: Update: PeasyCam 0.3.0
Reply #4 - Mar 3rd, 2009, 9:46pm
 
jeffg wrote on Mar 3rd, 2009, 6:46pm:
I like the double click feature, but I'd like to control where it is navigated (instead of the start).  Let's say I have 5 objects on the screen.  I'd like to double click on any object and have it set as the center (focus) point and "fly" me to it.


Determining what point in 3D space is meant by a user gesture is way beyond the scope of my library. You could perhaps apply some other techniques to determine the clicked-on object, then tell PeasyCam to navigate there, but PeasyCam won't be adding features like that.
Re: Update: PeasyCam 0.3.0
Reply #5 - Mar 4th, 2009, 2:12am
 
I understand that determining the point in 3D space would be beyond the scope of this library.  I should be able to do that outside of the library with screenx/screeny (I think) and send it to Peasy.  What I need though is to be able to disable the double click feature of Peasy - I'll need to handle this mouse control myself instead.  I'll also need the ability to tell Peasy to navigate and set focus to a particular point.  The camera look feature jumps there, but doesn't have the cool "fly" effect that you get when you do a reset (double click).  Perhaps the camera look function could be modified to allow a animation transition like the reset does.  Or perhaps the ability to set the start values after the start, so that when you do a reset, it navigates to the new point.
Re: Update: PeasyCam 0.3.0
Reply #6 - Mar 4th, 2009, 2:59am
 
OK, version 0.4.1 is up with the following new methods:

Code:
lookAt(x,y,z,animationTimeInMillis)
setResetOnDoubleClick(boolean)
setMinimumDistance(double)
setMaximumDistance(double)

Let me know how it goes for you.
Re: Update: PeasyCam 0.3.0
Reply #7 - Mar 4th, 2009, 5:06am
 
Excellent Smiley
I gave it a quick test.
setMinimumDistance(double) - Worked great
setMaximumDistance(double) - Worked great
lookAt(x,y,z,animationTimeInMillis) - Worked great

setResetOnDoubleClick(boolean) - Didn't appear to do anything.. Double click would refocus it to 0,0,0 with it set to both true and false.

Also noted that the lookAt does not set the distance.  So if you're zoomed out, while it does focus it to the object, it does not zoom you back into it.  I tried to use the setDistance method after the lookAt but it did not bring me back close to the object.  It would be nice if setDistance was able to do this with a similar animationTimeInMillis.
Re: Update: PeasyCam 0.3.0
Reply #8 - Mar 4th, 2009, 6:43pm
 
Trying to do a 3d color pick in the buffer, however, I'm having a problem getting the camera into the buffer.  Any way to send it the current camera position and feed it into a camera() control for the buffer?
Re: Update: PeasyCam 0.3.0
Reply #9 - Mar 4th, 2009, 7:20pm
 
jeffg wrote on Mar 4th, 2009, 5:06am:
setResetOnDoubleClick(boolean) - Didn't appear to do anything.. Double click would refocus it to 0,0,0 with it set to both true and false.
Ha! Stupid bug; fixed.

Quote:
I tried to use the setDistance method after the lookAt but it did not bring me back close to the object.
setDistance() didn't change the camera's distance Are you sure you were within min and max

Quote:
It would be nice if setDistance was able to do this with a similar animationTimeInMillis.
Well, I've added a couple more lookAts that take a distance as well.
0.4.2 is up in the usual place.
Re: Update: PeasyCam 0.3.0
Reply #10 - Mar 4th, 2009, 7:36pm
 
setResetOnDoubleClick now works great. Smiley

Mixed results on the lookAt().

Perhaps the program doesn't know which one is which here - same number of variables.

  camera.lookAt(double x, double y, double z, long animationTimeInMillis);
  camera.lookAt(double x, double y, double z, double distance);

This one worked fine, which was the main function I wanted. Smiley
  camera.lookAt(double x, double y, double z, double distance, long animationTimeInMillis);

Tested setDistance() again but didn't work for me, but unnecessary due to the new lookAt feature.
Re: Update: PeasyCam 0.3.0
Reply #11 - Mar 4th, 2009, 7:51pm
 
jeffg wrote on Mar 4th, 2009, 7:36pm:
Mixed results on the lookAt().

Perhaps the program doesn't know which one is which here - same number of variables.
But different types. This would be a bug in Processing's compiler. I'll come up with a distinct name.

Quote:
Tested setDistance() again but didn't work for me
Please come up with a test case that shows the bug. I can't reproduce it.

Thanks for your comments.
Re: Update: PeasyCam 0.3.0
Reply #12 - Mar 4th, 2009, 8:05pm
 
John, Here is a quick test that I ran with the setDistance.

If setDistance is before the lookAt, I found that both work fine.  It sets the distance and then looks at the point.

     cam.setDistance(200);
     cam.lookAt(100,0,100);

If setDistance is after the lookAt, only the lookAt will work.  The camera looks at the point, but does not set the distance.

     cam.lookAt(100,0,100);
     cam.setDistance(200);

Hope this helps
Re: Update: PeasyCam 0.3.0
Reply #13 - Mar 4th, 2009, 8:40pm
 
No, I really need a complete test case, i.e., the entire source of a sketch that exhibits the behavior you describe. Thanks.
Re: Update: PeasyCam 0.3.0
Reply #14 - Mar 4th, 2009, 9:00pm
 
//When the key "1" is pressed, it does not set the distance.
//When the key "2" is pressed, it sets both the distance and the lookat.
//Pressing 1 or 2 will set the center sphere to 100,0,100.
//Double click will set it back to 0,0,0.

import peasy.*;
PeasyCam cam;

void setup() {
 size(800,600, P3D);
 cam = new PeasyCam(this, 500);
}

void draw() {
 background(0);
 stroke(255);
 line(0,0,0,100,0,100);
 translate(0,0,0);
 sphere(10);
 translate(100,0,100);
 sphere(10);

if(keyPressed) {

   if (key == '1') {
     cam.lookAt(100,0,100);
     cam.setDistance(200);
   }
   else if (key == '2') {
     cam.setDistance(200);
     cam.lookAt(100,0,100);
   }
 }
}
Pages: 1 2 3