www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: tejas87 on July 02, 2013, 01:39:25 PM

Title: Animating a object
Post by: tejas87 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.
Title: Re: Animating a object
Post by: Wolf17 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!

Title: Re: Animating a object
Post by: EgonOlsen 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.