KeyInputController cause a Texture Problem

Hi everyone!

I've got a very strange bug :

In my Poker Game , I've got a method "createCard()" which create 2 quads (1 textured witch a recto, and 1 with a verso) attached to 1 node.

I also have methods to deal the card.

When i use these 2 methods in my simpleInitGame() method everythinks works perfectly :

protected void simpleInitGame() {
Node cardTest = createCard();

But when i use dealCard(cardTest) in with a keyInputController, the card have only one texture (the verso one)  :-o

protected void simpleInitGame() {
 input.addAction(new DealingCard(), "deal the card", KeyInput.KEY_L, false);

class DealingCardextends KeyInputAction{

      public void performAction(InputActionEvent evt) {

i try everything : to create the card in simpleInitGame, in the attribute declaration : i always have the same texture probleme, and i cant understand it!!!  :?

(I join a picture where you can see one card dealt in simpleInitGame and another one with the method with the KeyInputController!)

I really need help.

Thank you.

PS: i still have problem with my camera node, i you think you can help me, go to the "How to use camera node" topic!

I still have this problem! It become really problematic for my development!  :frowning:

Seriously, nobody have an idea?

I haven't used SimpleGame very much so I'm not quite sure how it works, but I think you would get a wider response if you showed the code in your createCard() and dealCard(Node n) methods.

class DealingCardextends KeyInputAction

I'm assuming this actually says

class DealingCard extends KeyInputAction

in your code. :)

Sounds like its possibly missing  node.updaterenderstate(); 

The code of createCard() :

private Node createCard()
         Quad cardRecto = new Quad("my card recto",WIDTH_CARD,LENGTH_CARD);

            URL myTextureRecto;
            myTextureRecto = TestState.class.getClassLoader().getResource("texturePoker/[CLOVER ACE].png");
            TextureState tsRecto = display.getRenderer().createTextureState();
            Texture tRecto = TextureManager.loadTexture(myTextureRecto, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
         Quad cardVerso = new Quad("my card verso",WIDTH_CARD,LENGTH_CARD);
            URL myTextureVerso;
            myTextureVerso = TestState.class.getClassLoader().getResource("texturePoker/verso.png");
            TextureState tsVerso = display.getRenderer().createTextureState();
            Texture tVerso = TextureManager.loadTexture(myTextureVerso, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
      //interval to divide recto and verso
      cardVerso.setLocalTranslation(new Vector3f(0,0,-0.001f));
      Node card = new Node("my card");
      card.setModelBound(new BoundingBox());
      return card;

and the code of dealCarde(Node card) (which is just the river for the test) :

   private void dealCard(Node card)
      Node pivot = new Node();
      Quaternion y180 = new Quaternion();
      y180.fromAngleAxis(FastMath.DEG_TO_RAD*180, new Vector3f(0,1,0));
      //to turn the card over
         SpatialTransformer st1=new SpatialTransformer(1);
         st1.setObject(pivot, 0, -1);
            st1.setPosition(0, 0, new Vector3f(0,0,0));
            Quaternion y0 = new Quaternion();
            y0.fromAngleAxis(0, new Vector3f(0,1,0));
            st1.setPosition(0, 1.5f, new Vector3f((X_RIVER/2),0,0));
            st1.setPosition(0, 2.5f, new Vector3f(X_RIVER,0,-(THICKNESS_DECK+0.001f)));
            st1.setPosition(0, 3, new Vector3f(X_RIVER,0,4));
            st1.setRotation(0, 3, y0);
            st1.setRotation(0, 4, y180);
            st1.setPosition(0, 4, new Vector3f(X_RIVER,0,-(THICKNESS_DECK+0.001f)));

JOC--> I try to write some card.updaterenderstate() and pivot.updaterenderstate(), it doesn't work. Where do i am suppose to write this?

I think cardVerso / cardRecto need the updateRenderstate() call - you manipulate their renderstate (cardRecto.setRenderState(…))


snareoj2 --> I add cardRecto.updateRenderState() under cardRecto.setRenderState(…) (and the same for cardVerso) but i still have the same bug.

It become really problematic because i must finish all the animation for January 4th!

Seriously, no one have an idea?

If you inputcontroller provider is AWT instead of LWJGL, it could be a threading problem. or it could generally be a threading problem.

my guess is you have to load all card textures anyway, so just create all cards in you simpleInit() method and store them in a Hashtable and then just access them when needed.

@dgdd : i use LWGL.

Finally, i found a solution, but it's strange :

if i want to have the correct texture, i have to do the declaration an the creation of the card in the init method :

Node cardTest = createCard();

if i do my declaration elsewhere than in the init method, i got the "only recto texture" bug.

But because i have to manipulate my card in other method, i create another Node before the init method :

Node cardBuff;

and i reference it in the init method :

 cardBuff=cardTest ;

after that i can manipulate my card in other method, like this:

   class Deal extends KeyInputAction{

      public void performAction(InputActionEvent evt) {


And it works! (But there are still some stuff i don't understand about this bug  :? , if someone find the solution, it could be interesting)

Thanks to all the people who try help me!  :)

the card switching with the good texture :