Skip to content

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

Open
rsepierre wants to merge 7 commits intojdf:masterfrom
rsepierre:master
Open

adding methods to move camera front and back (.move, .forward, .backward)#42
rsepierre wants to merge 7 commits intojdf:masterfrom
rsepierre:master

Conversation

@rsepierre
Copy link

No description provided.

@rsepierre
Copy link
Author

rsepierre commented Jan 24, 2022

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 :

  • .move (x, y, z) -- similar to panning relative to the camera, on three axis.
  • .forward (distance) -- moves the center forward for a certain distance.
  • .backward (distance) -- moves the center backward for a certain distance.

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 :

  • make the "center" variable public
  • add z parameters to .pan() (instead of creating .move)

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
Copy link
Author

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

Copy link
Owner

@jdf jdf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the changes to all files except PeasyCam.java. Thank you!

@rsepierre
Copy link
Author

rsepierre commented Jan 26, 2022

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 :

  • Implementation of move() which enables moving on x,y,z axis relative to the camera.
  • implementation of forward() and backward() which uses move()
  • pan() now also uses move()
  • deletion of the unused import processing.core.PShape; in Resizable_Offscreen.java Eclipse was warning about.
  • Every other file should be reverted to current master state, untouched.
	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 rsepierre requested a review from jdf January 26, 2022 14:15
@rsepierre rsepierre requested a review from jdf January 28, 2022 13:44
@rsepierre
Copy link
Author

rsepierre commented Feb 21, 2022

@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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants