나는 vtk progarm을 수행하고 있는데, vtk를 사용하여 창 좌표를 객체 좌표로 매핑해야한다는 점에서
OpenGL 코드는 다음과 같습니다.
winX = 0.2;//some float values
winY = 0.43;//some float values
double posX, posY, posZ;
glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
glGetDoublev( GL_PROJECTION_MATRIX, projection );
glGetIntegerv( GL_VIEWPORT, viewport );
glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ)
gluUnProject(winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);
vtk를 사용하여이 작업을 수행하는 방법을 모르겠습니까? 어떤 도움을 주시면 감사하겠습니다. 또한 이와 같은 모델보기 매트릭스를 얻기위한 솔루션을 봤습니다.
renderWindow->GetRenderers()->GetFirstRenderer()->GetActiveCamera()->GetViewTransformMatrix();
하지만 vtk에서 창 좌표를 객체 좌표로 매핑하는 방법을 모릅니다.
예, VTK는 화면 좌표를 세계 좌표로 매핑 할 수 있습니다. 다음 코드를 필요에 맞게 조정할 수 있습니다 (2D 경우에만 해당).
// 1. Get the position in the widget.
int* clickPosition = this->GetInteractor()->GetEventPosition();
const int x = clickPosition[0];
const int y = clickPosition[1];
// 2. Transform screen coordinates to "world coordinates" i.e. into real coordinates.
vtkSmartPointer<vtkCoordinate> coordinate = vtkSmartPointer<vtkCoordinate>::New();
coordinate->SetCoordinateSystemToDisplay();
coordinate->SetValue(x, y, 0);
double* worldCoordinates = coordinate->GetComputedWorldValue(widget->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
double worldX(worldCoordinates[0]), worldY(worldCoordinates[1]);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다