开发者

Marker based AR android application using Qualcomm SDK

开发者 https://www.devze.com 2023-03-30 09:14 出处:网络
I am developing an android application in which a specific video is played when the poster of a specific movie is shown infront of the camera in android.

I am developing an android application in which a specific video is played when the poster of a specific movie is shown infront of the camera in android. Earlier i was using AndAr project for this stuff and i did some changes in draw() function of customObject and got it working. But now my client wan开发者_如何学编程ts me to use Qualcomm sdk . I was playing with image targets application but couldnt find anything to get in my head.


Ok i got it working. The following is the solution to it which i got from this link

https://ar.qualcomm.at/arforums/showthread.php?t=32

The imagetargets.cpp which i had was already having the method renderFrame so i had to modify it a little

  JNIEXPORT void JNICALL
  Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv*       
  env, jobject obj)

{
//LOG("Java_com_qualcomm_QCARSamples_ImageTargets_GLRenderer_renderFrame");

// Clear color and depth buffer 
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Render video background:
QCAR::State state = QCAR::Renderer::getInstance().begin();

 #ifdef USE_OPENGL_ES_1_1
// Set GL11 flags:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glEnable(GL_TEXTURE_2D);
glDisable(GL_LIGHTING);

 #endif

glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);

// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++)
{
    // Get the trackable:
    const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx);
    QCAR::Matrix44F modelViewMatrix =
        QCAR::Tool::convertPose2GLMatrix(trackable->getPose());        

    // Choose the texture based on the target name:
    int textureIndex = (!strcmp(trackable->getName(), "stones")) ? 0 : 1;
    const Texture* const thisTexture = textures[textureIndex];

    jstring js = env->NewStringUTF(trackable->getName());
               jclass javaClass = env->GetObjectClass(obj);
               jmethodID method = env->GetMethodID(javaClass, "displayMessage", "(Ljava/lang/String;)V");
               env->CallObjectMethod(obj, method, js);

  }

glDisable(GL_DEPTH_TEST);

 #ifdef USE_OPENGL_ES_1_1        
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 #else
glDisableVertexAttribArray(vertexHandle);
glDisableVertexAttribArray(normalHandle);
glDisableVertexAttribArray(textureCoordHandle);
 #endif

QCAR::Renderer::getInstance().end();
}

and after doing changes in imageRenderer class i added following code in on resume :-

   ImageTargetsRenderer.mainActivityHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse("http://www.youtube.com/watch?v=DyDA2Abnssg"));
            startActivity(intent);
            ImageTargets.this.finish();
        }
    };
0

精彩评论

暂无评论...
验证码 换一张
取 消