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 8240 times)
Re: Update: PeasyCam 0.3.0
Reply #15 - Mar 4th, 2009, 11:06pm
 
I think I may need a method to find out where the PeasyCam is at.  Perhaps the getState() does this and I just need to covert it.  I think I need something I can feed into camera() for buffer picking.
Re: Update: PeasyCam 0.3.0
Reply #16 - Mar 5th, 2009, 1:26am
 
Thanks very much for the bug demo. I had to completely rewrite all of the interpolation stuff.

OK, try 0.4.2, and, again, thanks for your very helpful comments and suggestions.
Re: Update: PeasyCam 0.3.0
Reply #17 - Mar 5th, 2009, 1:31am
 
jeffg wrote on Mar 4th, 2009, 11:06pm:
I think I may need a method to find out where the PeasyCam is at.  Perhaps the getState() does this and I just need to covert it.  I think I need something I can feed into camera() for buffer picking.
PeasyCam.getState() returns a private, opaque data structure that won't be useful to you (since my states are represented in terms of a distance and a quaternion rotation, and not a camera position).

You can get the "camera" matrix directly from the PGraphics3D. Just say

 ((PGraphics3D)g).camera
Re: Update: PeasyCam 0.3.0
Reply #18 - Mar 5th, 2009, 2:36am
 
Tested 0.4.3 and the setDistance worked great.  I also tested the setMatrix(((PGraphics3D)g).camera); and it worked.  I'll post an example soon for "Peasy Picking". Smiley

Another possible feature... full inertia (the object just keeps rotating with the mouse gesture).

Since you also seem to be well versed in text (Wordle), any suggestions on applying text inside of Peasy so that the text stays up-right and readable (but tied to the objects) as the camera is rotated around.  I'd like to apply labels to the objects, but still have the full orbit environment.
Re: Update: PeasyCam 0.3.0
Reply #19 - Mar 5th, 2009, 2:35pm
 
Again, thanks for the great library.  Here is another possible feature that would be very cool.  At this point, I expect you're ready to DDOS me off the forum. Smiley

Flight Mode - The current Peasy is set to Orbit mode, but it would be nice to have the ability to switch it to "flight mode" with the camera in first person position.  You are focus point and rotate in position, Min/Max distance are ignored as zoom has no limit or stop point as the center point moves with you.  I would combine this feature with the full inertia feature described above to provide first person flight movement in any direction.

Mac Zoom - It's difficult to zoom on the mac with one mouse button.  It's a tough combination of two stroke trackpad gestures.  Perhaps an alt-left-drag could be added for zoom.
Re: Update: PeasyCam 0.3.0
Reply #20 - Mar 5th, 2009, 4:20pm
 
Does peasy use its own light source? Depending on how I rotate it, it will be brighter and then get darker.  I've tried to set an ambient light (keeping equal lighting), but it doesn't change.
Re: Update: PeasyCam 0.3.0
Reply #21 - Mar 5th, 2009, 4:22pm
 
jeffg wrote on Mar 5th, 2009, 4:20pm:
Does peasy use its own light source Depending on how I rotate it, it will be brighter and then get darker.
No, you're looking at different sides of an object that's lit from one side.
Re: Update: PeasyCam 0.3.0
Reply #22 - Mar 5th, 2009, 7:11pm
 
Peasy Picking 3d Example
Double click a sphere to set it to the center focus point.

Quote:
//Double click a sphere to set it to the center focus point

import processing.opengl.*;
import peasy.*;

PeasyCam cam;

class Node {

 // variables
 int id;          // id
 int x, y, z, w;  // position (x, y, z) and width (w)
 color c;         // color (in scene, not buffer)

 // constructor
 public Node(int id, int x, int y, int z, int w) {
   this.id = id;
   this.x = x;
   this.y = y;
   this.z = z;
   this.w = w;
   c = color(random(255), 250, 50);
 }

 // make the color change
 public void focus() {
   cam.lookAt(x,y,z,1000); //lookat xyz - speed 1000 ms
 }

