Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - teal03

#1
Thank you i just initiallize the modelViewMat like this..    

private float[] modelViewMat ={0.0f,0.0f,0.0f,0.0f               
                                            ,0.0f,0.0f,0.0f,0.0f                
                                            ,0.0f,0.0f,0.0f,0.0f                  
                                            ,0.0f,0.0f,0.0f,0.0f};
so it's working!
That's very basic problem. Thanks agian.
#2
Hello, I want to see my obj is rendered on Marker in real Camera background. I followed your sample code but it's not working.
Native code is working but in java code not working when i attach updateCamera() in onDrawFrame.
How can i do that??

my ImageTargetsRenderer.java code

private float[] modelViewMat=null;  // create the Value of modelViewMat : is it right?

public ImageTargetsRenderer(ImageTargets activity) {
    this.mActivity = activity;
    world = new World();
    world.setAmbientLight(20, 20, 20);
   
    sun = new Light(world);
    sun.setIntensity(250, 250, 250);
   
    Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity.getResources().getDrawable(R.drawable.markman)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);

    obj = Object3D.mergeAll(Loader.loadOBJ(mActivity.getResources().openRawResource(R.raw.mark_obj), mActivity.getResources().openRawResource(R.raw.mark_mtl), 25));

    obj.setTexture("texture");
    obj.strip();
    obj.build();

    world.addObject(obj);
   
    SimpleVector sv = new SimpleVector();
    sv.set(obj.getTransformedCenter());
    sv.y -= 100;
    sv.z -= 100;
    sun.setPosition(sv);
    MemoryHelper.compact();

    }
   
    public void updateModelviewMatrix(float mat[]) {
        modelViewMat = mat;
    }


    /** Called when the surface is created or recreated. */
    public void onSurfaceCreated(GL10 gl, EGLConfig config)
    {
        DebugLog.LOGD("GLRenderer::onSurfaceCreated");

        // Call native function to initialize rendering:
        initRendering();

        // Call QCAR function to (re)initialize rendering after first use
        // or after OpenGL ES context was lost (e.g. after onPause/onResume):
        QCAR.onSurfaceCreated();
    }


    /** Called when the surface changed size. */
    public void onSurfaceChanged(GL10 gl, int width, int height)
    {
        DebugLog.LOGD("GLRenderer::onSurfaceChanged");
       
        if (fb != null) {
            fb.dispose();
       }
       fb = new FrameBuffer(width, height);
       
        updateRendering(width, height);
        QCAR.onSurfaceChanged(width, height);
    }

    /** The native render function. */
    public native void renderFrame();
       
    public void updateCamera() {
   
    cam = world.getCamera();
   
    Matrix m = new Matrix();
    m.setDump(modelViewMat);
            cam.setBack(m);
    }
   
     /** Called to draw the current frame. */
    public void onDrawFrame(GL10 gl)
    {
        if (!mIsActive)
            return;     
        mActivity.updateRenderView();
        renderFrame();
        updateCamera();
       
world.renderScene(fb);
world.draw(fb);
fb.display();
    }


this is JNI C++ renderframe code.

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

jclass activityClass = env->GetObjectClass(obj); //We get the class of out activity

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

    // Get the state from QCAR and mark the beginning of a rendering section
    QCAR::State state = QCAR::Renderer::getInstance().begin();
   
    // Explicitly render the Video Background
    QCAR::Renderer::getInstance().drawVideoBackground();

    jmethodID updateMatrixMethod = env->GetMethodID(activityClass, "updateModelviewMatrix", "([F)V");

    jfloatArray modelviewArray = env->NewFloatArray(16);

    for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
    {
    // Get the trackable:
    const QCAR::TrackableResult* result = state.getTrackableResult(tIdx);
    const QCAR::Trackable& trackable = result->getTrackable();
    QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());

        SampleUtils::rotatePoseMatrix(180.0f, 1.0f, 0, 0, &modelViewMatrix.data[0]);
        // Passes the model view matrix to java
        env->SetFloatArrayRegion(modelviewArray, 0, 16, modelViewMatrix.data);
        env->CallVoidMethod(obj, updateMatrixMethod , modelviewArray);
    }
    env->DeleteLocalRef(modelviewArray);


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


error message

