Loading...
Logo
Processing Forum

Camera from above...

in General Discussion  •  Other  •  9 months ago  
I've read over several posts on this and I must be missing something stupid because this seems really simple to me.  I want to position a camera in 3d space above a flat drawing plane (where I will be drawing only  2d things) and have the camera point down at the plane.  For example: 
So my thought was I would move the eye position up above (eyeX=0,eyeY=200,eyeZ=0), and then I would want it to point down to 0,0,0 so I set my center to that... and "up" values is what I thought was the key here, but 0,1,0 gives me something with a strange perspective, and shuffling the other values isn't helping.

Any advice would be appreciated- thanks so much.

Replies(4)

The up direction should be at 90 degrees to the vector joing the eye and view point. The problem here is that the "up" direction is the same as the viewing direction i.e. 0 degrees.

Using your values for case change the up value to 1,0,0 or 0,0,1 (or any value x,0,z where x and z are not both zero an y is zero)
Okay, I tried that, but it still seems to be looking from the wrong angle- here's a simplified version of my code.  It appears to me that I'm seeing it from the "side" when I swap any of those values (tried 1,0,1 / 0,0,1 / 1,0,0).  Maybe this will make my question a bit more clear. Thanks

Copy code
  1. float eX,eY,eZ,cX,cY,cZ;

  2. void setup() {
  3.   size(500,500,P3D);
  4.   noFill();
  5.   eX= 0.0;
  6.   eY= 100.0;
  7.   eZ= 0.0;
  8.   cX= 0.0;
  9.   cY= 0.0;
  10.   cZ= 0.0;
  11. }

  12. void draw() {
  13.   lights();
  14.   background(255);
  15.   
  16.   camera(eX,eY,eZ,cX,cY,cZ, 1.0, 0.0, 0.0);

  17.   line(30, 20, 85, 20);
  18.   stroke(255,100,0);
  19.   line(85, 20, 85, 75);
  20.   stroke(255,100,0);
  21.   line(85, 75, 30, 75);
  22. }
If you position your camera along the Y axis then a position on the drawing plane will be defined by X, Z coordinates.

In the code above the statements on 21,  23 and 25 draw lines using X,Y coordinates which means you are looking down on the edge of the drawing rather than the surface.

The code below uses the 3D version of the line command and I have moved the eyeY to 200 so it can be seen.


Copy code
  1. float eX,eY,eZ,cX,cY,cZ;

  2. void setup() {
  3.   size(500,500,P3D);
  4.   noFill();
  5.   eX= 0.0;
  6.   eY= 200.0;
  7.   eZ= 0.0;
  8.   cX= 0.0;
  9.   cY= 0.0;
  10.   cZ= 0.0;
  11. }

  12. void draw() {
  13.   lights();
  14.   background(255);
  15.  
  16.   camera(eX,eY,eZ,cX,cY,cZ, 1.0, 0.0, 0.0);
  17.   stroke(255,100,0);
  18.   line(30, 0, 20, 85, 0, 20);
  19.   line(85, 0, 20, 85, 0, 75);
  20.   line(85, 0, 75, 30, 0, 75);
  21. }

I want to position a camera in 3d space above a flat drawing plane (where I will be drawing only  2d things) and have the camera point down at the plane
Why not then place the camera on the Z axis define the up as the Y axis and then you can draw just using the X,Y coordinates. Here is your sketch code based on this.


Copy code
  1. float eX,eY,eZ,cX,cY,cZ;

  2. void setup() {
  3.   size(500,500,P3D);
  4.   noFill();
  5.   eX= 0.0;
  6.   eY= 0.0;
  7.   eZ= 200.0;
  8.   cX= 0.0;
  9.   cY= 0.0;
  10.   cZ= 0.0;
  11. }

  12. void draw() {
  13.   lights();
  14.   background(255);
  15.  
  16.   camera(eX,eY,eZ,cX,cY,cZ, 0.0, 1.0, 0.0);
  17.   stroke(255,100,0);
  18.   line(30, 20, 85, 20);
  19.   line(85, 20, 85, 75);
  20.   line(85, 75, 30, 75);
  21. }
HTH
awesome. i was focused on flipping the camera to see it from the side, that I didn't think about drawing it in 3d space. thanks so much