 // display the Node on screen
 public void display(PGraphics ecran) {
   ecran.fill(c, 100); //color, alpha
   ecran.noStroke();
   drawNode(ecran);
 }

 // draw the Node in the buffer
 public void drawBuffer(PGraphics buffer) {
   color idColor = getColor(id);
   buffer.fill(idColor);
   drawNode(buffer);
 }

 private void drawNode(PGraphics g) {
   g.pushMatrix();
   g.translate(x, y, z);
   g.sphere(w);
   g.popMatrix();
 }

}

PGraphics buffer;   // buffer
Node[] Nodes;       // Nodes

//float a = 0;        // angle to make the scene rotate

void setup() {

 // we use OPENGL for display
 size(800, 600, OPENGL);
 //printCamera();
 cam = new PeasyCam(this, 400);
 cam.setResetOnDoubleClick(false);
 cam.setMinimumDistance(100);
 cam.setMaximumDistance(5000);
 // buffer is created using applet dimensions
 buffer = createGraphics(width, height, P3D);

 // put Nodes randomly in the scene
 Nodes = new Node[7];

 Nodes[0] = new Node(
 0,  // identifiant
 0,  // position x
 0,  // position y
 0,  // position z
 10  // size
 );
 Nodes[1] = new Node(1,100,0,0,10);
 Nodes[2] = new Node(2,0,100,0,10);
 Nodes[3] = new Node(3,0,0,100,10);
 Nodes[4] = new Node(4,-100,0,0,10);
 Nodes[5] = new Node(5,0,0,-100,10);
 Nodes[6] = new Node(6,0,-100,0,10);

}

void draw() {

 background(0);
 lights();
 smooth();
 strokeWeight(1.5);
 stroke(126, 50);
 line(0, 0, 0, 100, 0, 0);
 line(0, 0, 0, 0, 100, 0);
 line(0, 0, 0, 0, 0, 100);
 line(0,0,0,-100,0,0);
 line(0,0,0,0,-100,0);
 line(0,0,0,0,0,-100);
 for (int i = 0; i < Nodes.length; i++) {
   Nodes[i].display(this.g);
 }
}

void mouseClicked() {
 if (mouseEvent.getClickCount() == 2) {

   // draw the scene in the buffer

   buffer.beginDraw();
   buffer.background(getColor(-1)); // since background is not an object, its id is -1
   buffer.noStroke();
   buffer.sphereDetail(10);
   buffer.setMatrix(((PGraphics3D)g).camera);
   //buffer.camera(-20, -20, 50, 0, 0, 0, 0, 1, 0);
   //buffer.rotateY(a);
   for (int i = 0; i < Nodes.length; i++) {
     Nodes[i].drawBuffer(buffer);
   }
   buffer.endDraw();

   // get the pixel color under the mouse
   color pick = buffer.get(mouseX, mouseY);
   // get object id
   int id = getId(pick);
   // if id > 0 (background id = -1)
   if (id >= 0) {
     // change the Node position
     Nodes[id].focus();

   }
 }
}

// id 0 gives color -2, etc.
color getColor(int id) {
 return -(id + 2);
}

// color -2 gives 0, etc.
int getId(color c) {
 return -(c + 2);
}
Re: Update: PeasyCam 0.3.0
Reply #23 - Mar 5th, 2009, 7:33pm
 
Neat-o!
Re: Update: PeasyCam 0.3.0
Reply #24 - Mar 5th, 2009, 9:36pm
 
