Texture resolution in P3D v4.5 POD view

Any issues, problems or troubleshooting topics related to the additional features present in the Prepar3D Professional Plus client application.
User avatar
Beau Hollis
Lockheed Martin
Posts: 2452
Joined: Wed Oct 06, 2010 3:25 pm

Re: Texture resolution in P3D v4.5 POD view

Post by Beau Hollis »

The callback is only called when the window plugin is added to a specific window. You need to get a window (by name or GetCurrentWindow, or getting the list of windows and iterating over them) and call AddPlugin() to register your plugin to that window. Then you'll get all the window plugin specific callbacks so you can handle camera changes, window closure, etc. Another option is to call RegisterInternalWindow() which is more or less the same as looking up the window by name and calling AddPlugin(). Finally you can use CreateInternalWindow() to create a new window (usually used for render to texture views) and you can pass a plugin in as a parameter. Again this just saves you an extra step of manually adding the plugin to the window after creating it. The Create/Register methods are used in the CameraPDK sample. The AddPlugin method is used in the MousePicking sample.
Beau Hollis
Prepar3D Software Architect
zamirk
Posts: 132
Joined: Mon Jul 21, 2014 8:39 am

Re: Texture resolution in P3D v4.5 POD view

Post by zamirk »

Hi Beau Hollis,
Really appreciate your masterly guidance, the following approach helped me in keeping the scene/terrain loaded:
I made a class WindowCallback which inherits from P3D::WindowPlugin, In this class I override the OnPostCameraUpdate method. In OnCustomRender function of TargetingPodPlugin class I registered my window with the callback instance.

Code: Select all

static const std::wstring win_name(L"TargetingPodView - View 01");

Code: Select all

static WindowCallback* g_pWindowCallback = nullptr;

Code: Select all

virtual void OnCustomRender(IParameterListV400* pParams) override{
	CComPtr<IWindowPluginSystem> spPluginSystem = PdkServices::GetWindowPluginSystem();
	if(spPluginSystem != NULL){
		if(g_pWindowCallback == nullptr){
			g_pWindowCallback = new WindowCallback();
			if(spPluginSystem->HasWindow(win_name.c_str())){
				spPluginSystem->RegisterInternalWindow(win_name.c_str(), g_pWindowCallback);
			}
		}
	}
}

Code: Select all

virtual void OnPostCameraUpdate(P3D::IWindowV400* pWindow, P3D::ICameraSystemV400* pCamera) override{
	if(pWindow && pCamera){
		double dTime;
		int iSeconds;
		double m_fLookAtLat = 0, m_fLookAtLon = 0, m_fLookAtAlt = 0;
		PdkServices::GetGlobalData()->GetUnitCode(L"Seconds", iSeconds);
		PdkServices::GetGlobalData()->GetAbsoluteTime(dTime, iSeconds);
		pCamera->GetCameraLookAtLLA(m_fLookAtLat, m_fLookAtLon, m_fLookAtAlt);
		
		if((dTime - m_dElapsedTime) > 1){
			m_dElapsedTime = dTime;
			if(m_OneSecDelay)
				m_OneSecDelay=false;
			else
				m_OneSecDelay=true;
		}
		
		if(m_OneSecDelay){
			double latRad = DEGREES_TO_RADIANS(m_fLookAtLat);
			double lonRad = DEGREES_TO_RADIANS(m_fLookAtLon);
			pCamera->SetSceneryLODOriginLLA(latRad, lonRad, m_fLookAtAlt);
			pCamera->SetTerrainLODOriginLLA(latRad, lonRad, m_fLookAtAlt);
		}
	}
}
Post Reply