Hi,
I need the 2D screen Position of a 3D Node transformation.
Can you write me a short code example with unigine matrices form the Player and Node and perspective division to get the NDC coordinates?
auto proj = m_player->getProjection();
auto view = m_player->getTransform();
auto obj = instance->second->getNode()->getTransform();
auto projectedPosition = Unigine::Math::Mat4(proj)*view*obj*Unigine::Math::Vec4(0.0, 0.0, 0.0, 1.0);
projectedPosition /= glm::abs(projectedPosition.w);
x = (projectedPosition.x+1.0f)*0.5f * m_ungineAppHandle->getWidth();
y = (1.f-(projectedPosition.z+1.0f)*0.5f) * m_ungineAppHandle->getHeight();
Thank you in advance,
Sebastian