The pbh value is being converted incorrectly. This function can still be used with the PBH and XYZ set to zero, and it should give you a valid screen coordinate for a given LLA. I suspect this is how must developers have been using it since this bug has been around since v2. The good news is, there is a workaround. If you need to calculate an LLA based on the body relative offset from an LLAPBH, you can do that using IObjectRenderer::ApplyBodyRelativeOffset (a new PDK interface added in 3.4 and used in the custom lights sample).
Code: Select all
struct LLADegreesMeters
{
double Latitude;
double Longitude;
double Altitude;
LLADegreesMeters() : Latitude(0.0), Longitude(0.0), Altitude(0.0) {}
LLADegreesMeters(double latitude, double longitude, double altitude)
: Latitude(latitude), Longitude(longitude), Altitude(altitude) {}
};
struct PBHDegrees
{
float Pitch;
float Bank;
float Heading;
PBHDegrees() : Pitch(0.0f), Bank(0.0f), Heading(0.0f) {}
PBHDegrees(float pitch, float bank, float heading)
: Pitch(pitch), Bank(bank), Heading(heading) {}
};
struct XYZMeters
{
float X;
float Y;
float Z;
XYZMeters() : X(0.0f), Y(0.0f), Z(0.0f) {}
XYZMeters(float x, float y, float z) : X(x), Y(y), Z(z) {}
};
struct ObjectLocalTransform
{
XYZMeters XYZ;
PBHDegrees PBH;
ObjectLocalTransform(){}
ObjectLocalTransform(float x, float y, float z, float pitch, float bank, float heading)
: XYZ(x, y, z), PBH(pitch, bank, heading) {}
};
struct ObjectWorldTransform
{
LLADegreesMeters LLA;
PBHDegrees PBH;
ObjectWorldTransform(){}
ObjectWorldTransform(double latitude, double longitude, double altitude,
float pitch, float bank, float heading)
: LLA(latitude, longitude, altitude), PBH(pitch, bank, heading) {}
};
/**
* Service for rendering lights into a view
*/
DECLARE_INTERFACE_(IObjectRenderer, IUnknown)
{
/**
* Add a light to the group
*/
virtual HRESULT AddLight(float x,
float y,
float z,
unsigned int lightType,
unsigned int color,
float size,
float range,
bool bAttenuateByAmbient) abstract;
/**
* Begin a light group with na origin at the LLA provided
*/
virtual HRESULT BeginLightGroup(ObjectWorldTransform& groupOrigin) abstract;
/**
* End a light group.
*/
virtual HRESULT EndLightGroup(bool sortGroup) abstract;
/**
* Applu body relative local transformation to a world transform
*/
virtual void ApplyBodyRelativeOffset(const ObjectWorldTransform& llapbhAtOrigin,
const ObjectLocalTransform& offsetXyzPbh,
ObjectWorldTransform& llapbhAtOffset) abstract;
/**
* Calculate body relative offset between two world transforms
*/
virtual void CalculateBodyRelativeOffset(const ObjectWorldTransform& llapbhAtOrigin,
const ObjectWorldTransform& llapbhAtOffset,
ObjectLocalTransform& offsetXyzPbh) abstract;
};
See IRenderingService.h and the custom lights sample for more details.