Getting the zoom component - C++ / OpenCascade

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
Valzul
Posts: 6
Joined: Fri Sep 06, 2024 12:15 am

Getting the zoom component - C++ / OpenCascade

Post by Valzul »

Hello,

I've been trying to use the SDK with a Qt/QML application that uses OpenCascade as a viewer.

Using the example you provided ( navlib_viewer ), I managed to get the getters/setters functions to work properly it seems
and my view's camera is getting what seems to me to be the good direction, up and eye position, but I can't seem to get the "zoom" or distance component right, and it looks like in my Qt test application the "SetCameraMatrix" function is not called when I use this particular mouse movement :

Image

I tested with the default navlib_viewer application and it seems to work fine when I'm using only this movement I get a call to SetCameraMatrix changing some components ( m03,m13,m23 ) in the 4x4 matrix :

Image

I'm wondering If I set enough information to give to the library ? Currently I only use these getters :


GetCoordinateSystem
GetCameraMatrix
GetViewFrustum


That I provide with OpenCascade camera settings, but I can't seem to get a SetCameraMatrix call when only using this particular movement.

Would appreciate if somebody would point me to what I might be doing wrong.

Thanks
ngomes
Moderator
Moderator
Posts: 3431
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Getting the zoom component - C++ / OpenCascade

Post by ngomes »

You will need to add more properties.

For example, the "perspective" property is necessary to ensure the Navigation Library has the information on how to change the camera position. If "perspective" is false (orthogonal projection), then the "view extents" property is used to "zoom" the view.

Since you're using the C++ wrapper classes, use IView::Get/SetViewExtents() and override IView::GetIsViewPerspective() to return the correct data.
Nuno Gomes
Valzul
Posts: 6
Joined: Fri Sep 06, 2024 12:15 am

Re: Getting the zoom component - C++ / OpenCascade

Post by Valzul »

Thanks for the help ngomes, I got more events to work with your help.

But I think I definitely don't understand how to make the whole thing work, because I don't have much knowledge in camera/world projection matrices.

The available matrix available to me to get/set by default which I know of in OpenCascade is the camera orientation matrix. I can also set the eye, direction, center and distance from center of the camera. I got this code to convert to Direction and Up the returning matrix from SetCameraMatrix components :

Code: Select all

SetCameraMatrix(const navlib::matrix_t& affine)
{
    m_Camera->SetDirection(gp_Dir(affine.m02, affine.m12, affine.m22));
    m_Camera->SetUp(gp_Dir(affine.m01, affine.m11, affine.m21));
}
My understanding was that I can just feed the camera matrix with the library matrix but there must be more to it.
ngomes
Moderator
Moderator
Posts: 3431
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Getting the zoom component - C++ / OpenCascade

Post by ngomes »

You will need to ensure you have the correct orientation. If your program's camera matrix is not in the same coordinate system as the Navigation Library (what direction is up and what is right), then you will not get the expected behaviour.

3Dconnexion has an API Support service. The contacts are in the same page where you found the SDK packages. Have a word with them as they may have more helpful information.
Post Reply