シーングラフの変換行列を z 法線 (0, 0, 1) に適用すればできると思いますが、うまくいきません。私のコードは次のようになります。
Vector3f toScreenVector = new Vector3f(0, 0, 1);
Transform3D t3d = new Transform3D();
tg.getTransform(t3d); //tg is Transform Group of all objects in a scene
t3d.transform(toScreenVector);
次に、次のようなことも試しました。
Point3d eyePos = new Point3d();
Point3d mousePos = new Point3d();
canvas.getCenterEyeInImagePlate(eyePos);
canvas.getPixelLocationInImagePlate(new Point2d(Main.WIDTH/2, Main.HEIGHT/2), mousePos); //Main is the class for main window.
Transform3D motion = new Transform3D();
canvas.getImagePlateToVworld(motion);
motion.transform(eyePos);
motion.transform(mousePos);
Vector3d toScreenVector = new Vector3f(eyePos);
toScreenVector.sub(mousePos);
toScreenVector.normalize();
しかし、それでもこれは正しく機能しません。そのようなベクトルを作成する簡単な方法があるに違いないと思います。私のコードの何が問題なのか、またはより良い方法を知っていますか?