08-28 16:00:01.254: W/dalvikvm(4729): threadid=14: thread exiting with uncaught exception (group=0x411852a0)
08-28 16:00:01.254: E/AndroidRuntime(4729): FATAL EXCEPTION: GLThread 11388
08-28 16:00:01.254: E/AndroidRuntime(4729): java.lang.NullPointerException
08-28 16:00:01.254: E/AndroidRuntime(4729): at com.threed.jpct.Matrix.setDump(Matrix.java:954)
08-28 16:00:01.254: E/AndroidRuntime(4729): at com.qualcomm.QCARSamples.ImageTargets.ImageTargetsRenderer.updateCamera(ImageTargetsRenderer.java:127)
08-28 16:00:01.254: E/AndroidRuntime(4729): at com.qualcomm.QCARSamples.ImageTargets.ImageTargetsRenderer.onDrawFrame(ImageTargetsRenderer.java:138)
08-28 16:00:01.254: E/AndroidRuntime(4729): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
08-28 16:00:01.254: E/AndroidRuntime(4729): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
08-28 16:00:01.274: D/QCAR(4729): ImageTargets::onPause
08-28 16:00:01.279: W/SurfaceView(4729): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false
08-28 16:00:01.279: I/QCAR(4729): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_stopCamera
08-28 16:00:01.484: D/gralloc(4729): unmmap  pid(1857), vaddr(0x5614a000)
08-28 16:00:01.484: E/gralloc(4729): [GR_MD] unmapping from 0x54331000, size=33427456
08-28 16:00:01.484: D/gralloc(4729): unmmap  pid(1857), vaddr(0x5a2cd000)
08-28 16:00:01.484: E/gralloc(4729): [GR_MD] unmapping from 0x583ce000, size=33427456
08-28 16:00:01.489: D/gralloc(4729): unmmap  pid(1857), vaddr(0x5a46a000)
08-28 16:00:01.489: E/gralloc(4729): [GR_MD] unmapping from 0x5a46a000, size=33427456
08-28 16:00:01.494: D/gralloc(4729): unmmap  pid(1857), vaddr(0x5c533000)
08-28 16:00:01.494: E/gralloc(4729): [GR_MD] unmapping from 0x5c4c0000, size=33427456
08-28 16:00:01.494: D/gralloc(4729): unmmap  pid(1857), vaddr(0x5e5a3000)
08-28 16:00:01.494: E/gralloc(4729): [GR_MD] unmapping from 0x5e4bd000, size=33427456
08-28 16:00:01.499: D/gralloc(4729): unmmap  pid(1857), vaddr(0x605f7000)
08-28 16:00:01.499: E/gralloc(4729): [GR_MD] unmapping from 0x6049e000, size=33427456
08-28 16:00:01.499: D/gralloc(4729): unmmap  pid(1857), vaddr(0x6264b000)
08-28 16:00:01.499: E/gralloc(4729): [GR_MD] unmapping from 0x6247f000, size=33427456
08-28 16:00:01.504: D/dalvikvm(4729): WAIT_FOR_CONCURRENT_GC blocked 0ms
08-28 16:00:01.544: D/dalvikvm(4729): GC_EXPLICIT freed 505K, 66% free 12405K/35911K, paused 4ms+4ms, total 39ms
#3
Support / Re: Inquiry of JPCT + QCAR
August 27, 2013, 09:07:34 AM
oh!!!!!! great!! I solved my problem
thank you your comments!!!
I just chage like this.
your comments is very helpful for me. i could get hint in your advice..


mRenderer = new ImageTargetsRenderer();     --->      mRenderer = new ImageTargetsRenderer(this);


thank you again.
#4
Support / Re: Inquiry of JPCT + QCAR
August 27, 2013, 08:38:24 AM
thank you. you said something is null?? so I found some different part. in lecture handles just ImageTargetsRenderer.java.
But I have error in ImageTargets.java when i first wrote your sample code.(not in ImageTargetsRenderer.java)

that part is here and i changed and then error was removed so i could build. but still i can't apply texture  :-\
mRenderer = new ImageTargetsRenderer();     --->      mRenderer = new ImageTargetsRenderer(null);


In here, is there something wrong?
#5
Support / Inquiry of JPCT + QCAR
August 26, 2013, 12:01:10 PM
hello~ i'm student of android development.  I have some problem when i integrated the JPCT and QCAR.
I refer your expaination in wiki which name is  Integrating JPCT-AE with Vuforia.
so i followed your sample code. but some problem occur in part of texture.
If i remove this code (texture part)


Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity.getResources().getDrawable(R.drawable.markman)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);


the program is worked without texture.
However, if I insert texture code the program isn't worked!!
I don't know how can i solve this problem. please help me :)
I attach the logcat and my code
thank you for your attention.

error below

