"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Animating texture

 

Hi,

i am showing  animation by translating the overlayed texture image. 

 

animateBowl(modelViewMatrix);

 

ShaderUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,

&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.0f, 0.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?

 

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

You could try doing this when the state changes: