我正在使用QCAR,JPCT-AE制作一些应用程序

时间:2012-10-05 15:54:57

标签: android qcar-sdk

您好我正在使用QCAR& JPCT-AE。有人可以看到我的源代码和建议我?如果可以,我会将源代码发送给您。我的电子邮件地址是lyhdra99@gmail.com。

请帮帮我^^


首先

  1. 我将modelViewMatrix(QCAR :: Matrix44F)从JNI发送到JAVA ex)JNIEXPORT jfloatArray JNICALL Java_jp_may_com_VirtualButtonsRenderer_getNowMatrix(JNIEnv * env,jobject obj)
  2. 使用此模型ViewMatrix,如下所示

  3. public class VirtualButtonsRenderer implements GLSurfaceView.Renderer {
    
    
        public VirtualButtonsRenderer(Activity act) {
            Config.maxAnimationSubSequences = 999;
            // TODO Auto-generated constructor stub
            this.act = act;
            _Object3D = Loader.loadMD2(act.getResources().openRawResource(R.raw.tris), 1.0f);
            _Object3D.setName("MyTarget");
        }
    
        public native float[] getNowMatrix();
    
        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    
            initRendering();
            QCAR.onSurfaceCreated();
            world = new World();
            world.setAmbientLight(20, 20, 20);
            TextureManager tm = TextureManager.getInstance();
            com.threed.jpct.Texture Cover = new com.threed.jpct.Texture(BitmapFactory.decodeStream(act.getResources().openRawResource(R.raw.skin)));
            tm.addTexture("Cover", Cover);          
            _Object3D.setTexture("Cover");
            world.addObject(_Object3D);
            world.buildAllObjects();
            sun = new Light(world);
            sun.setIntensity(250, 250, 250);        
            Camera cam = world.getCamera();
            cam.moveCamera(Camera.CAMERA_MOVEOUT, 100);
            cam.lookAt(_Object3D.getTransformedCenter());           
            SimpleVector sv = new SimpleVector();
            sv.set(_Object3D.getTransformedCenter());
            sv.x -= 300;
            sv.z -= 0;
            sun.setPosition(sv);
            MemoryHelper.compact(); 
    
        }
    
        public void onDrawFrame(GL10 gl) {
            if (!mIsActive)
                return;
            if (renderFrame()) {
                Matrix NowMatrix = new Matrix();
                NowMatrix.fillDump(getNowMatrix());
                world.getCamera().setBack(NowMatrix);
                world.renderScene(fb);          
                world.draw(fb);     
                fb.display();
                return;
            } else {
                mIsTouch = false;
            }
        }
    
    }
    

    在这里,我遇到了问题。我认为Object3D可以像使用modelViewMatrix在Marker上的Teapot(QCAR Sample Object)一样移动。但它不能。

    这是我的问题^^ ;;

1 个答案:

答案 0 :(得分:0)

我想帮助您使用自己的应用, 请将您的原生imagetarget.cpp代码发送给我,

之前我认为你已经看过这个页面,请参考一次

http://www.jpct.net/wiki/index.php/Integrating_JPCT-AE_with_Vuforia

其项目源代码 https://github.com/sidneibjunior/vuforia-jpct

从renderframe中获取modelViewMatrix并将其发送到java,就像这样

const QCAR :: TrackableResult * result = state.getTrackableResult(tIdx);

QCAR :: Matrix44F modelViewMatrix = QCAR :: Tool :: convertPose2GLMatrix(result-> getPose());

SampleUtils :: rotatePoseMatrix(90.0f,1.0f,0,0,& modelViewMatrix.data [0]);

//反转矩阵 QCAR :: Matrix44F inverseMV = SampleMath :: Matrix44FInverse(modelViewMatrix);

//转置倒置矩阵 QCAR :: Matrix44F invTranspMV = SampleMath :: Matrix44FTranspose(inverseMV);

将逆转置矩阵发送到java代码。它会工作正常...我希望:))