如下代码:
void getScreentPos(double displayPos[3], double world[3])
{
double fp[4], tmp1[4], eventFPpos[4];
renderer->GetActiveCamera()->GetFocalPoint(fp);
cout << "GetFocalPoint" << fp[0] << "-" << fp[1] << "-" << fp[2] << "-" << fp[3] << endl;
fp[3] = 1.0;
renderer->SetWorldPoint(fp);
renderer->WorldToDisplay();
renderer->GetDisplayPoint(tmp1);
tmp1[0] = displayPos[0];
tmp1[1] = displayPos[1];
renderer->SetDisplayPoint(tmp1);
renderer->DisplayToWorld();
renderer->GetWorldPoint(eventFPpos);
}
void getScreentPos(double displayPos[3], double world[3])
{
double fp[4], tmp1[4], eventFPpos[4];
renderer->GetActiveCamera()->GetFocalPoint(fp);
cout << "GetFocalPoint" << fp[0] << "-" << fp[1] << "-" << fp[2] << "-" << fp[3] << endl;
fp[3] = 1.0;
renderer->SetWorldPoint(fp);
renderer->WorldToDisplay();
renderer->GetDisplayPoint(tmp1);
tmp1[0] = displayPos[0];
tmp1[1] = displayPos[1];
renderer->SetDisplayPoint(tmp1);
renderer->DisplayToWorld();
renderer->GetWorldPoint(eventFPpos);
}