Hello

Okay thanks


Le sam. 21 janv. 2023 à 15:42, Robert Osfield <[email protected]> a
écrit :

> Could you post your question on the new github forum as this is new
> official place for support.
>
> https://github.com/openscenegraph/OpenSceneGraph/discussions
>
> On Tuesday, 17 January 2023 at 14:24:01 UTC [email protected] wrote:
>
>> Hello all
>>
>> I have some questions.
>>
>> I want to transmit the camera of my opengl scene to my OSG scene, to do
>> this I retrieve the view of my camera as well as the point it is looking at
>> with the following code:
>>
>> {
>> GLdouble camera_pos[3];
>>
>>         double rationZoom    =
>> m_pModel->GetView()->m_graphEnv.GetZoomRatio();
>>         int* iViewport       =
>> m_pModel->GetView()->m_graphEnv.GetViewport();
>>         double* projetMatrix =
>> m_pModel->GetView()->m_graphEnv.GetProjMatrix();
>>         double* modelMatrix  =
>> m_pModel->GetView()->m_graphEnv.GetModelMatrix();
>>
>>         double screenCenterX =
>> m_pModel->GetView()->m_graphEnv.GetScreenCenterX();
>>         double screenCenterY =
>> m_pModel->GetView()->m_graphEnv.GetScreenCenterY();
>>
>>         double rotateX =
>> m_pModel->GetView()->m_graphEnv.GetRotationCenterX();
>>         double rotateY =
>> m_pModel->GetView()->m_graphEnv.GetRotationCenterY();
>>         double rotateZ =
>> m_pModel->GetView()->m_graphEnv.GetRotationCenterZ();
>>
>>   // I retrieve the camera and the center of the screen (for the point it
>> is looking)
>>         gluUnProject((iViewport[2] - iViewport[0]) / 2, (iViewport[3] -
>> iViewport[1]) / 2,
>>             0.0, modelMatrix, projetMatrix, iViewport, &camera_pos[0],
>> &camera_pos[1], &camera_pos[2]);
>>
>>         // rotCenter it's the center point looking
>>         osg::Vec3f rotCenter = osg::Vec3f(screenCenterX,
>>                                           screenCenterY,
>>                                           rationZoom * (-1.0));
>>
>>         double X = (camera_pos[0] / 2) / rationZoom;
>>         double Y = (camera_pos[1] / 2) / rationZoom;
>>         double Z = (camera_pos[2] / 2) / rationZoom;
>>
>>        osg::Vec3 updateCameraPosition(X, Y,Z);
>>
>>         osg::Vec3f eye(updateCameraPosition);
>>
>>         osg::Vec3f up(0, 0, 1);
>>         osg::Vec3f centre = osg::Vec3f(rotCenter.x(), rotCenter.y(),
>> rotCenter.z());
>>         nodeCamera->setViewMatrixAsLookAt(eye, centre, up);
>> }
>>
>> but i don't know why, i have wrong values with osg eye Y axis. Does
>> anyone have any ideas ??
>>
>> If I'm not mistaken the OpenGL coordinate system is : Y up, X right, Z
>> forward but I don't have this configuration on my OSG scene. Maybe this is
>> the problem ?
>>
>> Or I have to use Matrix Transform and rotate the matrix to have the same
>> coordinate system of my OpenGL scène ??  So can I set matrixtransform with
>> my camera and set it to my viewer ??
>>
>> Thanks in advance
>> Souffou
>>
> --
> You received this message because you are subscribed to the Google Groups
> "OpenSceneGraph Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osg-users/730dba22-191e-4c5e-a4d7-44c3d6adcddbn%40googlegroups.com
> <https://groups.google.com/d/msgid/osg-users/730dba22-191e-4c5e-a4d7-44c3d6adcddbn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osg-users/CALpo-HFG_5yymxc4-8ANWANSLeAGq35HmnRLyRJdCa7-VbbdyA%40mail.gmail.com.

Reply via email to