jPCT-AE - a 3d engine for Android => Support => Topic started by: andvazva on June 17, 2016, 11:10:59 am

Title: Touch 3D object ArToolKitJpctBaseLib
Post by: andvazva on June 17, 2016, 11:10:59 am

I found an adaptation of ARToolKit + jpct + android:

https://github.com/plattysoft/ArToolKitJpctBaseLib (https://github.com/plattysoft/ArToolKitJpctBaseLib)

I've got draw various 3D objects on the screen.
But now I have the problem: I need to touch them
I saw this tutorial: http://www.jpct.net/wiki/index.php?title=Picking (http://www.jpct.net/wiki/index.php?title=Picking)
But my class is something different, is very abstracted and simple and I'm a newbie ..

This is the mainClass, I don't found my framebuffer... :'(

Code: [Select]
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import android.widget.Toast;

import com.threed.jpct.Loader;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;
import com.threed.jpct.World;

import org.artoolkit.ar.jpct.ArJpctActivity;
import org.artoolkit.ar.jpct.TrackableLight;
import org.artoolkit.ar.jpct.TrackableObject3d;

import java.io.IOException;
import java.util.List;

public class RealidadAumentada extends ArJpctActivity{
        private Object3D astronauta = null;
        private TrackableObject3d cubo = null;

        public void onCreate(Bundle savedInstanceState) {


     * Use the FrameLayout in this Activity's UI.
    protected FrameLayout supplyFrameLayout() {
        return (FrameLayout)this.findViewById(R.id.mainLayout);

    public void configureWorld(World world) {
        world.setAmbientLight(150, 150, 150);


    protected void populateTrackableObjects(List<TrackableObject3d> list) {
        Object3D astronauta2 = null;

        try {
            cubo = new TrackableObject3d("single;Data/patt.hiro;80", getCube());
            //astronauta2 = getAstronauta2());
            astronauta = getAstronauta();
        } catch (IOException e) {

        TrackableLight light = new TrackableLight();
        light.setIntensity(0, 0, 255);
        light.setPosition(new SimpleVector(0, 0, 100));




    private Object3D getCube() throws IOException {
        int scale = 40;
        Object3D object3D = Primitives.getCube(scale);
        // Cubes in jpct are rotated by 45 degrees when created.
        object3D.rotateY((float) Math.PI / 4);
        object3D.setOrigin(new SimpleVector(0, 0, scale));
        return  object3D;

        private Object3D getAstronauta() throws IOException {
            int scale = 40;
            Object3D[] astronaut = Loader.load3DS(getAssets().open("astronaut1.3ds"), 5);
            astronaut[0].setOrigin(new SimpleVector(0, 0, 270));

            return  astronaut[0];

        This method doesnt work
        public boolean onTouchEvent(MotionEvent me) {
            if (me.getAction() == MotionEvent.ACTION_DOWN) {
                Toast.makeText(this, cubo.getXAxis().toString()+" "+String.valueOf(me.getX()),2000).show();
               // Toast.makeText(this,String.valueOf(cubo.getCenter()),2000).show();
                return true;

Thank you
Title: Re: Touch 3D object ArToolKitJpctBaseLib
Post by: EgonOlsen on June 18, 2016, 04:51:04 pm
That's because there is none. If you don't understand your own code structure, then maybe it's time to refactor it. Just search your files for FrameBuffer. Every IDE has an option to search into files.
Title: Re: Touch 3D object ArToolKitJpctBaseLib
Post by: andvazva on June 22, 2016, 12:20:12 am
Solved !
I spent many hours but I finally got what I wanted.
Draw several 3D objects on a ARToolKit(Android) marker and then click on each of them.

Thanks for the help
Title: Re: Touch 3D object ArToolKitJpctBaseLib
Post by: ares91x on August 18, 2016, 06:00:14 pm
this has nothing to do with your problem but i saw something in your code that i'm looking for to much time. How do you track multpiple objects ,in other words how do you assign a pattern to a object for example hear
Code: [Select]
cubo = new TrackableObject3d("single;Data/patt.hiro;80", getCube()); you assign
Code: [Select]
"single;Data/patt.hiro;80" to Cube .How to assign different patterns to different objects ?