Plot camera course and make it glide from one point to the other

edited December 2016 in Library Questions

As the title says I am trying to plot a certain course for a camera to move around a 3D space. In a way that after a certain amount of time it would glide from the first plotted XYZ to another one.

I've looked up moveEye examples and believe it is not what I am looking for. I was just wondering if anyone could direct me towards a resource, a library or generously throw some code at me.

Much appreciated.

Tagged:

Answers

  • Post what you have.

  • edited December 2016

    And perhaps you don't know this, but the camera requires three bits of information -

    • Its position.
    • The point it should point at.
    • Its orientation, i.e. the "up" vector.
  • I do understand how to set a camera up. What I don't understand is how to slowly glide between the two camera positions. I know I am missing a piece of code. This is what I currently have.

    void setup(){
      size (800, 800, P3D);
      background (0);
    }
    
    void draw(){
      camera (width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);
      translate(width/2, width/2, 0);
      box (40);
      if (millis() > 5000){
      camera (width/8.0, height/8.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0);
      }
    }
    
  • edited January 2017 Answer ✓

    (Is this really a library question? Which one?)

    Look at lerp() please

  • edited December 2016

    It is not a library question. I posted it in "How to" but for some unknown reason it ended up here. Maybe it was moved because I mentioned a library in my question.

    I'm going to go and check OCD library. Maybe I can achieve what I want with that one.

  • Well I guess it's a good thing this was moved into a library section. I did some digging around OCD library and realised that I can achieve what I want with it. Thanks everyone for help.

  • You can? Impressive. And I was wasting my time to figure it out all this time. If I hadn't noticed your comment, I would probably have spent an hour to figure it out fully.

  • Lol not sure if sarcasm or not but if you were wondering yourself how to do something like this here is my code. It requires OCD library.

    import damkjer.ocd.*;
    
    Camera camera1;
    
    void setup() {
      size(800, 800, P3D);
    
      camera1 = new Camera(this, 100, -125, 150);
    }
    
    void draw() {
      background(204);
      lights();
      camera1.feed();
    
      rotateY(PI/3);
      translate (0, 200, 100);
      box (50);
      translate (-100, -10, -10);
      box(50);
      //translate (400, 0, 600);
      //box (50);
      //translate (410, 0, 600);
      //box (50);
    
      if (millis() > 3000 && millis() <= 5000){
      //camera1.track(-.3, 0);
      camera1.boom(3);
      //camera1.truck(.5);
      //camera1.dolly(-.5);
      camera1.tilt (radians(-.2));
      }
    
      if (millis() > 6000 && millis() <= 8000){
      camera1.truck(3);
      camera1.pan(.01);
      }
    
      if (millis() > 6000 && millis() <= 10000){
      translate (440, 0, 550);
      box (50);
    
      }
    
      if (millis() > 8000 && millis() <= 11000){
        camera1.zoom (-.01);
        camera1.tilt (radians(-.2));
      }
    }
    
  • A little sarcasm - I was sad that I had wasted time on something that can already be done by a library.

  • Well I was killing myself for about half a day trying to achieve it without a library and at that point realised that it can be done way easier. And to be fair from the very beginning I was curious if anyone could recommend a library if it was to be quicker. Thanks for the effort of trying to help.

  • Well, I should thank you - the OCD library is very cool.

  • edited January 2017

    Interesting! I hadn't looked at that library.

    The Obsessive Camera Direction (OCD) Library by Kristian Linn Damkjer is linked from the Processing Libraries page, and also available here:

    truck() boom() dolly() and pan() take distances -- this can be updated periodically based on a frameRate or timer.

    Alternately, if you want to enter absolute distances between a starting and stopping point you could generate intermediate distances by using lerp() and an amount on your x,y,z pairs (I believe that this would work using any camera, or e.g. QuesyCam, PeasyCam etc. -- although I have not tested).

Sign In or Register to comment.