jdf / peasycam

Dead-simple mouse-driven camera for Processing
http://MrFeinberg.com/peasycam/
Apache License 2.0
116 stars 35 forks source link

adding methods to move camera front and back (.move, .forward, .backward) #42

Open rsepierre opened 2 years ago

rsepierre commented 2 years ago

The goal for this commit was to provide a public interface to move the PeasyCam camera center position. Because "center" is private, even by extending the PeasyCam Class, we can not add the possibility to move or "pan" backwards or forwards relative to the camera.

For this reason, I created three methods (although they are not all necessary) which are similar to the pan method :

I could not find any way to actually build the library so I could not test the code. I think then maybe forward and backward are inverted, otherwise I think it should behave just like .pan() as code is mostly identical;

Alternative ways I thought about to fixing the issue :

As unfortunately extending the PeasyCam Class does not provide any public interface with "center" I hope that you will consider those changes for the main branch.

rsepierre commented 2 years ago

I have since successfully compiled peasycam and tested the functions that worked seamlessly. Just as I feared I had to invert .forward and .backard but everything works fine.

I'm not sure how pull requests work. The last two commits added themselves to the PR automatically. If considered for master, should probably filter out changes made to the compiler/builder and .gitignore

rsepierre commented 2 years ago

Ok it's a lot of commits for this, I'm sure there was better way to git my way out of there but here should be everything that changes with the pull request as of now :

    public void move(final double dx, final double dy, final double dz) {
        center = center.add(rotation.applyTo(new Vector3D(dx, dy, dz)));
        feed();
    }

    public void pan(final double dx, final double dy) {
        move(dx, dy, 0);
    }

    public void forward(final double distance) {
        move(0, 0, -distance);
    }

    public void backward(final double distance) {
        move(0, 0, distance);
    }
rsepierre commented 2 years ago

@jdf Hi there ! I allow myself to tag you as I'm guessing this might have slipped through your priorities :-) I was wondering if you were satisfied with the current state of the pull request ?