Author Topic: Gif in vuforia-jpct-ae  (Read 4467 times)

Offline angelala

  • bit
  • Posts: 3
    • View Profile
Gif in vuforia-jpct-ae
« on: October 29, 2013, 08:56:54 PM »
Hi, I had read this: http://www.paulscode.com/forum/index.php?topic=9.0 , this is awesome. Can this be implement into AR world. I want to render a gif on a plane on a marker.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Gif in vuforia-jpct-ae
« Reply #1 on: October 29, 2013, 10:00:53 PM »
Sure, I don't see why you couldn't.  If you can render a quad in 3D space and set the camera position and orientation the way you want, you'd just assign the animated texture on the quad.  Presumably you would be using jPCT-ae for an AR project, correct?  If so, here is the Android port of that project (uses Android-specific API for images and textures):

Example Ap  (source code)
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline angelala

  • bit
  • Posts: 3
    • View Profile
Re: Gif in vuforia-jpct-ae
« Reply #2 on: October 29, 2013, 11:07:02 PM »
Below is my code in ImageTargetsRenderer.java, but I have an error :- The method getResources() is undefined for the type ImageTargetsRenderer


Code: newbielink:javascript:void(0); [nonactive]
public ImageTargetsRenderer(ImageTargets activity){
        this.mActivity = activity;
        TextureManager.getInstance().flush();
        world = new World();
world.setAmbientLight(20, 20, 20);

sun = new Light(world);
sun.setIntensity(250, 250, 250);

// Create a red texture, for debugging purposes (TODO: remove)
Texture texture = new Texture( 8, 8, new RGBColor( 255, 0, 0) );
TextureManager.getInstance().addTexture( "texture", texture );

// Load some animated GIF files to use:
GIFHandlerJPCTAE.addTexture( "Front", getResources().openRawResource( R.raw.twobuf ), true );

plane = Primitives.getPlane(20, 30);
plane.calcTextureWrapSpherical();
plane.setTexture("texture");
plane.strip();
cube.build();

world.addObject(plane);

/* cube = Primitives.getCube(100);
cube.calcTextureWrapSpherical();
cube.setTexture("texture");
cube.strip();
cube.build();

world.addObject(cube);*/

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

SimpleVector sv = new SimpleVector();
sv.set(cube.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();
        initNativeCallback();

        // 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();
       
        long currentTimeMillis = System.currentTimeMillis();

if( currentTimeMillis - time >= 1000 )
{
Logger.log( fps + "fps" );
fps = 0;
time = System.currentTimeMillis();
}
fps++;
        // Animate the GIFs:
        animateGIFs( currentTimeMillis );
    }
   
 // Animate the GIFs
    private void animateGIFs( long currentTimeMillis )
    {
        // If a frame number has changed, update the UV coordinates.
        if( frontGIF.getCurrentFrameNumber() != frontGIF.animate( currentTimeMillis ) );
    }
   
    public void updateCamera() {
    Matrix m = new Matrix();
    m.setDump(modelViewMat);
            cam.setBack(m);
    }
   
    public void updateModelviewMatrix(float mat[]) {
        modelViewMat = mat;
    }

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Gif in vuforia-jpct-ae
« Reply #3 on: October 30, 2013, 06:37:32 AM »
Presumably you need to call getResources from a Context or Activity instance.  You could pass the context to your class in its constructor for example.
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline angelala

  • bit
  • Posts: 3
    • View Profile
Re: Gif in vuforia-jpct-ae
« Reply #4 on: October 30, 2013, 08:14:47 PM »
Hi,  I had change my code to this:
GIFHandlerJPCTAE.addTexture( "Bottom", activity.getResources().openRawResource( R.raw.twobuf ), true );
and no error. But after i installed it into my phone, the app close unexpectedly.
Why is this happen?

Thanks.

Offline Paul

  • Administrator
  • double
  • *****
  • Posts: 3473
  • Developer
    • View Profile
    • PaulsCode.Com
Re: Gif in vuforia-jpct-ae
« Reply #5 on: October 30, 2013, 10:55:35 PM »
Who knows?  What does logcat say?
Device: Samsung Galaxy Nexus i515
CPU: TI OMAP4460, 1.2 GHz (dual core, ARM Cortex-A9)
GPU: PowerVR SGX540, 307 MHz
RAM: 1 GB
Resolution: 720 x 1280
Rom: omni-4.4.4-20141014-toro-FML KitKat 4.4.4, rooted

Device: Eee PC 1015PEM
CPU: Intel Atom N550, 1.5 GHz (dual core, x86)
GPU: Intel GMA 3150, 200 MHz (dual core)
RAM: 2GB
Resolution: 1024 x 600
Rom: android-x86-4.3-20130725 Jelly Bean 4.3, rooted

Offline adelmrk

  • bit
  • Posts: 1
    • View Profile
Re: Gif in vuforia-jpct-ae
« Reply #6 on: April 28, 2016, 02:04:11 PM »
Hi Paul,
I see your sample code and apk up this topic
now I want to use that in my project
I am using Image target vuforia sample
could you help me about that ?

use GIF format (with transparency=alpha-channel) in Vuforia Android SDK

Thanks