Can the Default aircraft to be controled by data which is transferring from outside?

For topics related to the creation of simulation objects (SimObjects). This includes development of aircraft, ground, and maritime vehicles.
Post Reply
reyad__007
Posts: 5
Joined: Mon Oct 22, 2018 3:17 am

Can the Default aircraft to be controled by data which is transferring from outside?

Post by reyad__007 »

Hello,

I want to control the default aircraft in the Prepar3D. I have controled the new SimObject by rewriting the funtion UpDate().(eg. the addons Tracker in the PDK Samples)

STDMETHODIMP Simulation::Update(double dDeltaT)
{
// Update surface and weather info
m_spBaseObject->GetSurfaceInformation(m_SurfaceInfo, NULL);
m_spBaseObject->GetWeatherInformation(m_WeatherInfo);

double latitude = 30.47939;
double longitude = -86.50909;
double altitude = 100.00;

m_vPosCurrent.dZ = DegreesToRadians(latitude);
m_vPosCurrent.dX = DegreesToRadians(longitude);
m_vPosCurrent.dY = altitude;

m_vOrientCurrent.dZ = 0.00;
m_vOrientCurrent.dX = 0.00;
m_vOrientCurrent.dY = 0.00;

m_spBaseObject->SetPosition(m_vPosCurrent, m_vOrientCurrent, DXYZ_ZERO, DXYZ_ZERO, FALSE, dDeltaT);

return S_OK;
}

I tried two methods to control the default aircraft(User aircraft In the Prepar3D).

The first method:

First, I created a new Simulation.
Second, I got the interface of the UserObject by PdkServices::GetSimObjectManager()->GetUserObject((IBaseObjectV400**)&spUserObject).
At the end, I use the service RegisterSimulation() provided through the IBaseObjectV400 to Registe the new Simulation Created in the first step.

But I can not control the User aircraft by the new Simulation.

The second method:

First, I got the interface of the UserObject by PdkServices::GetSimObjectManager()->GetUserObject((IBaseObjectV400**)&spUserObject).
Second, I use the interface of the UserObject(spUserObject I got from the first step) to set a new Position of the User aircraft.(spUserObject->SetPosition())

But I can not update the new position of the UserObject.
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: Can the Default aircraft to be controled by data which is transferring from outside?

Post by Clifton Crane »

Hello,

The Tracker sample was setup to demonstrate a standalone ISimObject that would drive its own position. When selected as the user object, the Tracker ISimObject would move on its own.

Is your DLL an ISimObject that is selected as the user object or are you trying to write a PDK based DLL that will override the position of any selected user object?

You may want to have a look at the DataHarvester sample. That sample shows a PDK based DLL that is used to poll data from the user object. You should be able to do something similar, but instead of polling data from the user object per frame, you can SetPosition on the user object.

You'll also want to double check that your DLL is being correctly loaded via add-on.xml or dll.xml.

Hope this helps!
Clifton Crane
Prepar3D® Software Engineer Sr.
Post Reply