08-26 18:59:17.099: D/dalvikvm(6180): GC_FOR_ALLOC freed 72K, 13% free 9596K/10951K, paused 15ms, total 16ms
08-26 18:59:17.099: I/dalvikvm-heap(6180): Grow heap (frag case) to 11.319MB for 775696-byte allocation
08-26 18:59:17.129: D/dalvikvm(6180): GC_CONCURRENT freed 1K, 12% free 10352K/11719K, paused 11ms+1ms, total 31ms
08-26 18:59:19.344: E/SpannableStringBuilder(6180): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
08-26 18:59:19.344: E/SpannableStringBuilder(6180): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
08-26 18:59:21.684: D/dalvikvm(6180): Trying to load lib /data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libQCAR.so 0x41bea720
08-26 18:59:21.689: D/dalvikvm(6180): Added shared lib /data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libQCAR.so 0x41bea720
08-26 18:59:21.694: I/QCAR(6180): Native library libQCAR.so loaded
08-26 18:59:21.699: D/dalvikvm(6180): Trying to load lib /data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libImageTargets.so 0x41bea720
08-26 18:59:21.699: D/dalvikvm(6180): Added shared lib /data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libImageTargets.so 0x41bea720
08-26 18:59:21.699: D/dalvikvm(6180): No JNI_OnLoad found in /data/data/com.qualcomm.QCARSamples.ImageTargets/lib/libImageTargets.so 0x41bea720, skipping init
08-26 18:59:21.699: I/QCAR(6180): Native library libImageTargets.so loaded
08-26 18:59:21.699: D/QCAR(6180): ImageTargets::onCreate
08-26 18:59:21.714: D/dalvikvm(6180): GC_FOR_ALLOC freed 57K, 12% free 10540K/11847K, paused 14ms, total 14ms
08-26 18:59:21.744: D/dalvikvm(6180): GC_FOR_ALLOC freed 17K, 12% free 10779K/12167K, paused 16ms, total 16ms
08-26 18:59:21.759: D/dalvikvm(6180): GC_FOR_ALLOC freed 0K, 12% free 11035K/12487K, paused 11ms, total 11ms
08-26 18:59:21.784: D/dalvikvm(6180): GC_FOR_ALLOC freed 520K, 16% free 10795K/12807K, paused 11ms, total 11ms
08-26 18:59:21.804: D/dalvikvm(6180): GC_FOR_ALLOC freed 16K, 14% free 11035K/12807K, paused 11ms, total 11ms
08-26 18:59:21.819: D/dalvikvm(6180): GC_FOR_ALLOC freed 0K, 12% free 11291K/12807K, paused 12ms, total 12ms
08-26 18:59:21.844: D/dalvikvm(6180): GC_FOR_ALLOC freed 520K, 16% free 11052K/13127K, paused 11ms, total 12ms
08-26 18:59:21.879: D/dalvikvm(6180): GC_CONCURRENT freed 16K, 13% free 11548K/13127K, paused 12ms+2ms, total 24ms
08-26 18:59:21.879: D/dalvikvm(6180): WAIT_FOR_CONCURRENT_GC blocked 1ms
08-26 18:59:21.894: I/QCAR(6180): Activity is in PORTRAIT
08-26 18:59:21.899: D/QCAR(6180): ImageTargets::onResume
08-26 18:59:21.904: I/AR(6180): QCAR has been initialized successfully
08-26 18:59:21.904: I/AR(6180): QCAR SDK version 2.0.31
08-26 18:59:22.004: E/SpannableStringBuilder(6180): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
08-26 18:59:22.004: E/SpannableStringBuilder(6180): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
08-26 18:59:22.014: D/QCAR(6180): InitQCARTask::onPostExecute: QCAR initialization successful
08-26 18:59:22.019: I/QCAR(6180): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initTracker
08-26 18:59:22.029: I/QCAR(6180): Successfully initialized ImageTracker.
08-26 18:59:22.029: I/QCAR(6180): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initApplicationNative
08-26 18:59:22.029: I/QCAR(6180): Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_initApplicationNative finished
08-26 18:59:22.034: I/QCAR(6180): Using OpenGL ES 2.0
08-26 18:59:22.034: I/QCAR(6180): Using opaque GLView, depth buffer size: 16, stencil size: 0
08-26 18:59:22.039: I/jPCT-AE(6180): Adding Lightsource: 0
08-26 18:59:22.039: D/AndroidRuntime(6180): Shutting down VM
08-26 18:59:22.039: W/dalvikvm(6180): threadid=1: thread exiting with uncaught exception (group=0x411852a0)
08-26 18:59:22.044: E/AndroidRuntime(6180): FATAL EXCEPTION: main
08-26 18:59:22.044: E/AndroidRuntime(6180): java.lang.NullPointerException
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.qualcomm.QCARSamples.ImageTargets.ImageTargetsRenderer.<init>(ImageTargetsRenderer.java:64)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets.initApplicationAR(ImageTargets.java:806)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets.updateApplicationStatus(ImageTargets.java:648)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets.updateApplicationStatus(ImageTargets.java:640)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets.access$3(ImageTargets.java:597)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets$InitQCARTask.onPostExecute(ImageTargets.java:225)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.qualcomm.QCARSamples.ImageTargets.ImageTargets$InitQCARTask.onPostExecute(ImageTargets.java:1)
08-26 18:59:22.044: E/AndroidRuntime(6180): at android.os.AsyncTask.finish(AsyncTask.java:631)
08-26 18:59:22.044: E/AndroidRuntime(6180): at android.os.AsyncTask.access$600(AsyncTask.java:177)
08-26 18:59:22.044: E/AndroidRuntime(6180): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
08-26 18:59:22.044: E/AndroidRuntime(6180): at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 18:59:22.044: E/AndroidRuntime(6180): at android.os.Looper.loop(Looper.java:137)
08-26 18:59:22.044: E/AndroidRuntime(6180): at android.app.ActivityThread.main(ActivityThread.java:4921)
08-26 18:59:22.044: E/AndroidRuntime(6180): at java.lang.reflect.Method.invokeNative(Native Method)
08-26 18:59:22.044: E/AndroidRuntime(6180): at java.lang.reflect.Method.invoke(Method.java:511)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
08-26 18:59:22.044: E/AndroidRuntime(6180): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
08-26 18:59:22.044: E/AndroidRuntime(6180): at dalvik.system.NativeStart.main(Native Method)




