# Help rotating a sphere around it's axis

Basically, I would like to simulate a ball rolling down a track.  It goes down the track fine, but it doesn't rotate.  Does anyone have any code examples or something that simply rotates a sphere around it's own axis a little bit every frame?

Thank you!

nope

I can make the ball roll, but not along its own axis, only along x,y,z or along their combination like x,y or x,y,z

to do so

you can use this code in update

rotate along x axis

yourball.rotate(1.5ftpf,0,0);

along x,y axis

yourball.rotate(1.5f
tpf,1.5f*tpf,0);

*tpf to make rotate smooth and doesnt run faster,slower on different computers

let me know if you can find the own axis of your ball, I'm curious of it ^^

cheers

hope that code helps you ^^

Thanks, using the rotateUpTo method I can get the ball to rotate when it moves left to right along the z axis, but not just straight down the x axis.

e:  This works!  You need to set a float counter that you increment every time your frame updates (or however often you want to rotate).  I called mine rotate, then in your update method use the following:

```Quaternion q = sphere.getLocalRotation (); q.fromAngleAxis(FastMath.DEG_TO_RAD*(-rotation),new Vector3f(0,0,1)); sphere.setLocalRotation(q);```

And it works!

I have a new question, but since this is still the second topic in the board I figure I'll just post it here…

I have a linked list of "Platform"s, which contain among other things a velocity and a Box.  I loop through the list, applying a different texture based on the velocity.  The proper textures are printed each time, but when it displays the platforms they all have whatever texture was applied last.  Could anyone point out what I'm missing?  Here's the code:

```currentPlatform = firstPlatform;       while (currentPlatform != null) {                      currentPlatform.box.setModelBound (new BoundingBox ());          currentPlatform.box.updateModelBound ();          currentPlatform.box.setRenderState (ms);          currentPlatform.box.setRenderState (ls);          currentPlatform.box.setRenderState(buf);                    if (currentPlatform.velocity == .06)             textureLoc = normalTex;          else if (currentPlatform.velocity == .1)             textureLoc = fastTex;          else if (currentPlatform.velocity == .006)             textureLoc = slowTex;          System.out.println (textureLoc);          // Use the TextureManager to load a texture          Texture t = TextureManager.loadTexture(textureLoc,                Texture.MinificationFilter.BilinearNearestMipMap,                Texture.MagnificationFilter.Bilinear);          // Assign the texture to the TextureState          ts.setTexture(t);                    currentPlatform.box.setRenderState (ts);          currentPlatform.box.updateRenderState ();          rootNode.attachChild (currentPlatform.box);          currentPlatform = currentPlatform.nextPlatform;       }```

Thank you!

e: Nevermind!  Resetting TextureState ts everytime (with ts = display.getRenderer().createTextureState();) I moved to the next platform worked.