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

Mixed intrinsic and extrinsic camera parameter in OpenGL projection matrix #1484

Closed
2 tasks done
zhengpingzhou opened this issue Aug 14, 2020 · 2 comments · Fixed by #1485
Closed
2 tasks done

Mixed intrinsic and extrinsic camera parameter in OpenGL projection matrix #1484

zhengpingzhou opened this issue Aug 14, 2020 · 2 comments · Fixed by #1485
Labels
type: bug Indicates an unexpected problem or unintended behavior

Comments

@zhengpingzhou
Copy link

zhengpingzhou commented Aug 14, 2020

Bug Report

  • I checked the documentation and the forum but found no answer.
  • I checked to make sure that this issue has not already been filed.

Environment

  • DART version: 6.3.0
  • OS name and version name(or number): Ubuntu 18.04
  • Compiler name and version number: GCC 7.5.0

Expected Behavior

The OpenGL projection matrix is expected to have the following structure:

Therefore, if you print the value of GL_PROJECTION_MATRIX, the 16th element must be zero.

Current Behavior

Currently, if you construct a SimWindow following the default setup, the 16th element of GL_PROJECTION_MATRIX is not zero. For example, when the aspect ratio is 4:3, the projection matrix is:

 1.81066        0        0        0
       0  2.41421        0        0
       0        0  -1.0202 0.818182
       0        0       -1        1

It seems the cause of the problem is that part of extrinsic parameters (which are supposed to be included in the model-view matrix) are integrated into the projection matrix (which is supposed to only contain the intrinsic parameters):

https://github.com/dartsim/dart/blob/v6.3.0/dart/gui/Win3D.cpp#L169

This may lead to confusion if the camera parameters need to be exported and used in other programs. Although this does not expose any rendering problem, I personally suggest moving the gluLookAt to model-view. Kindly let me know if I'm missing any context.

Code to Reproduce

dart-opengl-projection-matrix-bug-report

Steps to Reproduce

Build and run the code. The code prints the value of GL_PROJECTION_MATRIX when the aspect ratio is 4:3.

@zhengpingzhou zhengpingzhou added the type: bug Indicates an unexpected problem or unintended behavior label Aug 14, 2020
@jslee02
Copy link
Member

jslee02 commented Aug 16, 2020

Thanks for the report with the test code! I was able to reproduce the incorrect projection matrix computation and fix it by moving the gluLookAt to the model-view section, as you suggested (#1485).

@zhengpingzhou
Copy link
Author

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants