1

我正在使用Java3D. 它以BranchGroup添加到 Locale 对象的对象(包含一组点)开始。APickCanvas是从 Locale 开始创建的,并且一个类实现MouseListener是从所述 开始构造的PickCanvas

在此阶段正确检测到鼠标点击。我遇到的问题是,每当我开始向我的小程序添加更多点时(通过BranchGroup为加载的每组点创建一个新对象,然后将此对象附加到我的初始Locale对象),当新添加点时,鼠标点击不会被注册被选中。

添加新对象后刷新实现对象时,PickCanvas我可能做错了什么。如何使启动后添加到分支组中的点通过鼠标单击来选择?MouseListenerBranchGroup

下面是语言环境、第一个分支组和鼠标监听器的创建方式:

setLayout(new BorderLayout());
GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();
Canvas3D canvas3D = new Canvas3D(gc);
Utm_Coord_3d observerPoint = new Utm_Coord_3d();
BranchGroup scene=loadPoints(geoPathID, startSequenceID, endSequenceID, observerPoint);
Locale mLocale = new Locale(simpleU);
mLocale.addBranchGraph(scene);
PickCanvas pickCanvas = new PickCanvas(canvas3D, mLocale);
pickCanvas.setMode(PickCanvas.BOUNDS);
MouseMethodsPoints myMouseEventListener = new MouseMethodsPoints(simpleU, viewT3D, pickCanvas);
canvas3D.addMouseListener(myMouseEventListener);
canvas3D.addMouseMotionListener(myMouseEventListener);
canvas3D.addMouseWheelListener(myMouseEventListener);
KeyMethodsPoints myKeyEventListener = new KeyMethodsPoints(canvas3D, simpleU, viewT3D, geoPathID, startSequenceID, endSequenceID, tiltX, scene,mLocale, myMouseEventListener);
canvas3D.addKeyListener(myKeyEventListener);
canvas3D.requestFocus();

最后这就是我将分支组添加到更新pickcanvas的语言环境对象的方式:

BranchGroup newBranchGroup=MainPoints.loadPoints(geoPathID, upperBound+1, upperBound+nFilesLoaded, null);
newBranchGroup.compile();
mLocale.addBranchGraph(newBranchGroup);         
PickCanvas pickCanvas = new PickCanvas(canvas3D,mLocale);       
pickCanvas.setMode(PickCanvas.BOUNDS);
mMouseMethodsPoints.setPickCanvas(pickCanvas);

where在实现类对象中setPickCanvas()设置pickCanvas 。MouseListener我什至尝试在每次添加分支组时创建一个新的 MouseMethodsPoints 对象,但单击仍然会在新分支组的区域中找不到任何点。

感谢您的时间!

4

0 回答 0