PeasyCam on Android

edited January 12 in Android Mode

Hello

This is my first time to post, I am not sure if I put this in the right section of the form.

After 1 day of searching, reading, testing, finally, I got the Android mode up and running. I can successfully run some test sketch, most of them works perfect. However, when I try to run sketches with PeasyCam lib, the console is giving me errors, saying \ant\build.xml XXX has errors. I looked the build.xml file, the error lines read like this.

 <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
            <!-- only convert to dalvik bytecode is *not* a library -->
            <do-only-if-not-library elseText="Library project: do not convert bytecode..." >
                <!-- special case for instrumented builds: need to use no-locals and need
                     to pass in the emma jar. -->
                <if condition="${build.is.instrumented}">
                    <then>
                        <dex-helper nolocals="true">
                            <external-libs>
                                <fileset file="${emma.dir}/emma_device.jar" />
                            </external-libs>
                        </dex-helper>
                    </then>
                    <else>
                        <dex-helper />
                    </else>
                </if>
            </do-only-if-not-library>
        </do-only-if-manifest-hasCode>


  verbose="${verbose}">
                <path path="${out.dex.input.absolute.dir}"/>
                <path refid="out.dex.jar.input.ref" />
                <external-libs />

I am using Processing 3.2.3 Android SDK API 7.1.1 (25)

Here is the code I am running into problems when I try to run it on my Android device (physical device);

import peasy.*;
PeasyCam cam;

void setup () {
  size (800, 800, P3D);
  cam = new PeasyCam(this, 200);
}

void draw () {
  background(80);
  box(90);
}

Could someone possibily please help?

Answers

  • edited January 12

    @Bizkit_J===

    --not sure at all that peasy is supposed to work in android mode; the doc never says that and looking in the source you can see that some methods or listeners (mouseWheel e.g) probably cannot run;

    --+ trying myself to compile some project with peasy for testing, i see that the error is "unsupported class file version 52.0 [dx] ...while parsing peasy/CameraState.class" this error according to Oracle means incompatibility versions of java (1.7,1.8)::

    The class file version for Java SE 8 is 52.0 as per the JVM Specification. Version 52.0 class files produced by a Java SE 8 compiler cannot be used in earlier releases of Java SE. The following document has information on changes to the Java Language Specification (JLS) and the Java VM Specification (JVMS).

    JSR 337: Java SE 8 Release Contents
    

    --Then the Android doc adds that "android supports java 1.7 + a subset of 1.8...

    https://developer.android.com/guide/platform/j8-jack.html

  • Hello akenaton

    Thank you for your reply and look into this. I should have thought of this.

    Anyhow, I am working on a 3D app for Android, this is going to be my 1st android app, it is pretty simple and basic.

    Now, since Peasycam can not work in Android mode, I am wondering is there any other ways, better ways to navgiating the view?

    Thank you again.

  • If you draw your objects in draw, you could introduce offsets in their positions simulating camera displacement. You can also try the camera() function. however, I haven't tested it myself in Android yet.

    Kf

  • edited January 12 Answer ✓

    @Bizkit=== as for android 3D you can use the native android OPENGL ES:

    https://developer.android.com/guide/topics/graphics/opengl.html#proj-es2

    --there is also the min3D library which is more simple and can be imported in Eclipse or AS, yet probably not as it is in Processing.

  • Here is an example of manipulating the scene by using translate and rotate functions. You can use the ketai library to use other multi-touch events like pinch or flicks. I hope this helps,

    Kf

    //INSTRUCTIONS:
    //Move finger along width of device to rotate box
    //Drag finger along height to move object in the Y-Z plane
    //NOTICE mini sphere grid is lay out on the X-Y plane
    
    PShape b;
    float offset=0;
    boolean pre=false;
    
    PGraphics pg;
    
    void setup() {
      size(displayWidth, displayHeight, P3D);
      orientation(PORTRAIT);
      shapeMode(CENTER);
    
      b = createShape(BOX, 100);
      b.setFill(color(100, 220, 200));
      b.setStroke(255);
      b.setStrokeWeight(3);
    
      pg=createGraphics(width, height, P3D);
      pg.beginDraw();
      pg.lights();
      for (int i=0; i<width; i+=100)
        for (int j=0; j<height; j+=100) {
          PShape s = createShape(SPHERE, 20);
          pg.shape(s, i, j);
        }
      pg.endDraw();
    }
    
    
    
    void draw() {
    
      background(0);
      lights();
    
      image(pg, 0, 0);
    
      if (pre==true)
        offset=height/2-mouseY;
      else 
        offset=0;
    
      float angle = map(mouseX, 0, width, 0, 360);
    
      translate(width/2, height/2+offset, offset*2);
      rotate(radians(angle));
      shape(b, 0, 0);
    }
    
    
    
    void mousePressed() {
      pre=true;
    }
    
    void mouseReleased() {
      pre=false;
    }
    
  • You can use the camera handler provided by Processing:
    https://processing.org/reference/Camera_.html
    https://processing.org/reference/beginCamera_.html

    However, it seems that mouse events don't respond. To demonstrate, replace line 50 in my previous post with:

      beginCamera();
      camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), 0,0, 0, 0, 1, 0);  
      rotateX(radians(frameCount%360));
      endCamera();
    

    Kf

Sign In or Register to comment.