Skip to content

Commit

Permalink
change camera normal frame to be more coherent, update tutorial model
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed May 3, 2024
1 parent 2971eb2 commit 5f6db92
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions modules/ar/include/visp3/ar/vpPanda3DGeometryRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*
* This information may contain, depending on requested render type:
*
* - Normals in the world frame or in the camera frame
* - Normals in the world frame or in the camera frame.
* - Depth information
*/
class VISP_EXPORT vpPanda3DGeometryRenderer : public vpPanda3DBaseRenderer
Expand All @@ -56,7 +56,7 @@ class VISP_EXPORT vpPanda3DGeometryRenderer : public vpPanda3DBaseRenderer
enum vpRenderType
{
WORLD_NORMALS, //! Surface normals in world space.
CAMERA_NORMALS, //! Surface normals in the frame of the camera
CAMERA_NORMALS, //! Surface normals in the frame of the camera. Z points towards the camera and y is up.
};

vpPanda3DGeometryRenderer(vpRenderType renderType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void main()
gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;
// View space is Z-up right handed, flip z and y
oNormal = p3d_NormalMatrix * normalize(p3d_Normal);
oNormal.yz = oNormal.zy;
oNormal.y = -oNormal.y;
// oNormal.yz = oNormal.zy;
// oNormal.y = -oNormal.y;
vec4 cs_position = p3d_ModelViewMatrix * p3d_Vertex;
distToCamera = -cs_position.z;
}
Expand Down
Binary file removed tutorial/ar/data/deformed_sphere.bam
Binary file not shown.
Binary file added tutorial/ar/data/suzanne.bam
Binary file not shown.
34 changes: 21 additions & 13 deletions tutorial/ar/tutorial-panda3d-renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ int main(int argc, const char **argv)
"Show frames step by step."},
{"-canny", vpParseArgv::ARGV_CONSTANT_BOOL, (char *) nullptr, (char *)&showCanny,
"Show frames step by step."},

{"-debug", vpParseArgv::ARGV_CONSTANT_BOOL, (char *) nullptr, (char *)&debug,
"Show Opengl/Panda3D debug message."},
{"-h", vpParseArgv::ARGV_HELP, (char *) nullptr, (char *) nullptr,
Expand All @@ -150,21 +149,28 @@ int main(int argc, const char **argv)
modelPath = modelPathCstr;
}
else {
modelPath = "data/deformed_sphere.bam";
modelPath = "data/suzanne.bam";
}
vpPanda3DRenderParameters renderParams(vpCameraParameters(300, 300, 160, 120), 240, 320, 0.01, 10.0);
vpPanda3DRendererSet renderer(renderParams);
renderer.setRenderParameters(renderParams);

const std::string objectName = "object";

std::shared_ptr<vpPanda3DGeometryRenderer> geometryRenderer = std::make_shared<vpPanda3DGeometryRenderer>(vpPanda3DGeometryRenderer::vpRenderType::WORLD_NORMALS);
std::shared_ptr<vpPanda3DGeometryRenderer> cameraRenderer = std::make_shared<vpPanda3DGeometryRenderer>(vpPanda3DGeometryRenderer::vpRenderType::CAMERA_NORMALS);
std::shared_ptr<vpPanda3DRGBRenderer> rgbRenderer = std::make_shared<vpPanda3DRGBRenderer>();
std::shared_ptr<vpPanda3DRGBRenderer> rgbDiffuseRenderer = std::make_shared<vpPanda3DRGBRenderer>(false);
std::shared_ptr<vpPanda3DLuminanceFilter> grayscaleFilter = std::make_shared<vpPanda3DLuminanceFilter>("toGrayscale", rgbRenderer, false);
std::shared_ptr<vpPanda3DGaussianBlur> blurFilter = std::make_shared<vpPanda3DGaussianBlur>("blur", grayscaleFilter, false);
std::shared_ptr<vpPanda3DCanny> cannyFilter = std::make_shared<vpPanda3DCanny>("canny", blurFilter, true, 10.f);
std::shared_ptr<vpPanda3DGeometryRenderer> geometryRenderer =
std::make_shared<vpPanda3DGeometryRenderer>(vpPanda3DGeometryRenderer::vpRenderType::WORLD_NORMALS);
std::shared_ptr<vpPanda3DGeometryRenderer> cameraRenderer =
std::make_shared<vpPanda3DGeometryRenderer>(vpPanda3DGeometryRenderer::vpRenderType::CAMERA_NORMALS);
std::shared_ptr<vpPanda3DRGBRenderer> rgbRenderer =
std::make_shared<vpPanda3DRGBRenderer>();
std::shared_ptr<vpPanda3DRGBRenderer> rgbDiffuseRenderer =
std::make_shared<vpPanda3DRGBRenderer>(false);
std::shared_ptr<vpPanda3DLuminanceFilter> grayscaleFilter =
std::make_shared<vpPanda3DLuminanceFilter>("toGrayscale", rgbRenderer, false);
std::shared_ptr<vpPanda3DGaussianBlur> blurFilter =
std::make_shared<vpPanda3DGaussianBlur>("blur", grayscaleFilter, false);
std::shared_ptr<vpPanda3DCanny> cannyFilter =
std::make_shared<vpPanda3DCanny>("canny", blurFilter, true, 10.f);


renderer.addSubRenderer(geometryRenderer);
Expand Down Expand Up @@ -197,11 +203,13 @@ int main(int argc, const char **argv)
renderer.addNodeToScene(object);

vpPanda3DAmbientLight alight("Ambient", vpRGBf(0.2));
// renderer.addLight(alight);
vpPanda3DPointLight plight("Point", vpRGBf(1.0), vpColVector({ 0.2, 0.2, -0.2 }), vpColVector({ 0.0, 0.0, 2.0 }));
renderer.addLight(alight);

vpPanda3DPointLight plight("Point", vpRGBf(1.0), vpColVector({ 0.3, -0.4, -0.2 }), vpColVector({ 0.0, 0.0, 1.0 }));
renderer.addLight(plight);
vpPanda3DDirectionalLight dlight("Directional", vpRGBf(2.0), vpColVector({ 0.0, -1.0, 0.0 }));
//renderer.addLight(dlight);

vpPanda3DDirectionalLight dlight("Directional", vpRGBf(2.0), vpColVector({ 1.0, 1.0, 0.0 }));
renderer.addLight(dlight);

rgbRenderer->printStructure();
std::cout << "Setting camera pose" << std::endl;
Expand Down

0 comments on commit 5f6db92

Please sign in to comment.