park.sungsoo Posted September 24, 2019 Share Posted September 24, 2019 Hello. I wonder about the world space transform to screen space by camera's matrix. Of course I know unigine engine provides functions internally.(getScreenPosition ) But in our current project, we need logic to get the result through the operation of the matrix, not the corresponding function. First of all, I wonder if it is correct to perform the operation as shown below, and I wonder if there is a matrix that converts to Screen Space like projection matrix and modelview matirx. * Source********************************************************************************************************************** ******************************************************************************************************************************* float znear = 0.00000f; float zfar = 1000.0f; //float aspect = 16.0f / 9.0f;1 //setting up othographic projection float fWidth = 2.0f; float fHeight = 2.0; ORTHO_Unigine_Camera->setProjection(Unigine::Math::ortho(-fWidth, fWidth, -fHeight, fHeight, znear, zfar)); //point world position Unigine::Math::vec3 worldposition = Unigine::Math::vec3(-2.475, -3.475, 0); //get projection matrix Unigine::Math::mat4 projection = m_UnigineCamera->getCamera()->getProjection(); //get modelview matrix Unigine::Math::mat4 modelView = m_UnigineCamera->getCamera()->getModelview(); //get clip space.. Unigine::Math::vec4 p = projection * modelView * Unigine::Math::vec3(worldposition); //next?? shader.. but I wonder about the "unigine's" matrix of screen space..(ortho //(width, height, 1/width, 1/height) // ******************************************************************************************************************************* Thank you. Have a good day. Link to comment
Recommended Posts