InputEvent

Hi, I’ve tried to generate a Sphere if someone press a key.





   protected void simpleInitGame() {



 input.addAction(new Test(), “test”, KeyInput.KEY_C, true);

   }





   class Test extends KeyInputAction {



       public void performAction(InputActionEvent evt) {



           Sphere bullet = new Sphere(“sphere”, 8, 80, 1.25f);

       

           rootNode.attachChild(bullet);      

       }



But when I start the programm and press the key, the sphere looks like this:







Can someone help me? thx

Coool…it works…thhxx :smiley:

Wow, nice effect… :3



For me it seems like there is a texture on the sphere. This texture doesnt fit your sphere. Interpolate it to make it fit, i think. ( I'm not sure if this was the way to make textures fitting round objects, but I have something like this in my mind…)



This texture could be inherited from some other objects in your scene… Check it out?

Firstly, I think you might want the last argument of addAction to be false, otherwise the action is repeated while you hold down the key.

After adding something to the scene, you might want to do an updateRenderState() on the root node as well.

I think I've seen this effect before in a post here on the forums, but not sure where or what the problem was.

Try updateRenderState and see if that helps, it often does.

every object that gets added to the scene needs to update its renderstates, because kids of the scenegraph inherit its parents renderstates.

Without the update, the result is pretty much undefined.

Also you should always create a Boundingvolume if you create a box/sphere or similar.



Without the Boundingvolume, culling wont work correctly.