Animating a object

Started by tejas87, July 02, 2013, 01:39:25 PM

Previous topic - Next topic

tejas87

Hello, I have a 3d object in a wheel shape and I want to spin it on touch. How can I achieve this.

Wolf17

     Hi tejas! Well , It's simple. Have you followed this example? -
(http://www.jpct.net/wiki/index.php/Hello_World_for_Android)
   Notice this code in your "onDrawFrame(GL10 gl") section -
if (touchTurn != 0) {
            cube.rotateY(touchTurn);
            touchTurn = 0;
         }

         if (touchTurnUp != 0) {
            cube.rotateX(touchTurnUp);
            touchTurnUp = 0;
         }
  This rotates the  cube in Y and X axis . You can restrict rotation  Y (or X ) so it rotates in that axis only by removing that part of code . I hope this helps!


EgonOlsen

You just have to make sure that your rotation pivot is set in the center of the wheel. The pivot is created based on the object's geometry when calling build(), but can be adjusted afterwards if that is needed.