Hello, I have some additional points that I’ve added into my own implementation of the vtkChartXYZ. Actually, they are the mid points of all of the vertices of the 3d box that bounds the chart. What I would like to be able to do is work out the x,y 2d coodinates of those points (from the perspective of the viewer).
Anyone got any suggestions on how I should do this?
I have this method that I call from the vtkChartXYZ::Paint method. I want to get the missing bit that I’ve written a comment for:
void vtkChartXYZ::DrawAxesMidPoints(vtkContext2D* painter) {
vtkContext3D* context = painter->GetContext3D();
context->ApplyPen(this->Pen);
for (int axis = 0; axis < 3; axis++) {
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
float midpoint[3];
midpoint[0] = (axis == 0) ? 0.5 : i;
midpoint[1] = (axis == 1) ? 0.5 : (axis == 0) ? i : j;
midpoint[2] = (axis == 2) ? 0.5 : j;
this->Box->TransformPoint(midpoint, midpoint);
context->DrawPoint(vtkVector3f(midpoint));
// x, y, z coordinates (3d)
cout << "midpoint " << midpoint[0] << " " << midpoint[1] << " " << midpoint[2] << endl;
// I want to work out the 2d viewer's perspective x and y coordinates...
}
}
}
context->ApplyPen(this->AxisPen);
}