Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced lookat, target, position by quaternion, position in the camera #591

Merged
merged 2 commits into from
Oct 19, 2018

Conversation

chevtche
Copy link
Contributor

No description provided.

camera.setUp(brayns::Vector3f(0.f, 1.f, 0.f));
camera.setPosition(brayns::Vector3f(0.f, 2 * height, -1.5f));
//camera.setTarget(brayns::Vector3f(0.f, 0.f, 0.f));
//camera.setUp(brayns::Vector3f(0.f, 1.f, 0.f));
Copy link
Contributor

Choose a reason for hiding this comment

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

rm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const brayns::Vector3f up = {0.f, 1.f, 0.f};
engine.getCamera().set(origin, target, up);

const brayns::Vector3d center = bounds.getCenter();
Copy link
Contributor

Choose a reason for hiding this comment

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

const auto&

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer to use "const brayns::Vector3d&". It's easier to understand and more consistent with the following lines.

engine.getCamera().set(origin, target, up);

const brayns::Vector3d center = bounds.getCenter();
const brayns::Quaterniond quat(frame * M_PI / 180.0f, brayns::Vector3d(0.0,1.0,0.0));
Copy link
Contributor

Choose a reason for hiding this comment

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

mix of float and double

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -31,7 +31,15 @@ namespace brayns
class AbstractManipulator
{
public:
AbstractManipulator(Camera& camera, KeyboardHandler& keyboardHandler);

enum AxisMode
Copy link
Contributor

Choose a reason for hiding this comment

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

enum class, lower-case names for values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do mean ? AxisMode -> axisMode ? or GLOBAL_Y -> globalY ?

Copy link
Contributor

@hernando hernando Oct 17, 2018

Choose a reason for hiding this comment

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

Is AxisMode a value?

enum class AxisMode
{
    globalY

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
enum AxisMode
enum class AxisMode
{
local_y,
global_y
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We were using camelCase in other projects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const brayns::Quaterniond quat(frame * M_PI / 180.0f, brayns::Vector3d(0.0,1.0,0.0));
const brayns::Vector3d dir = quat.rotate(brayns::Vector3d(0.0, 0.0, -1.0));
engine.getCamera().setPosition(center + radius * -dir);
engine.getCamera().setQuaternion(quat);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not keep using the set() function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Call the method camera.setOrientation. The quaternion is the parameter type, not the attribute you're modifying. Otherwise it would be setVector instead of setPosition

const Vector3d& getUp() const { return _up; }
void setQuaternion(const Quaterniond& quat)
{
Quaterniond normalized = quat;
Copy link
Contributor

Choose a reason for hiding this comment

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

could just take a copy arg in the function then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -52,13 +52,9 @@ class Camera : public PropertyObject
camera is "looking at" or focused on
Copy link
Contributor

Choose a reason for hiding this comment

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

that comment is wrong now

Copy link
Contributor

Choose a reason for hiding this comment

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

also the one for the class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@karjonas karjonas left a comment

Choose a reason for hiding this comment

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

LGTM. Just make sure to run clang format on all the changed files.

if (updateTarget)
_camera.setTarget(_camera.getPosition() - newPivotToCam);
Vector3d axisY;
if(axisMode == LOCAL_Y)
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like no clang format has been run on this code


if (updateTarget)
_camera.setTarget(_camera.getPosition() - newPivotToCam);
Vector3d axisY;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can write this as const auto axisY = axisMode == LOCAL_Y ? _camera.getQuaternion().rotate(Vector3d(0.0, 1.0, 0.0)) : Vector3d(0.0, 1.0, 0.0);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

tests/webAPI.cpp Outdated
@@ -37,10 +37,10 @@ BOOST_AUTO_TEST_CASE(change_fov)

BOOST_AUTO_TEST_CASE(reset_camera)
{
const auto target = getCamera().getTarget();
getCamera().setTarget({1, 2, 3});
const auto quat = getCamera().getQuaternion();
Copy link
Contributor

Choose a reason for hiding this comment

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

const auto (&) quat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


namespace brayns
{
namespace
{
const float DEFAULT_MOTION_SPEED = 0.001f;
const float DEFAULT_ROTATION_SPEED = 0.005f;
const float DEFAULT_MOTION_SPEED = 0.03f;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const float DEFAULT_MOTION_SPEED = 0.03f;
constexpr float DEFAULT_MOTION_SPEED = 0.03f;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@rolandjitsu rolandjitsu left a comment

Choose a reason for hiding this comment

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

Furthermore, the docker build is failing currently with:

[261/405] Building CXX object brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o
FAILED: brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o 
/usr/bin/c++  -DBOOST_ALL_NO_LIB -DBRAYNSCOMMON_DSO_NAME=\"libbraynsCommon.so.0.8.0\" -DBRAYNSCOMMON_SHARED -DBRAYNS_LITTLEENDIAN=1 -DBRAYNS_USE_ASSIMP=1 -DBRAYNS_USE_BOOST=1 -DBRAYNS_USE_BRION=1 -DBRAYNS_USE_CXX11=1 -DBRAYNS_USE_FREEIMAGE=1 -DBRAYNS_USE_HDF5=1 -DBRAYNS_USE_LIBARCHIVE=1 -DBRAYNS_USE_LIBJPEGTURBO=1 -DBRAYNS_USE_LIBUV=1 -DBRAYNS_USE_NETWORKING=1 -DBRAYNS_USE_OPENMP=1 -DBRAYNS_USE_OSPRAY=1 -DBRAYNS_USE_ROCKETS=1 -DBRAYNS_USE_SERVUS=1 -DBRAYNS_USE_VMMLIB=1 -DBoost_NO_BOOST_CMAKE -DLIBASYNC_STATIC -DLinux=1 -DOSPRAY_TASKING_TBB -DWARN_DEPRECATED -DbraynsCommon_EXPORTS -I../ -Iinclude -I. -I../vmmlib -Ivmmlib/include -Ivmmlib -I../async++/include -isystem /usr/lib/include -isystem /app/dist/include -isystem /app/dist/include/ospray/SDK -isystem /app/dist/include/ospray -isystem /usr/include/hdf5/serial -isystem ../uvw/src -fopenmp -O3 -DNDEBUG -fPIC   -Wuninitialized -Wnon-virtual-dtor -Wsign-promo -Wvla -fno-strict-aliasing -Wall -Wextra -Winvalid-pch -Winit-self -Wno-unknown-pragmas -Wshadow -Werror -fmax-errors=5 -pthread -std=gnu++14 -MD -MT brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o -MF brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o.d -o brayns/common/CMakeFiles/braynsCommon.dir/camera/AbstractManipulator.cpp.o -c ../brayns/common/camera/AbstractManipulator.cpp
../brayns/common/camera/AbstractManipulator.cpp: In member function 'void brayns::AbstractManipulator::translate(const Vector3f&)':
../brayns/common/camera/AbstractManipulator.cpp:81:35: error: 'class vmml::Quaternion<double>' has no member named 'rotate'
     const auto translation = quat.rotate(vector);
                                   ^~~~~~
../brayns/common/camera/AbstractManipulator.cpp: In member function 'void brayns::AbstractManipulator::rotate(const Vector3f&, float, float, brayns::AbstractManipulator::AxisMode)':
../brayns/common/camera/AbstractManipulator.cpp:89:52: error: 'const Quaterniond' {aka 'const class vmml::Quaternion<double>'} has no member named 'rotate'
     const Vector3d axisX = _camera.getQuaternion().rotate(Vector3d(1.0, 0.0, 0.0));
                                                    ^~~~~~
../brayns/common/camera/AbstractManipulator.cpp:93:41: error: 'const Quaterniond' {aka 'const class vmml::Quaternion<double>'} has no member named 'rotate'
         axisY = _camera.getQuaternion().rotate(Vector3d(0.0, 1.0, 0.0));
                                         ^~~~~~
../brayns/common/camera/AbstractManipulator.cpp:101:32: error: 'const Quaterniond' {aka 'const class vmml::Quaternion<double>'} has no member named 'rotate'
     const Vector3d dir = final.rotate(Vector3d(0.0, 0.0, -1.0));
                                ^~~~~~

renderInput.target = camera.getTarget();
renderInput.up = camera.getUp();

renderInput.quat = camera.getQuaternion();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
renderInput.quat = camera.getQuaternion();
renderInput.quaternion = camera.getQuaternion();

Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned in other comment, this should be called orientation, not quaternion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -217,12 +217,11 @@ inline void init(brayns::Renderer::PickResult* p, ObjectHandler* h)

inline void init(brayns::Camera* c, ObjectHandler* h)
{
h->add_property("look_at", Vector3dArray(c->_target), Flags::Optional);
h->add_property("quat", Vector4dArray(c->_quat), Flags::Optional);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
h->add_property("quat", Vector4dArray(c->_quat), Flags::Optional);
h->add_property("quaternion", Vector4dArray(c->_quaternion), Flags::Optional);

Copy link
Contributor

Choose a reason for hiding this comment

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

should be also 'orientation' as all the other instances

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@hernando
Copy link
Contributor

CI is not passing either, it looks like the revision for vmmlib in .gitsubprojects and the nix recipe has not been updated to account for the function added there.

const brayns::Quaterniond quat(frame * M_PI / 180.0f, brayns::Vector3d(0.0,1.0,0.0));
const brayns::Vector3d dir = quat.rotate(brayns::Vector3d(0.0, 0.0, -1.0));
engine.getCamera().setPosition(center + radius * -dir);
engine.getCamera().setQuaternion(quat);
Copy link
Contributor

Choose a reason for hiding this comment

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

Call the method camera.setOrientation. The quaternion is the parameter type, not the attribute you're modifying. Otherwise it would be setVector instead of setPosition

@@ -217,12 +217,11 @@ inline void init(brayns::Renderer::PickResult* p, ObjectHandler* h)

inline void init(brayns::Camera* c, ObjectHandler* h)
{
h->add_property("look_at", Vector3dArray(c->_target), Flags::Optional);
h->add_property("quat", Vector4dArray(c->_quat), Flags::Optional);
h->add_property("origin", Vector3dArray(c->_position), Flags::Optional);
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to 'position'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@chevtche
Copy link
Contributor Author

retest this please

@chevtche chevtche merged commit 28e43de into BlueBrain:master Oct 19, 2018
tribal-tec added a commit to tribal-tec/Brayns that referenced this pull request Oct 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants