|
jmoliere
|
 |
« on: 17. June 2008, 03:26:04 pm » |
|
Greetings, I'm pulling what hair I have left with determining which component of the QuadDivider or FourViewsPanel got the mouse event.
In AWT, I could call 'getComponentAt(mousePosX, MousePosY)' and get the respective component that the mouse is located. This method doesn't seem to work in FourViewsPanel. Also in AWT there is a 'getSource()' method. The MouseEvent handling in Xith doesn't use AWT and never returns the origin component of the click.
I tried something like this -- to no avail... public class MyFourViews extends extends InputAdapterRenderLoop {
HandleSWView hswv = new HandleSWView(); hswv.getInputmanager().registerKeyboardAndMouse(fvp.getSWPanel().getCanvas());
this.getInputManager().registerkeyboardAndMouose(fvp.getSEPanel().getCanvas());
class HandleSWView extends InputadapterRenderLoop { public void onMouseMoved(MouseMovedEvent e) { ... } }
public void onMouseMoved(MouseMovedEvent e) { ... } }
Using QuadDivider, I would expect methods like 'getVerticalDividerPos()' and 'getHorizontalDividerPos()' to exist so I can mathematically deduce which component got the mouse event and procede forward. Unfortunately, these methods don't exist.
Any helpful suggestions?
Thanks!
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #1 on: 17. June 2008, 09:39:53 pm » |
|
[code]First of all please checkout the latest Xith3D and Xith-tk from SVN. Please don't use the beta-download atm, since there are a whole lot of improvements in SVN and it works very stable and is MUCH faster.
In SVN the new InputSystem is used. And it will allow for what you need for the FourViewsPanel. Just use a mouse-click-event-method like this:
@Override public void onMouseButtonPressed( MouseButtonPressedEvent e, MouseButton button ) { CanvasPeer canvasPeer = (CanvasPeer)e.getMouse().getSourceWindow(); System.out.println( canvasPeer.getCanvas3D() ); System.out.println( canvasPeer.getCanvas3D().getComponent() ); } [/code] The Canvas3D has a method getComponent(), that returns the AWT-component in case of an AWT/Swing setup. You can cast it to java.awt.Component. As for the QuadDivider: The version in SVN has all the methods to query and modify the sizes. So this should still be the preferred way. Marvin
|
|
|
|
|
Logged
|
|
|
|
|
jmoliere
|
 |
« Reply #2 on: 18. June 2008, 12:28:33 am » |
|
Marvin, It appears that event handling is very different in the latest and greatest code. For example, in the code below, getInputManager() doesn't exist anymore. Can you direct me to the new way of registering for events? I have looked around in other posts but didn't see anything that maps registerKeyboardAndMouse to the new way of doing things.
public class MyFourViews extends extends InputAdapterRenderLoop {
HandleSWView hswv = new HandleSWView(); // doesn't work below... this.getInputManager().registerkeyboardAndMouose(fvp.getSEPanel().getCanvas()); .....
Thanks!
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #3 on: 18. June 2008, 12:47:27 am » |
|
Hmm... Did you ever have a look at the xith-tk testcases or read XIN? I mean, I hate to say RTFM. But in this case, it would have been simple, since all testcases use/do it  . In the new code it is done the following way: InputSystem.getInstance().registerNewKeyboardAndMouse( canvas.getPeer() );
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
jmoliere
|
 |
« Reply #4 on: 18. June 2008, 12:55:28 am » |
|
Marvin, I shall RTFTCs
Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
|
|
jmoliere
|
 |
« Reply #6 on: 23. June 2008, 08:34:02 pm » |
|
Marvin, The code below has been updated to work with the latest and greatest Xith and it's respective event handling. http://www.javademos.com/XithDisplay.tgzI'm still at a loss at how to get access to one of the Quad Views without resorting to java.awt.event.* handling. In other words, how can I determine which of the 4 quads the mouse is over? I would like to use methods that the creators of Xith would prefer instead of pulling out my pocket knife and rolling my own. The samples to take a look at are org.xith3d.test.ui.FourViewsPanelTest.java org.xith3d.test.ui.QuadViewportTest.java
|
|
|
|
« Last Edit: 23. June 2008, 09:07:22 pm by jmoliere »
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #7 on: 23. June 2008, 09:17:45 pm » |
|
Wow! You sent your whole workspace within that file  . Well, I don't know, what up with your project. It only shows up two windows when it is started, of which one is small and completely black and the other one is larger with a white square in it. Nothing else happens. I will see, if I can dig into the source a little more when I have time. For now I have added another convenience method to QuadDivider, that gives you exactly this information. Please see its implementation. It is really simple. As an example of usage I used a mouse-event-method like this: @Override public void onMouseMoved( MouseMovedEvent e, int x, int y, int dx, int dy ) { System.out.println( quadDivider.getPanelUnderMouse( x, y ) ); }
I hope, this helps. Marvin
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #8 on: 23. June 2008, 09:47:08 pm » |
|
Ah, I see. I was running the wrong source. The testcase in question was the modified QuadViewportTest. You seem to be expecting the QuadViewportTest to use four canvases, which it of course doesn't. This is, why it is so much faster. It uses ONE Canvas3D with four viewports, which are modified through the QuadDivider widget. And in your modified source you forgot to attach the HUD to the scenegraph, which is why it won't work at all. Please use this line to add the HUD: sg.addHUD( hud );
You will also find it in the original source from xith-tk. If you need four Canvas3Ds with an AWT component each, you will need to use the (slower) FourceViewsPanelTest-way. What do you want to do with the quad-divided UI? This information may be helpful to give you better advices. Marvin
|
|
|
|
|
Logged
|
|
|
|
|
jmoliere
|
 |
« Reply #9 on: 23. June 2008, 10:33:23 pm » |
|
Marvin, That wrong source is now the correct source for another thread -- the bad billboards.
I have fixed the code 'sg.addHUD( hud );' and am putting it up in case you want to use this source base.
To answer your question, 'What do you want to do with the quad-divided UI?', I'd like to pan, tilt, and zoom each panel. Without knowing which quad I'm working with, I don't know which camera/view to select and move around.
As for the code 'System.out.println( quadDivider.getPanelUnderMouse( x, y ) );'
I'll check out the latest and greatest.
Thanks!
|
|
|
|
« Last Edit: 23. June 2008, 11:02:13 pm by jmoliere »
|
Logged
|
|
|
|
|
jmoliere
|
 |
« Reply #10 on: 24. June 2008, 07:58:29 pm » |
|
Wow! You sent your whole workspace within that file  . Well, I don't know, what up with your project. It only shows up two windows when it is started, of which one is small and completely black and the other one is larger with a white square in it. Nothing else happens. I will see, if I can dig into the source a little more when I have time. For now I have added another convenience method to QuadDivider, that gives you exactly this information. Please see its implementation. It is really simple. As an example of usage I used a mouse-event-method like this: @Override public void onMouseMoved( MouseMovedEvent e, int x, int y, int dx, int dy ) { System.out.println( quadDivider.getPanelUnderMouse( x, y ) ); }
I hope, this helps. Marvin Marvin, I'm not totally on top of Xith to know what to say but getting the java.awt.Component may not be the best object to return. An object that contains the View, the BranchGroup, and the the respective Canvas3D may be the best object. This will allow users to tweak the branch, view, or what-ever they choose. jmoliere
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #11 on: 24. June 2008, 08:29:17 pm » |
|
I'm not totally on top of Xith to know what to say but getting the java.awt.Component may not be the best object to return. An object that contains the View, the BranchGroup, and the the respective Canvas3D may be the best object. This will allow users to tweak the branch, view, or what-ever they choose.
I am not sure, if I understood your right here. But the approach above has nothing to do with java.awt.Components. The syso above just prints out an abstract indicator for the panel/area, you're hovering. Then you can use this indicator to map to any information, you need. I have modified the QuadViewportTest in xith-tk to do a mapping like this. All you need is contained in the four RenderPasses. Please see the testcase, where I mapped the abstract panel/area info to the appropriate RenderPass. The RenderPass holds a RenderPassConfig object, that keeps a view-transform, the Viewport, etc... all you need. Marvin
|
|
|
|
|
Logged
|
|
|
|
|
jmoliere
|
 |
« Reply #12 on: 25. June 2008, 03:04:38 pm » |
|
The QuadView uses a Rect2i as the camera to display the contents. How would I zoom in on an object located in the quad? Why did the Rect2i object get used over the View object component? I'd also like to change each quad's view perspective -- parallel and projective.
Thanks! jmoliere
|
|
|
|
« Last Edit: 25. June 2008, 03:55:34 pm by jmoliere »
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #13 on: 25. June 2008, 04:03:16 pm » |
|
The QuadView uses a Rect2i as the camera to display the contents. How would I zoom in on an object located in the quad? Why did the Rect2i object get used over the View object component?
The Rect2i is NOT a View-replacement. It is the Viewport. Let me give you some more explanations. The SceneGraph (Xith3DEnvironment) can contain any number of RenderPasses. Let's assume, you have one View and one Canvas3D (like in the QuadViewportTest), which is the fastest way to go. If of the RenderPasses can have its own sub-graph or share a BranchGroup with other RenderPasses (like in QuadViewportTest). Each RenderPass has its own RenderPassConfig, which you can retrieve through pass.getConfig(). This RenderPassConfig keeps a lot of settings, that don't apply for the whole SceneGraph, but for this RenderPass only. the default values are mostly something like "inherit from SceneGraph". The two mostly relevant settings from RenderPassConfig for you in this case are "view-transform" and "viewport". The view-transform together with some other settings from RenderPassConfig (like field-of-view) build all the settings, a view normally has, but only apply to the one single RenderPass. The Viewport is a definition of a sub-area of the Canvas3D to render this RenderPass on - nothing more and nothing less. Please have a look at RenderPassConfig and DefaultRenderPassConfig to get a full overview of all the possible settings for a RenderPass. There are also a few more settings for a RenderPass, that are not in the RenderPassConfig object, but in the RenderPass directly. But these ones are not important for you this time. I hope, this was helpful. Marvin
|
|
|
|
|
Logged
|
|
|
|
|
jmoliere
|
 |
« Reply #14 on: 25. June 2008, 08:39:59 pm » |
|
Marvin, Thanks for your post above. I did get all 4 quadrants to have their own view and can pan them using the right mouse click and zooming in/out with the mouse wheel. http://www.javademos.com/XithDisplay.zipThe only problem I have now is when the images overlap the divider and display in the next quadrant. What do you suggest I use to cut/crop the image that rolls over onto another quad? Thanks!
|
|
|
|
|
Logged
|
|
|
|
|