Question that is similar to my text question above (post 18.).  I'm trying to use a GUI (ControlP5 but will switch to whatever works) and I can't get it to stay "on-top" and not rotate with the camera.  I want to create a textbox and information window that "sits" (doesn't move) on the screen while the 3d objects are controlled in the background.
Re: Update: PeasyCam 0.3.0
Reply #25 - Mar 6th, 2009, 4:53pm
 
Johnathan,
I've found a thread that deals with similar camera controls but is able to maintain the text upright.  Not sure if this can be worked into the code, but this will be important for my project, as is getting a GUI to stay still.

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1227727935

Here is an example.
http://www.personal.leeds.ac.uk/~gy06do/processing/ces_function/
Re: Update: PeasyCam 0.3.0
Reply #26 - Mar 10th, 2009, 4:09pm
 
Here is an update for future people searching for similar issues.

jeffg wrote on Mar 5th, 2009, 4:20pm:
Does peasy use its own light source Depending on how I rotate it, it will be brighter and then get darker.  I've tried to set an ambient light (keeping equal lighting), but it doesn't change.


I resolved this by using:

Code:
ambientLight(255, 255, 255, 0,0,0); 



jeffg wrote on Mar 5th, 2009, 2:36am:
Since you also seem to be well versed in text (Wordle), any suggestions on applying text inside of Peasy so that the text stays up-right and readable (but tied to the objects) as the camera is rotated around.  I'd like to apply labels to the objects, but still have the full orbit environment.


Jonathan resolved this using a new feature in PeasyCam called getRotations().

Code:

float[] rotations = new float[3];
...
pushMatrix();
translate(x, y, z);
rotations = cam.getRotations();
rotateX(rotations[0]);
rotateY(rotations[1]);
rotateZ(rotations[2]);
ellipse(0,0,20,20);
popMatrix();


Re: Update: PeasyCam 0.3.0
Reply #27 - Mar 11th, 2009, 2:28pm
 
jeffg wrote on Mar 5th, 2009, 9:36pm:
Question that is similar to my text question above (post 18.).  I'm trying to use a GUI (ControlP5 but will switch to whatever works) and I can't get it to stay "on-top" and not rotate with the camera.  I want to create a textbox and information window that "sits" (doesn't move) on the screen while the 3d objects are controlled in the background.


Here is how to create a ControlP5 GUI with PeasyCam.

Code:

import peasy.*;
import controlP5.*;
PeasyCam cam;
ControlP5 controlP5;
Textfield myTextfield;
boolean enter = false;
int dx;
float[] offsets = new float[3];
float[] rotations = new float[3];

void setup() {
size(800,600, P3D);
cam = new PeasyCam(this, 400);
controlP5 = new ControlP5(this);
controlP5.setAutoDraw(false);
}

void draw() {
background(0);
stroke(255);
pushMatrix();
line(0,0,0,100,0,100);
translate(0,0,0);
sphere(10);
translate(100,0,100);
sphere(10);
popMatrix();
if (enter == true){
cam.setDistance(dx);
searchbox();
}

}

void keyPressed() {
if (key == ENTER || key == RETURN) {
if (enter == false){
enter = true;
dx = (int)cam.getDistance();
myTextfield = controlP5.addTextfield("Search",-dx/6, dx/2-5 ,dx/3,dx/24);
}
else if (enter == true){
enter = false;
myTextfield.remove();
}
}
}
private void searchbox()
{

pushMatrix();
rotations = cam.getRotations();
offsets = cam.getLookAt();
translate(offsets[0],offsets[1],offsets[2]);
rotateX(rotations[0]);
rotateY(rotations[1]);
rotateZ(rotations[2]);
stroke(128,60);
fill(50,60);
rect(-dx, dx/2.2, dx*2, dx/6);
controlP5.draw();
myTextfield.setFocus(true);
popMatrix();
}

public void Search(String theText) {
// receiving text from Search textbox
println(theText);
}
Re: Update: PeasyCam 0.3.0
Reply #28 - Jul 6th, 2009, 8:10am
 
jeffg wrote on Mar 11th, 2009, 2:28pm:
Here is how to create a ControlP5 GUI with PeasyCam.
....


I tried the same with numeric sliders, but this doesn't work because you cannot click on the slider Do you have a solution for this

thanks a lot.
Re: Update: PeasyCam 0.3.0
Reply #29 - Jul 6th, 2009, 9:16am
 
i just added a control window with ControlP5. Now it works ...

http://www.sojamo.de/libraries/controlP5/examples/ControlP5window/ControlP5window.pde
Pages: 1 2 3