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.


Messages - Maro

Pages: [1]
1
Support / Re: Problem with integration of Jpct-ae and Vuforia
« on: April 24, 2013, 11:15:50 am »
Ok i found the solution, i post it in the case someone will read.

In the native function the array is initialize only if marker is currently track.
So in the java code i use an if to dected when the array is null, in that case i simply do nothing, waiting for another call of that function, when finally is not null i can execute the portion of code who gave me some problem

the code here:
Code: [Select]
    Matrix m = new Matrix();
    if(modelViewMat!=null)
    {
    m.setDump(modelViewMat);
    cam.setBack(m);
    }

2
Support / Re: Vuforia / jpct / load 3D Model
« on: April 24, 2013, 11:08:17 am »
Assuming you want to load on obj model you need to:
1 create an array of object3d
2 load that obj into an input stream
3 load the mtl in another input stream
4 inizialize array with the right function

an example of code here:
Code: [Select]
public Object3D[] model;
public AssetManager mngr;
public InputStream objStream = null;
public InputStream mtlStream = null;

//into your constructor
public yourconstructor()
{
.
.
.
mngr = instanceofactivity.getAssets();
try {
objStream = mngr.open("file.obj");
} catch (IOException e) {
e.printStackTrace();
}
try {
mtlStream = mngr.open("file.mtl");
} catch (IOException e) {
e.printStackTrace();
}
   
model = Loader.loadOBJ(objStream, mtlStream, x);
.
.
.
}
In this case i put my file into the assets folder.
Hope can be helpful!

3
Support / Re: Problem with integration of Jpct-ae and Vuforia
« on: April 23, 2013, 04:58:26 pm »
After some debug i discovered setDump() error is caused from modelViewMat, because it is null.
Now the new question is, why that array is not filled by the native function?

my code native function:
Code: [Select]
JNIEXPORT void JNICALL
Java_com_example_vuforiajpctae_ImageTargetsRenderer_renderFrame(JNIEnv *env, jobject obj)
{
jclass activityClass = env->GetObjectClass(obj); //We get the class of out activity
jmethodID updateMatrixMethod = env->GetMethodID(activityClass, "updateModelviewMatrix", "([F)V");
    // 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();
    // Did we find any trackables this frame?
    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]);
        env->SetFloatArrayRegion(modelviewArray, 0, 16, modelViewMatrix.data);
        env->CallVoidMethod(obj, updateMatrixMethod , modelviewArray);
    }
    env->DeleteLocalRef(modelviewArray);
    //QCAR::Renderer::getInstance().end();

}

THX

4
Support / Problem with integration of Jpct-ae and Vuforia
« on: April 23, 2013, 01:40:38 pm »
Hi, in these days i started to looking for a good sdk to combine with Vuforia.
I think this one is pretty good so i started to use, but i've encountered some problem.
Can someone help me?

I followed step by step this helpful guide: http://www.jpct.net/wiki/index.php/Integrating_JPCT-AE_with_Vuforia

But when I call the function updateCamera(), i have ever the same error:
This is my code:
Code: [Select]
  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.ic_launcher)), 64, 64));
    TextureManager.getInstance().addTexture("texture", texture);

    cube = Primitives.getCube(10);
    cube.calcTextureWrapSpherical();
    cube.setTexture("texture");
    cube.strip();
    cube.build();
    cube.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS|Object3D.COLLISION_CHECK_SELF);
cube.setCollisionOptimization(true);

    world.addObject(cube);

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

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

    }

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

    /** Native function to update the renderer. */
    public native void updateRendering(int width, int height);

    /** 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");

    // Call native function to update rendering when render surface
    // parameters have changed:
    updateRendering(width, height);

    // Call QCAR function to handle render surface size changes:
    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)
    {
        if (!mIsActive)
            return;
       
        // Update render view (projection matrix and viewport) if needed:
        mActivity.updateRenderView();

        // Call our native function to render content
        renderFrame();
       
        updateCamera();
       
        world.renderScene(fb);
        world.draw(fb);
        fb.display();
       
    }
   
    public void updateModelviewMatrix(float mat[]) {
        modelViewMat = mat;
    }
   
    public void updateCamera() {
    Matrix m = new Matrix();
    m.setDump(modelViewMat);
        cam.setBack(m);
    }

and this is my logcat:
Code: [Select]
04-23 13:24:50.255: E/AndroidRuntime(13001): FATAL EXCEPTION: GLThread 14
04-23 13:24:50.255: E/AndroidRuntime(13001): java.lang.NullPointerException
04-23 13:24:50.255: E/AndroidRuntime(13001): at com.threed.jpct.Matrix.setDump(Matrix.java:955)
04-23 13:24:50.255: E/AndroidRuntime(13001): at com.example.vuforiajpctae.ImageTargetsRenderer.updateCamera(ImageTargetsRenderer.java:160)
04-23 13:24:50.255: E/AndroidRuntime(13001): at com.example.vuforiajpctae.ImageTargetsRenderer.onDrawFrame(ImageTargetsRenderer.java:146)
04-23 13:24:50.255: E/AndroidRuntime(13001): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1388)
04-23 13:24:50.255: E/AndroidRuntime(13001): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138)

the problem is about the function setDump in updateCamera, but i don't know how to fix, i tryed everything...
Please, healp me!

Pages: [1]