Log in or register to post comments

Animating texture

July 2, 2013 - 3:17am #1

 

Hi,

i am showing  animation by translating the overlayed texture image. 

 

animateBowl(modelViewMatrix);

 

ShaderUtils::translatePoseMatrix(0.0f0.0fkObjectScale,

&modelViewMatrix.data[0]);

 

ShaderUtils::scalePoseMatrix(targetSize.data[0], targetSize.data[1], 1.0f,

&modelViewMatrix.data[0]);

 

ShaderUtils::multiplyMatrix(&qUtils.projectionMatrix.data[0],

&modelViewMatrix.data[0] ,

&modelViewProjection.data[0]);

 

and the animatebowl function changes the translation pose based on time:

 

void

animateBowl(QCAR::Matrix44F& modelViewMatrix)

{

NSLog(@"animate");

static float translateCoord = 0.0f;

static float rotateBowlAngle = 0.0f;

 

static double prevTime = getCurrentTime();

double time = getCurrentTime();             // Get real time difference

float dt = (float)(time-prevTime);          // from frame to frame

NSLog(@"time %f",dt);

translateCoord += dt * 10.0f;     // Animate angle based on time

NSLog(@"traslate coord %f",translateCoord);

rotateBowlAngle += dt * 180.0f/3.1415f;     // Animate angle based on time

 

ShaderUtils::translatePoseMatrix(translateCoord, 0.0f0.0f,&modelViewMatrix.data[0]);

prevTime = time;

 

}

 

 

Now the issue is when the image target is detected, texture gets overlayed and starts animating. But now when i move my device somewhere else (then image target is not detected,rite) then again i move back my device over image target, the textture gets overlayed.

 

But now here the animation of overlayed texture starts from the position where it ended previously.

 

Wanted to know that from where do i have to reset the translation pose?

 

Animating texture

July 2, 2013 - 4:48am #2

Wanted to know that from where do i have to reset the translation pose?

You could try doing this when the state changes:

    state.getNumTrackableResults()

 

If you want to get really sophisticated then you could set up a notification mechanism as I discussed here:

https://developer.vuforia.com/forum/ios/trackableeventhandler-equivalent-ios

 

 

Log in or register to post comments