my code below


/** The renderer class for the ImageTargets sample. */
public class ImageTargetsRenderer implements GLSurfaceView.Renderer
{
    public boolean mIsActive = false;
   
    private FrameBuffer fb = null;
private World world = null;
private Light sun = null;
private Object3D obj = null;

    /** Reference to main activity **/
    public ImageTargets mActivity;

    /** Native function for initializing the renderer. */
    public native void initRendering();

    /** Native function to update the renderer. */
    public native void updateRendering(int width, int height);
   
   
    public ImageTargetsRenderer(ImageTargets activity) {
    this.mActivity = activity;
    world = new World();
    world.setAmbientLight(20, 20, 20);
   
    sun = new Light(world);
    sun.setIntensity(250, 250, 250);
   
    // Create a texture out of the icon...:-)
    Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(mActivity.getResources().getDrawable(R.drawable.markman)), 64,

64));
TextureManager.getInstance().addTexture("texture", texture);

    //obj = Object3D.mergeAll(Loader.loadOBJ(mActivitygetResources().openRawResource(R.raw.mark_obj), getResources().openRawResource

(R.raw.mark_mtl), 25));
   
    obj = Primitives.getCube(10);
    obj.calcTextureWrapSpherical();
   
    obj.setTexture("texture");
    obj.strip();
    obj.build();

    world.addObject(obj);

        Camera cam = world.getCamera();
        cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
        cam.lookAt(obj.getTransformedCenter());

    SimpleVector sv = new SimpleVector();
    sv.set(obj.getTransformedCenter());
    sv.y -= 100;
    sv.z -= 100;
    sun.setPosition(sv);
    MemoryHelper.compact();


    }


    /** Called when the surface is created or recreated. */
    public void onSurfaceCreated(GL10 gl, EGLConfig config)
    {
        DebugLog.LOGD("GLRenderer::onSurfaceCreated");

        // Call native function to initialize rendering:
        initRendering();

        // Call QCAR function to (re)initialize rendering after first use
        // or after OpenGL ES context was lost (e.g. after onPause/onResume):
        QCAR.onSurfaceCreated();
    }


    /** Called when the surface changed size. */
    public void onSurfaceChanged(GL10 gl, int width, int height)
    {
        DebugLog.LOGD("GLRenderer::onSurfaceChanged");
        updateRendering(width, height);
        QCAR.onSurfaceChanged(width, height);
       
        if (fb != null) {
            fb.dispose();
       }
       fb = new FrameBuffer(width, height);
    }


    /** The native render function. */
    public native void renderFrame();


    /** Called to draw the current frame. */
    public void onDrawFrame(GL10 gl)
    {
world.renderScene(fb);
world.draw(fb);
fb.display();

        if (!mIsActive)
            return;     
        mActivity.updateRenderView();
        renderFrame();
    }
    }