[toxiclibs] Import Toxi Mesh from STL in Android Mode

edited October 2016 in Android Mode

I cant seem to import a mesh as a toxi mesh.

import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.processing.*;
import toxi.geom.mesh.STLReader;
import toxi.geom.mesh.TriangleMesh;
import toxi.processing.ToxiclibsSupport;

import processing.opengl.*;

ToxiclibsSupport gfx;
TriangleMesh cave;

void setup() {
  fullScreen(P3D);
  cave = (TriangleMesh) new STLReader().loadBinary(sketchPath("cave.stl"), STLReader.TRIANGLEMESH);
  gfx = new ToxiclibsSupport(this);
}

void draw() {

  background(0);
  camera(0, 0, 10, 0, 0, -50, 0, -1, 0);
  directionalLight(255, 64, 0, 0.5f, -0.1f, 0.5f);
  fill(255);
  noStroke();
  gfx.mesh(cave, false);
}

It compiles but it crashes on the phone.

This one however works

import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.math.*;
import toxi.processing.*;

import processing.opengl.*;

float NOISE_SCALE = 0.08f;
int DIM=40;

Terrain terrain;
ToxiclibsSupport gfx;
Mesh3D mesh;

void setup() {
  fullScreen(P3D);
  terrain = new Terrain(DIM, DIM, 50);
  float[] el = new float[DIM*DIM];
  noiseSeed(23);
  for (int z = 0, i = 0; z < DIM; z++) {
    for (int x = 0; x < DIM; x++) {
      el[i++] = noise(x * NOISE_SCALE, z * NOISE_SCALE) * 400;
    }
  }
  terrain.setElevation(el);
  mesh = terrain.toMesh();
  gfx = new ToxiclibsSupport(this);
}

void draw() {
  background(0);
  camera(0, 0, 10, 0, 0, -50, 0, -1, 0);
  directionalLight(255, 64, 0, 0.5f, -0.1f, 0.5f);
  fill(255);
  noStroke();
  gfx.mesh(mesh, false);
}

It looks like toxiclib works in processing for android so I'm not sure why I'm getting this problem.

Tagged:
Sign In or Register to comment.