Trouble running Lesson1

Hi. I just downloaded the jme-physics beta 2 and I have trouble running the test code. When I for example run Lesson1 I get the following error



java.lang.NoSuchMethodError: com.jme.scene.Line.setColorBuffer(Ljava/nio/FloatBuffer;)V
   at com.jmex.physics.PhysicsDebugger.<clinit>(PhysicsDebugger.java:147)
   at com.jmex.physics.geometry.PhysicsBox.<clinit>(PhysicsBox.java:24)
   at com.jmex.physics.impl.ode.OdePhysicsSpace.createBox(OdePhysicsSpace.java:834)
   at com.jmex.physics.PhysicsNode.createBox(PhysicsNode.java:260)
   at com.jmetest.physicstut.Lesson1.simpleInitGame(Lesson1.java:35)
   at com.jme.app.BaseSimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at com.jmetest.physicstut.Lesson1.main(Lesson1.java:69)



How do I get it to run?

You have to use the approriate jME version. Either use the snapshot provided as download with the beta 2, or check out the correct date from CVS.



Using a jME release is not supported by the betas.



If you want to use the current development version of jME (nightly build or CVS HEAD) you have to use the CVS version of jME Physics 2, too.

Great - now the lesson works  :slight_smile: However when I run my app (that worked before updating the jars and the lib) I get the following error:



java.lang.NullPointerException
   at com.jme.scene.Node.attachChild(Unknown Source)
   at ui.HudNode.<init>(HudNode.java:39)
   at GnuOfDoom.simpleInitGame(GnuOfDoom.java:64)
   at com.jme.app.BaseSimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at GnuOfDoom.main(GnuOfDoom.java:114)



If I comment out the line that creates the HudNode then I just get another exception:


java.lang.NullPointerException
   at com.jme.scene.Spatial.setLocalTranslation(Unknown Source)
   at render.Gnunode.update(Gnunode.java:20)
   at render.Gnunode.<init>(Gnunode.java:13)
   at render.Flocknode.<init>(Flocknode.java:20)
   at GnuOfDoom.initFlock(GnuOfDoom.java:102)
   at GnuOfDoom.simpleInitGame(GnuOfDoom.java:81)
   at com.jme.app.BaseSimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at GnuOfDoom.main(GnuOfDoom.java:114)


I was using .10 when it worked. Any suggestions?

Your UiNode and your Gnunode seem to call jME methods in an unexpected way (attachChild and setLocalTranslation).  More info on the spatial you try to attach and on the parameter you pass to setLocalTranslation would be needed to help you. Though these two methods did not change a lot from .10 till physics beta 2 . . .

okay - here's some code:



public class HudNode extends Node{
   public static JMEDesktop hudQuad;
   private AbsoluteMouse cursor;
   private DisplaySystem display;


   public HudNode (DisplaySystem disp, InputHandler handler){
      display=disp;
      hudQuad = new JMEDesktop("Hud", 200, display.getHeight(), false, handler);
      hudQuad.setLightCombineMode(LightState.OFF);
      this.attachChild(hudQuad);
      

      hudQuad.getJDesktop().setBackground( new Color( 1, 1, 1, 0.2f
      ) );

        hudQuad.setRenderQueueMode(Renderer.QUEUE_ORTHO);       

        hudQuad.setLocalTranslation(new Vector3f(display.getWidth()-100,display.getHeight()/2,0));

        this.setCullMode( Spatial.CULL_NEVER );
        hudQuad.setLightCombineMode(LightState.OFF);
        hudQuad.updateRenderState();
        createSwingStuff();
   }
   
   protected void createSwingStuff() {
        final JDesktopPane desktopPane = hudQuad.getJDesktop();
        desktopPane.removeAll();

        createCamFrame( desktopPane, "Kamera control", 0, 0 );
        createflokFrame( desktopPane, "Flok control", 0, 300 );

        desktopPane.repaint();
        desktopPane.revalidate();
    }
   
   private void createflokFrame(JDesktopPane desktopPane, String title, int x, int y) {
           final JInternalFrame internalFrame = new JInternalFrame( title );
           if ( title == null ) {
               internalFrame.putClientProperty( "JInternalFrame.isPalette",
   Boolean.TRUE );
           }
           internalFrame.setLocation( x, y );
           internalFrame.setResizable( false );
           internalFrame.setBackground(new Color( 0.8f, 0f, 0, 0.2f ));
          // internalFrame.setSize(200, 200);

           internalFrame.getContentPane().setLayout( new FlowLayout() );
           JButton knap=new JButton( "<html><b>Oversigt</b><html>" );
           JButton knap2=new JButton( "<html><b>GNU-CAM</b></html>" );
           knap.setSize(200,200);
           internalFrame.getContentPane().add(knap);
           internalFrame.getContentPane().add(knap2);
           internalFrame.setVisible( true );
           internalFrame.pack();

           desktopPane.add( internalFrame );
      
   }
   private void createCamFrame( final JDesktopPane
         desktopPane, final String title, int x, int y ) {
                 final JInternalFrame internalFrame = new JInternalFrame( title );
                 if ( title == null ) {
                     internalFrame.putClientProperty( "JInternalFrame.isPalette",
         Boolean.TRUE );
                 }
                 internalFrame.setLocation( x, y );
                 internalFrame.setResizable( false );
                 internalFrame.setBackground(new Color( 0.8f, 0f, 0, 0.2f ));
                // internalFrame.setSize(200, 200);

                 internalFrame.getContentPane().setLayout( new FlowLayout() );
                 JButton knap=new JButton( "<html><b>Oversigt</b><html>" );
                 JButton knap2=new JButton( "<html><b>GNU-CAM</b></html>" );
                 knap.setSize(200,200);
                 internalFrame.getContentPane().add(knap);
                 internalFrame.getContentPane().add(knap2);
                 internalFrame.setVisible( true );
                 internalFrame.pack();

                 desktopPane.add( internalFrame );
             }
}




public class Gnunode extends Node{
   public IBoid dyr;
   public Gnunode(IBoid gnu, Node grafik){
      dyr=gnu;
      update();
      this.attachChild(grafik);
   }
   
   public void update(){
      this.setLocalTranslation(dyr.getCenter());
      Vector3f v=dyr.getVelocity();
      Quaternion rot=new Quaternion(v.x, v.y, v.z, 0);
      this.setLocalRotation(rot);
   }
}

Your classes extend Node and call the supercontructor without parameters - this most probably causes your problems. Call the constructor with the String paremeter as stated in the javadoc to get the Nodes properly initialized.

That one's gotten me too…why does the empty constructor exist at all?  Why not just remove it?

It is used internally (quite alot).



Edit: it can be used safely in current cvs version btw, darkfrog. Thus I just changed the comment accordingly. (Going to commit it later as it's not that important now)

It is required for "blind" object instantiation done by classes such binary importer.

Good info, didn't know that. :slight_smile:

Thanks for the replies! After providing each super ctor with an appropriate String everything runs normal again.  :slight_smile: