Problem with DebuggameState

What is the code to split this example in two different class?

http://wiki.jmephysics.irrisor.net/tiki-index.php?page=PhysicsGameState

Why this code don't work?





package tutorial.com.jmetest.physicstut;

import java.util.logging.Level;

import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;

import com.jmex.game.StandardGame;
import com.jmex.game.state.DebugGameState;
import com.jmex.game.state.GameStateManager;
import com.jmex.physics.DynamicPhysicsNode;
import com.jmex.physics.StaticPhysicsNode;
import com.jmex.physics.util.states.PhysicsGameState;

/**
 * <p>
 * This class uses PhysicsGameState to show the most simple physics with graphical representation: A
 * dynamic box falling onto a static floor (also a box).
 * </p>
 *
 * <p>
 * This demonstration has been mostly copied from Lesson2.java and modified to use PhysicsGameState
 * instead of extending SimplePhysicsGame.
 * </p>
 *
 * @author Irrisor
 * @author Sam Couter
 */
public class PhysicsGameStateTutorial
{
   /**
    * The main method to allow starting this class as application.
    *
    * @param args command line arguments
    */
   public static void main(String [] args)
   {
   //   LoggingSystem.getLogger().setLevel(Level.WARNING); // to see the important stuff

      // Create and start the OpenGL thread.
      final StandardGame game = new StandardGame("Physics tutorial");
      game.start();

      final DebugGameState debugGameState = new CopyOfLesson3();


      

      
      GameStateManager.getInstance().attachChild(debugGameState);
      debugGameState.setActive(true);

   
      debugGameState.getRootNode().updateRenderState();
       System.out.println("ciao1");
       debugGameState.setActive(true);
   }
}



and this is the code of class copyoflesson3:


public class CopyOfLesson3 extends DebugGameState {
   
   final PhysicsGameState physicsGameState = new PhysicsGameState("Physics tutorialrer");
    protected void Update(float d){
        System.out.println("ciao");  
        
      }
    public void CopyOfLessone3(){
        System.out.println("ciao");
       simpleInitGame();
    }
  
   protected void simpleInitGame() {
     System.out.println("ciao");
        // first we will create the floor like in Lesson2
       
       StaticPhysicsNode staticNode = physicsGameState.getPhysicsSpace().createStaticNode();

       this.getRootNode().attachChild( staticNode );
        final Box visualFloorBox = new Box( "floor", new Vector3f(), 5, 0.25f, 5 );
        staticNode.attachChild( visualFloorBox );
        // this time we tilt it a bit
        visualFloorBox.getLocalRotation().fromAngleNormalAxis( 0.3f, new Vector3f( 0, 0, -1 ) );
        // and create another part below
        final Box visualFloorBox2 = new Box( "floor", new Vector3f(), 5, 0.25f, 5 );
        staticNode.attachChild( visualFloorBox2 );
        visualFloorBox2.getLocalTranslation().set( 9.7f, -1.5f, 0 );
        staticNode.generatePhysicsGeometry();

        // second we create a box - as we create multiple boxes this time the code moved into a separate method
        DynamicPhysicsNode dynamicNode = createBox();
        // the first box gets in the center above the floor
        dynamicNode.getLocalTranslation().set( 0, 5, 0 );
        // this box keeps the default material

        // ok first we will explore some predefined materials
        // lets create an ice block...
        final DynamicPhysicsNode iceQube = createBox();
        iceQube.setMaterial( Material.ICE );
        // changing material means changing desity
        // you may choose to compute the mass from the volume and density of an object
        iceQube.computeMass();
        // color the visual representation in transparent blue
        color( iceQube, new ColorRGBA( 0.5f, 0.5f, 0.9f, 0.6f ) );
        // move the iceQube besides the first box
        iceQube.getLocalTranslation().set( 0, 5, 1.5f );

        // ... a rubber ...
        final DynamicPhysicsNode rubber = createBox();
        rubber.setMaterial( Material.RUBBER );
        rubber.computeMass();
        // color the visual representation in yellow
        color( rubber, new ColorRGBA( 0.9f, 0.9f, 0.3f, 1 ) );
        // move the rubber on the other side of the first box
        rubber.getLocalTranslation().set( 0, 5, -1.5f );

        // finally we define a custom material
        final Material customMaterial = new Material( "supra-stopper" );
        // we make it really light
        customMaterial.setDensity( 0.05f );
        // a material should define contact detail pairs for each other material it could collide with in the scene
        // do that just for the floor material - the DEFAULT material
        MutableContactInfo contactDetails = new MutableContactInfo();
        // our material should not bounce on DEFAULT
        contactDetails.setBounce( 0 );
        // and should never slide on DEFAULT
        contactDetails.setMu( 1000 ); // todo: Float.POSITIVE_INFINITY seems to cause issues on Linux (only o_O)
        // now set that behaviour
        customMaterial.putContactHandlingDetails( Material.DEFAULT, contactDetails );

        // ... finally test our supra-stopper with a red cube
        final DynamicPhysicsNode stopper = createBox();
        stopper.setMaterial( customMaterial );
        // don't forget to compute mass from density
        stopper.computeMass();
        // color the visual representation in yellow
        color( stopper, new ColorRGBA( 1, 0, 0, 1 ) );
        // move the stopper to the front
        stopper.getLocalTranslation().set( 0, 5, 3 );

        // start paused - press P to start the action :)
        pause = true;
    }

    /**
     * Little helper method to color a spatial.
     *
     * @param spatial the spatial to be colored
     * @param color   desired color
     */
    private void color( Spatial spatial, ColorRGBA color ) {
        final MaterialState materialState = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
        materialState.setDiffuse( color );
        if ( color.a < 1 ) {
            final AlphaState alphaState = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
            alphaState.setEnabled( true );
            alphaState.setBlendEnabled( true );
            alphaState.setSrcFunction( AlphaState.SB_SRC_ALPHA );
            alphaState.setDstFunction( AlphaState.DB_ONE_MINUS_SRC_ALPHA );
            spatial.setRenderState( alphaState );
            spatial.setRenderQueueMode( Renderer.QUEUE_TRANSPARENT );
        }
        spatial.setRenderState( materialState );
    }

    /**
     * Create a box like known from Lesson2.
     *
     * @return a physics node containing a box
     */
    private DynamicPhysicsNode createBox() {
        DynamicPhysicsNode dynamicNode = physicsGameState.getPhysicsSpace().createDynamicNode();
        rootNode.attachChild( dynamicNode );
        final Box visualFallingBox = new Box( "falling box", new Vector3f(), 0.5f, 0.5f, 0.5f );
        dynamicNode.attachChild( visualFallingBox );
        dynamicNode.generatePhysicsGeometry();
        return dynamicNode;
    }


}

                In my observation, i dunno where codes are being bug.





_________________

Manitowoc Ice Machine

it would help just a little if you would tell us what exactly doesn't work.