Log in or register to post comments

Add touch event on specific augmented object on camera

January 2, 2015 - 2:59am #1

Hello guys, I'm working on such a application which augment image when camera detect target image using vuforia SDK in native android code. 

Here is a issue that I'm facing.

I want to move my image on touch. I have implemented touch event on surfaceview on which my image is augmented. So now wherever I move my finger on screen my image moves. But I want to implement touch event only for my image so when I touch or move my finger on rest of screen it should not make any effect on image.

 

Here is my code for augmenting image :::

 

 float[] modelviewmatrix = vuforiamatrix.getData();
        
   Matrix.translateM(modelviewmatrix, 0, 0.0f+mXdistance, 16.5f+mYdistance,
           17.0f);
   
Matrix.rotateM(modelviewmatrix, 0, 180.0f, 0.0f, 1.0f, 0.0f);
     
 
     
Matrix.scaleM(modelviewmatrix, 0,420+mDistance,
                    420+mDistance, 420+mDistance);   
                   
Matrix.multiplyMM(modelviewprojectionmatrix_image, 0, vuforiaAppSession
                    .getProjectionMatrix().getData(), 0, modelviewmatrix, 0);  
     
GLES20.glUseProgram(shaderProgramID_image);
GLES20.glVertexAttribPointer(vertexHandle_image, 3, GLES20.GL_FLOAT, false, 0, 
             imageloader.getvertexbuffer());
GLES20.glVertexAttribPointer(normalHandle_image, 3, GLES20.GL_FLOAT, false, 0,
    imageloader.getnormalbuffer());
GLES20.glVertexAttribPointer(textureCoordHandle_image, 2,
           GLES20.GL_FLOAT, false, 0, imageloader.gettexbuffer());
   
GLES20.glEnableVertexAttribArray(vertexHandle_image);
GLES20.glEnableVertexAttribArray(normalHandle_image);    
GLES20.glEnableVertexAttribArray(textureCoordHandle_image);
 
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);    
  
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,
texturehandler_image);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,
texturehandler_image);
 
   GLES20.glUniform1i(texSampler2DHandle_image, 0);
   
GLES20.glUniformMatrix4fv(mvpMatrixHandle_image, 1, false,
           modelviewprojectionmatrix_image, 0);
     
   GLES20.glDrawElements(GLES20.GL_TRIANGLES,
            6, GLES20.GL_UNSIGNED_SHORT,
            imageloader.getindicesbuffer());
       
   GLES20.glDisableVertexAttribArray(vertexHandle_image);
     GLES20.glDisableVertexAttribArray(normalHandle_image);
     GLES20.glDisableVertexAttribArray(textureCoordHandle_image);

Add touch event on specific augmented object on camera

March 25, 2015 - 3:23am #4

mX  distance and mYdistsance are values of distance in x direction and y direction when I move my finger. I get those values from ontouch event. 

Add touch event on specific augmented object on camera

March 25, 2015 - 1:13am #3

mXdistance and mYdistance is equals=""?

Add touch event on specific augmented object on camera

January 7, 2015 - 1:01pm #2
Log in or register to post comments