I've started learning jME today (after watching that presentation on sun forums yesterday), but I'm getting screwed on the basics.
I decided to start by attempting to develop a basic Pong application. But I've got a serious problem with collisions that I have no idea how to treat.
Basically, my paddle moves with this (on the simpleUpdate):
if ( ( KBM.isValidCommand( "playerleft" ) )
&& ( ! playerPaddle.hasCollision( leftWall , true ) ) ){
playerPaddle.translatePoints( -0.1f , 0 , 0 );
playerPaddle.updateModelBound();
}
(Same for right, of course)
The thing is, when I start the game and hit one of the walls, the paddle stops pretty much as it should, and there's absolutely nothing wrong with it. But if I go to the other wall, the paddle will blatantly ignore it and go ahead. If I come back to the first wall, it will collide and stop normally. This happens with both walls, depending on which one I hit first.
I don't believe the screenshot will help, but I won't discard that possibility:

I'm guessing it's something on hasCollision. Is there another way of doing this collision test?
Edit:
Here's my source, if it helps in anything:
public final class HelloWorld extends SimpleGame {
private HelloWorld() {}
public static void main ( String[] args ) {
HelloWorld game = new HelloWorld( );
game.setConfigShowMode( ConfigShowMode.AlwaysShow );
game.start();
}
final KeyBindingManager KBM = KeyBindingManager.getKeyBindingManager();
Box playerPaddle , rightWall , leftWall ;
@Override protected void simpleInitGame() {
final Vector3f CENTER = new Vector3f();
final Node GAME = new Node( "gamenode" );
MaterialState wallColor = display.getRenderer().createMaterialState();
wallColor.setEmissive( new ColorRGBA( 0.5f , 0.5f , 0.5f , 1 ) );
MaterialState ballColor = display.getRenderer().createMaterialState();
ballColor.setEmissive( new ColorRGBA( 1 , 0 , 0 , 1 ) );
MaterialState paddleColor = display.getRenderer().createMaterialState();
paddleColor.setEmissive( new ColorRGBA( 0.3f , 0.3f , 0.3f , 1 ) );
Box playerWall = new Box( "playerwall" , CENTER , 20 , 0.5f , 1 );
playerWall.setModelBound( new BoundingBox() );
playerWall.updateModelBound();
playerWall.setRenderState( wallColor );
playerWall.setLocalTranslation( 0 , -10 , -33 );
Box enemyWall = new Box( "enemywall" , CENTER , 20 , 0.5f , 1 );
enemyWall.setModelBound( new BoundingBox() );
enemyWall.updateModelBound();
enemyWall.setRenderState( wallColor );
enemyWall.setLocalTranslation( 0 , -10 , +33 );
leftWall = new Box( "leftwall" , CENTER , 1 , 0.5f , 34 );
leftWall.setModelBound( new BoundingBox() );
leftWall.updateModelBound();
leftWall.setRenderState( wallColor );
leftWall.setLocalTranslation( -21 , -10 , 0 );
rightWall = new Box( "rightwall" , CENTER , 1 , 0.5f , 34 );
rightWall.setModelBound( new BoundingBox() );
rightWall.updateModelBound();
rightWall.setRenderState( wallColor );
rightWall.setLocalTranslation( +21 , -10 , 0 );
Box ball = new Box( "ball" , CENTER , 1 , 0.5f , 1 );
ball.setModelBound( new BoundingBox() );
ball.updateModelBound();
ball.setRenderState( ballColor );
ball.setLocalTranslation( 0 , -10 , 0 );
playerPaddle = new Box( "playerpaddle" , CENTER , 3 , 0.5f , 0.5f );
playerPaddle.setModelBound( new BoundingBox() );
playerPaddle.updateModelBound();
playerPaddle.setRenderState( paddleColor );
playerPaddle.setLocalTranslation( 0 , -10 , +30 );
Box enemyPaddle = new Box( "enemyPaddle" , CENTER , 3 , 0.5f , 0.5f );
enemyPaddle.setModelBound( new BoundingBox() );
enemyPaddle.updateModelBound();
enemyPaddle.setRenderState( paddleColor );
enemyPaddle.setLocalTranslation( 0 , -10 , -30 );
PointLight light = new PointLight( );
light.setLocation( new Vector3f( 20 , -3 , 15 ) );
light.setDiffuse( new ColorRGBA( 0.3f , 0.3f , 0.3f , 1 ) );
light.setEnabled( true );
lightState.detachAll();
LightState ls = display.getRenderer().createLightState();
ls.attach( light );
GAME.setRenderState( ls );
GAME.attachChild( playerWall );
GAME.attachChild( enemyWall );
GAME.attachChild( leftWall );
GAME.attachChild( rightWall );
GAME.attachChild( playerPaddle );
GAME.attachChild( enemyPaddle );
GAME.attachChild( ball );
GAME.setLocalScale( 0.5f );
rootNode.attachChild( GAME );
KBM.add( "playerleft" , KeyInput.KEY_LEFT );
KBM.add( "playerright" , KeyInput.KEY_RIGHT );
}
@Override protected void simpleUpdate ( ) {
super.simpleUpdate();
if ( ( KBM.isValidCommand( "playerleft" ) )
&& ( ! playerPaddle.hasCollision( leftWall , true ) ) ){
playerPaddle.translatePoints( -0.1f , 0 , 0 );
playerPaddle.updateModelBound();
}
if ( ( KBM.isValidCommand( "playerright" ) )
&& ( ! playerPaddle.hasCollision( rightWall , true ) ) ) {
playerPaddle.translatePoints( +0.1f , 0 , 0 );
playerPaddle.updateModelBound();
}
}
}