Problems about setting parameters of OfEasyCam

Why OF_functions about OfEasyCam cannot work in setup() but it can work in draw()?
For example:

OfEasyCam camera;
camera.setPosition(100,100,100) ;

When i add “cout<<camera.getPosition()” in draw();
The output is not equal to (100,100,100).

But OfCamera’s functions can work in setup().

setPosition in ofEasyCam is overwritten by the mouse interaction every frame so calling it in setup will get it overwritten in the next update

When you do it in draw it’s not overwritten until next update so the camera is in that position when drawing it.

I believe setting the distance to the target using setDistance will preserve that position but not completely sure.

This is really a bug in OF since it should allow to position the camera initially. If you could open an issue in github that would be really helpful

Thank you very much for your careful answer. I’ll try using setDistance.

When i use lookAt and setDistance,it become works.
Thank you again.

Hi @LLLuKa and @arturo ,
this is not a bug but a feature.
in short, in setup call camera.setAutoDistance(false);

This feature allows the easy cam to actually be easy, thus neading no setup as it will automatically position itself at the needed distance so the viewport would be “placed” at z = 0.
The auto distance is setup only on the first update.

Also, the mouse does not update the parameters on every frame. It only updates when there is a mouse interaction.

hope this helps.

Still it feels really non intuitive that calling setPosition doesn’t actually set the position and lots of people trip on that (i constantly have this problem and always call 2 or 3 things in different places until it works)

In my opinion setPosition should override anything when called since it’s the most logical method to call if you want to set the position of the camera. Mostly on the first frame but in my opinion it should just override any auto setting any time it’s called.

It’s also kind of violating some rules of polymorphism, every object that overrides a method should have the same apparent behaviour, in this case that method does nothing which is weird.

This is really a problem of using inheritance and we should just use composition instead and only publish those methods that make sense for the ofEasyCam but as long as that method is there, when called it should set the position, non doing so looks like the class is broken to anyone who doesn’t know anything about the inner workings of ofEasyCam

I agree. I will make a PR with the changes. This shouldn’t be much and as you say it would be a lot more intuitive.

ok. Just made the PR.

Thank you for your reply,it can works too by using camera.setAutoDistance(false).


using set distances works too because as a side effect it disables autoDistance. I made the fixes and made a PR for it, so it should be shortly available.