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 & HelpOther Libraries › OCD: off-center camera
Page Index Toggle Pages: 1
OCD: off-center camera (Read 778 times)
OCD: off-center camera
Jan 4th, 2007, 12:43am
 
Hello,
I'm using the OCD library and trying to create a camera that is shifted to one side, so that when I circle/arc the camera, it rotates around an off-center position.  I've experimented with changing camera and target XYZ positions, but the rotation still happens around the center of the applet.  Any help or suggestions on how to accomplish this would be much appreciated.

Thanks,
Andrew
Re: OCD: off-center camera
Reply #1 - Jan 5th, 2007, 7:18am
 
Sure. Can you post a minimal example of your problem for us to see?
Re: OCD: off-center camera
Reply #2 - Jan 8th, 2007, 7:20pm
 
Thanks for the reply.  Here's the code I'm working with:

Code:

import processing.core.*;
import damkjer.ocd.*;

public class CameraTest extends PApplet{
Camera cam1;

public void setup() {
size(600,400,P3D);
cam1 = new Camera(this,
0,0,width,
0,0,0);
}

public void draw() {
background(255);

cam1.feed();
fill(210,0,0);
box(50); // red box
translate(200,0);
fill(0,210,0);
box(50); // green box
fill(0,0,210);
translate(200,0);
box(50); // blue box
}

public void mouseDragged()
{
if (mouseButton == LEFT) {
cam1.circle(radians(mouseX - pmouseX));
cam1.arc(radians(mouseY - pmouseY));
} else if (mouseButton == RIGHT) {
cam1.zoom(radians(mouseY - pmouseY) / 2.0f);
}
}

public static void main(String[] args) {
PApplet.main(new String[] { CameraTest.class.getName() });
}

}


What I'd like is for the red box to be positioned in the center of the applet initially, but when you rotate the view, the camera rotates around the green box.  As I said before, I tried messing around with the camera and target XYZ attributes, but this only changes the camera in relation to the boxes.  What I want is to position the camera in relation to the the applet window (e.g. shift it to the right).

Andrew
Page Index Toggle Pages: 1