Author Topic: Animating a object  (Read 1846 times)

Offline tejas87

  • byte
  • *
  • Posts: 1
    • View Profile
Animating a object
« on: July 02, 2013, 01:39:25 pm »
Hello, I have a 3d object in a wheel shape and I want to spin it on touch. How can I achieve this.

Offline Wolf17

  • int
  • **
  • Posts: 77
    • View Profile
Re: Animating a object
« Reply #1 on: July 02, 2013, 04:55:46 pm »
     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!


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Animating a object
« Reply #2 on: July 03, 2013, 07:15:11 am »
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.