Log in or register to post comments

Anumation Problem

February 15, 2013 - 4:27am #1

Hello everyone

Im trying to create a simple animation on the image target sample, so I added

float x = 0.0f;
float y = 0.0f;
bool moveRight = true;

under the

static float kObjectScale = 3.0f;

I then

in the "JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv *, jobject)" function (which i assume draws the scean)

i added

        if (moveRight == true) {
          x += 1.0f;
            if (x > 50.0f)
                moveRight = false;
         }
         else {
          x -= 1.0f;
            if (x < -50.0f)
                moveRight = true;
         }

then changed

glTranslatef(0.0f, 0.0f, kObjectScale);

to

glTranslatef(x, y, kObjectScale);

and changed

SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
                                         &modelViewMatrix.data[0]);

to

SampleUtils::translatePoseMatrix(x, y, kObjectScale,
                                         &modelViewMatrix.data[0]);

but nothing happens even if i just put

x = 50.0f

in renderFrame, the only time I get a result is when I change the value where the variable is created (ie float x = 30.0f)

please help

I tried to make this as clear as possible to make it easier to understand my problem.

Thanks In Advance :)

Anumation Problem

February 17, 2013 - 2:20am #7

Great.

Anumation Problem

February 16, 2013 - 10:08pm #6

Once again thanks for the reply I realise now that I was being stupid I place my loop in an if statement for another version of opengl so it never got reached. 

everything works fine now

Anumation Problem

February 16, 2013 - 10:07pm #5

Once again thanks for the reply I realise now that I was being stupid I place my loop in an if statement for another version of opengl so it never got reached. everything works fine now

Anumation Problem

February 15, 2013 - 8:19am #4

Hi, I have placed the animation code  just before the "for loop"; can you try the same ?

Anumation Problem

February 15, 2013 - 8:12am #3

thank u for the reply, yes I am doing the ndk-build and refreshing the project but it does not work mabey I'm placing it in the wrong place, 

my animation code is directly bellow the "glLoadMatrix(projectionMatrix.data)" where shud it be

Anumation Problem

February 15, 2013 - 5:47am #2

Hi, I just tried your code changes in the Image Targets sample and it works nicely (I can see the teapot oscillating on the target, moving left-to-right and back right-to-left).

Not sure what the problem could be in your case;

have you rebuilt with ndk-build and refreshed the project in Eclipse ?

 

 

 
Log in or register to post comments