Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3507 Members - Latest Member: PienueDut

26. May 2012, 01:06:00 pm
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)Actions in SelectionTest question
Pages: [1] 2
Print
Author Topic: Actions in SelectionTest question  (Read 1323 times)
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« on: 01. December 2009, 09:31:21 pm »

Marvin

    In the SelectionTest  there is code of the form below.  How is this activated ??

Code:
final BoundingBoxSelectable<Node> cubeSelectable = new BoundingBoxSelectable<Node>( cube );
        cubeSelectable.register( new MenuAction( "Action1" )
        {
            @Override
            public void onActionPerformed()
            {
                //JOptionPane.showMessageDialog( null, "Clicked " + this.getName() );
                MsgBox.show( "Clicked " + this.getName(), hud );
            }
        } );
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #1 on: 02. December 2009, 01:07:41 pm »

In org.xith3d.selection.HUDContextMenuProvider, there is
Code:
public void showContextMenu(...)
    {
...
        for ( int i = 0; i < selection.size(); i++ )
        {
            Selectable selectable = selection.get( i );
            List<MenuAction> actions = selectable.lookup( MenuAction.class );
            result.addAll( actions );
        }

selectable.lookup(...) is the reciprocal of selectable.register(...).

Hope this helps even though I'm not Marvin Wink
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #2 on: 02. December 2009, 07:38:44 pm »

I'm not sure, if I understood the question correctly. But if I do, Kevin gave the answer Smiley.

Marvin
Logged
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« Reply #3 on: 02. December 2009, 08:49:03 pm »

I never get a hud menu. 

Left mouse selects and moves shapes

Middle mouse does nothing

Right mouse generates
Code:
Selected tris
java.lang.NullPointerException
at org.xith3d.ui.hud.HUD.removeInternalWidget(HUD.java:962)
at org.xith3d.ui.hud.HUD.removeVolatilePopup(HUD.java:939)
at org.xith3d.ui.hud.__HUD_PrivilegedAccess.removeVolatilePopup(__HUD_PrivilegedAccess.java:69)
at org.xith3d.ui.hud.contextmenu.ContextMenu.popUp(ContextMenu.java:184)
at org.xith3d.selection.HUDContextMenuProvider.showContextMenu(HUDContextMenuProvider.java:68)
at org.xith3d.selection.SelectionManager.onObjectsPicked(SelectionManager.java:487)
at org.xith3d.picking.PickingLibrary.pickAll(PickingLibrary.java:292)
at org.xith3d.picking.PickingLibrary.pickAll(PickingLibrary.java:384)
at org.xith3d.picking.PickingLibrary.pickAll(PickingLibrary.java:424)
at org.xith3d.picking.PickingLibrary.pickAll(PickingLibrary.java:443)
at org.xith3d.selection.SelectionManager.onHUDPickMissed(SelectionManager.java:392)
at org.xith3d.ui.hud.HUD.pick(HUD.java:1631)
at org.xith3d.ui.hud.HUD.onMouseButtonReleased(HUD.java:1719)
at org.xith3d.ui.hud.HUDInputSystemConnection.onMouseButtonReleased(HUDInputSystemConnection.java:105)
at org.jagatoo.input.devices.Mouse.fireOnMouseButtonReleased(Mouse.java:490)
at org.jagatoo.input.devices.Mouse.fireMouseEvent(Mouse.java:690)
at org.jagatoo.input.events.EventQueue.dequeueAndFire(EventQueue.java:105)
at org.jagatoo.input.impl.awt.AWTMouse.updateMouse(AWTMouse.java:271)
at org.jagatoo.input.devices.Mouse.update(Mouse.java:773)
at org.jagatoo.input.InputSystem.updateMouses(InputSystem.java:1135)
at org.jagatoo.input.InputSystem.update(InputSystem.java:1178)
at org.xith3d.base.Xith3DEnvironment.updateInputSystem(Xith3DEnvironment.java:210)
at org.xith3d.loop.RenderLoop.prepareNextFrame(RenderLoop.java:593)
at org.xith3d.loop.RenderLoop.loopIteration(RenderLoop.java:638)
at org.xith3d.loop.RenderLoop.update(RenderLoop.java:698)
at org.xith3d.loop.UpdatingThread.nextIteration(UpdatingThread.java:473)
at org.xith3d.loop.RenderLoop.nextIteration(RenderLoop.java:709)
at org.xith3d.loop.RenderLoop.loop(RenderLoop.java:762)
at org.xith3d.loop.UpdatingThread.run(UpdatingThread.java:526)
at org.xith3d.loop.RenderLoop.run(RenderLoop.java:785)
at org.xith3d.loop.RenderLoop.begin(RenderLoop.java:841)
at org.xith3d.loop.RenderLoop.begin(RenderLoop.java:871)
at org.xith3d.test.selection.SelectionTest.main(SelectionTest.java:307)
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #4 on: 02. December 2009, 10:11:16 pm »

I have semi-fixed this. But it still behaves stragely. I will ask Mathias.

Marvin
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #5 on: 05. December 2009, 09:34:32 pm »

Previously, I was rolling my own selection handling.  Since that's a bad idea, I'm trying to setup selection handling of HUD events as demonstrated in the SelectionTest.

Is there a trick to it?  With a lot of code omitted, here is what I am doing.
Code:
public class MySceneMaker
{
    public BranchGroup createScene()
    {
        BranchGroup result = new BranchGroup();
        Sphere sphere = new Sphere( 0.25f, 16, 16, Colorf.WHITE );
        StaticTransform.translate( sphere, -5, 5, 0 );
        sphere.setName( "Sphere" );
        sphere.setUserData( Selectable.class, new BoundingBoxSelectable< Node >( sphere ) );
        result.addChild( sphere );
        return result;
    }
}

public class MyHud extends HUD
{
    public MyHud( XithRoot xithRoot )
    {
        xithRoot.myInputHandler.selectionManager = new SelectionManager();
        xithRoot.myInputHandler.selectionManager.bind( xithRoot.branchGroup, xithRoot.firstCanvas );
        InputSystem.getInstance().getMouse().addMouseListener( xithRoot.myInputHandler.selectionManager );

        xithRoot.myInputHandler.selectionManager.setContextMenuProvider( new HUDContextMenuProvider( this ) );
        xithRoot.myInputHandlerselectionManager.addSelectionListener( new SelectionListener()
        {
            public void selectionChanged( List< Selectable > selection, List< Selectable > selectedContext )
            {
                for( int i = 0; i < selection.size(); i++ )
                {
                    Selectable selectable = selection.get( i );
                    Node node = selectable.getNode();
                    System.out.println( "Selected " + node.getName() );
                }
            }

            public void selectionMoved( List< Selectable > selection, List< Selectable > selectedContext, Vector3f delta )
            {
                for( int i = 0; i < selection.size(); i++ )
                {
                    Selectable selectable = selection.get( i );
                    Node node = selectable.getNode();
                    System.out.println( node.getName() + " moved" );
                }
            }
        } );

        addPickMissedListener( SelectionManager.HUD_PICK_MISSED_MASK, xithRoot.myInputHandler.selectionManager );
    }
}

I never get the print statements.  I think the omitted code can't hurt anything involved here but could include it if it helps.

I don't know if this has any bearing on the problem, but I found that
Code:
        setCrosshair( createCrossHairTexture() );
        setCrosshairVisible( true );
does not work but that
Code:
        getContentPane().addWidgetCentered( new Image( 32f, 32f, createCrossHairTexture() ) );
does.
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #6 on: 05. December 2009, 09:52:10 pm »

I am still waiting for an answer from Mathias about the selection stuff. But the crosshair works like shown in the BSPLoaderTest.

Marvin
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #7 on: 05. December 2009, 10:15:10 pm »

Using the Texture2D.create() factory methods instead of constructing it the way I was fixed the setCrosshair bug.
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #8 on: 06. December 2009, 01:21:40 am »

It turns out that the SelectionManager does not work if FirstPersonInputHandler has setMouseMovementSuspended( false ) which is the default.
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #9 on: 06. December 2009, 01:56:26 pm »

I have added the following code to the end of SelectionTest's constructor.
Code:
FirstPersonInputHandler fpih = new FirstPersonInputHandler( env.getView(), canvas );
fpih.setMouseSuspended( true );
InputSystem.getInstance().addInputHandler( fpih );

And the selection still works. Could you please check this?

Marvin
Logged
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« Reply #10 on: 07. December 2009, 03:37:44 pm »

excellant...all is well
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #11 on: 07. December 2009, 04:11:28 pm »

Correct, it works with true, which is what was in the SelectionTest.

Try
Code:
        moveHandler = new FirstPersonInputHandler( env.getView(), env.getCanvas(), 0.5f, 0.5f, arguments.getMouseYInverted(), 0.5f );
        moveHandler.setMouseMovementSuspended( false );
        moveHandler.getBindingsManager().createDefaultBindings();
which does not work.
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #12 on: 07. December 2009, 04:55:40 pm »

I see. Gonna check that later.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #13 on: 11. December 2009, 04:50:34 pm »

I have fixed that.

Marvin
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #14 on: 13. December 2009, 02:22:34 am »

Oooo, we can use selection with FPIH.setMouseMovementSuspended( false ) now?
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic