SofaDefrost / sofa

SOFA, open source framework for multi-physics simulation.
https://www.sofa-framework.org
13 stars 6 forks source link

ADD: BaseCamera helper methods #25

Closed marques-bruno closed 4 years ago

marques-bruno commented 4 years ago

Tested rudimentarily by creating an arbitrary 2D point, and converting back n forth. seems to work, but can't tell for sure with Z... (there seem to be an inversion of direction, maybe from the OpenGL 180° rotation around X, when converting to world coord, and I get huge z when converting back. example of test below):

viewport: 635x621
glProjection / glModelView: defaults from runSofa2's BaseCamera
input point: 142 142
toViewportCoord: 0.223622 0.228663 1
toWorldCoord: -0.0047776 0.00458704 -1.02025
back to viewportCoord:  0.223622 -0.271337 2492.75
back to screenCoord:  142 -168.5 2492.75

I wanted to add a unit test in SofaBaseVisual, but I don't know how to mock the glProjection / glModelView that are retrieved in getOpenGLProjection / getOpenGLModelView called within my added methods... I'll look into it on monday ;)


This PR:

Reviewers will merge only if all these checks are true.