Jump to content

Camera Zoom Orientation Problem


photo

Recommended Posts

I wanted to write to you at the camera point. I mentioned that the problem about the camera accuracy has been solved in the subject I opened past days. At this stage, I am working on a simple gimbal camera and when I perform the related camera rotation, the sliding occurs in the related FOV because it provides a dynamic movement according to my intersection on the earth. If you help me ,I would be pleased.

My basic algorithm for camera zoom

void Sim::Manager::BCameraManager::update_camera_zoom(){
		mGimbal.camera->setFov(params.maxFov);

        float tcurrent_zoom_factor = params.maxFov/params.fov; //these are fov and calculated correctly
        //float z_far = mGimbal.camera->getZFar();
        //float z_near = mGimbal.camera->getZNear();
        Unigine::Math::vec3 direction = mGimbal.camera->getWorldDirection(Unigine::Math::AXIS_NZ);
        Unigine::Math::Vec3 p1 = mGimbal.camera->getWorldPosition();
        Unigine::Math::Vec3 p2 = p1 + Unigine::Math::Vec3(direction * 20000.0);
        auto intersection = Unigine::WorldIntersection::create();
        // mGimbal.camera->setViewportMask(0x400);
        auto res = Unigine::World::get()->getIntersection(p1, p2, 0x00000400, intersection);//4 Landscape 
        // mGimbal.camera->setViewportMask(0x1);
        Unigine::Math::Vec3 point;

        if (res) {
            point = intersection->getPoint();
            camzoomparam.distance = length(point - p1); //Here i get intersection between gimbal cam and landscape
            qDebug()<<"intersection @";
        } else {
            point = p2;
            qDebug()<<"No intersection!";
        }
  
         camzoomparam.distance -= camzoomparam.distance/tcurrent_zoom_factor; //Zooming operation for gimbal cam position
  
         mGimbal.camCurrentPoint = p1+ Unigine::Math::Vec3(direction * camzoomparam.distance);
  		 mGimbal.camera->getCamera()->setPosition(mGimbal.camCurrentPoint);//Here i apply cam position therefore it gives accuracy like a manual zoom operation .
  //The Only Problem is , intersection point is always change(because landscape point of intersection is changing when i turn gimbal cam to another point)
  //So I have to keep related cam fov when i move gimbal  to right,left and up,down
  //But i really have no idea
}

Thank you in advance

Edited by burakdogancay
Link to comment
×
×
  • Create New...