Currently Being Moderated
Hi,
I've been able to do it in Perspective projection the code above. Why does'n it work the same with Parallel projection? The point where new geometry is added doesn't correspond to the mouse point on screen...
public Point3d getCanvasPtToVworldPt(int x, int y) {
if(view.getProjectionPolicy()==View.PERSPECTIVE_PROJECTION){
Point3d VworldPt = new Point3d();
Point3d centerEyePt = new Point3d();
// convert the canvas point to ImagePlate coords
cv.getPixelLocationInImagePlate(x, y, VworldPt);
// transform the point from an imageplate coordinate to a Vworld
// coordinate
Transform3D imagePlateToVworld = new Transform3D();
cv.getImagePlateToVworld(imagePlateToVworld);
imagePlateToVworld.transform(VworldPt);
cv.getCenterEyeInImagePlate(centerEyePt);
imagePlateToVworld.transform(centerEyePt);
double alpha = 0.0;
if (VworldPt.z != centerEyePt.z) {
alpha = centerEyePt.z / (VworldPt.z - centerEyePt.z);
}
Point3d planePt = new Point3d(
centerEyePt.x - alpha * (VworldPt.x - centerEyePt.x),
centerEyePt.y - alpha * (VworldPt.y - centerEyePt.y),
0.0); //centerEyePt.z - beta * (VworldPt.z - centerEyePt.z )
return planePt;
}
thanks