Hi there
For the Unigine v1, we used the following code to get the height above terrain (HAT) and pack it into the CigiHatHotExtResponse packet.
int ret[0];
dvec3 p0 = position + vec3(0.0f,0.0f,1000.0f);
dvec3 p1 = position - vec3(0.0f,0.0f,1000.0f);
Object object = engine.world.getIntersection(p0,p1,~0,ret);
CigiHatHotExtResponse response = new CigiHatHotExtResponse(hathot_id);
if(object != NULL) {
dvec3 point = ret[0];
vec3 normal = ret[1];
response.setResponseValid(1);
response.setHeightAbove(position.z - point.z);
response.setHeightOf(point.z);
response.setAzimuth(atan2(normal.x,normal.y) * RAD2DEG);
response.setElevation(acos(clamp(-normal.z,-1.0f,1.0f)) * RAD2DEG - 90.0f);
}
engine.cigi.addIGPacket(response);
In Unigine V2 there are some changes in the getIntersection* commands.
We tried it as followed:
int ret[0];
dvec3 p0 = position + vec3(0.0f, 0.0f, -200.0f);
dvec3 p1 = position - vec3(0.0f, 0.0f, 1000.0f);
int intersected = engine.world.getIntersectionObjects(p0, p1, ret);
But as it seems, the returned 'ret' value doesn't contains any more the point and its normal of the ground model. As described in the documentation, the ret array contains the result.
Is my approach correct? I should get the point on the ground vertically below the spectator.
Thanks a lot,
Renato