Sure, my "hello android" code example is here. But basically you just
follow the Android example code from their website.
http://developer.android.com/guide/tutorials/hello-world.html
Then you simply have jinngine in a separate eclipse project, and
specify jinngine on you android project's build path, in Project-
>Properties->Build Path->Projects(tab). After that you use the Android
run configuration to execute the code. If you plug in an Android
device, you can chose to run directly on that device instead of the
emulated device. But be warned, it doesn't run terribly fast, but it
runs. And since no low-level optimizations has yet been done, I
suspect there is room for great improvement of the Android
performance.
My code example goes here:
package com.mofobo.helloandroid;
import jinngine.collision.SAP2;
import jinngine.geometry.Box;
import jinngine.math.Vector3;
import jinngine.physics.Body;
import jinngine.physics.DefaultDeactivationPolicy;
import jinngine.physics.DefaultScene;
import jinngine.physics.force.GravityForce;
import jinngine.physics.solver.NonsmoothNonlinearConjugateGradient;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
// start jinngine
DefaultScene scene = new DefaultScene(new SAP2(), new
NonsmoothNonlinearConjugateGradient(10), new
DefaultDeactivationPolicy());
scene.setTimestep(0.1);
// add boxes to bound the world
Body floor = new Body("floor", new Box(1500,20,1500));
floor.setPosition(new Vector3(0,-30,0));
floor.setFixed(true);
Body back = new Body( "back", new Box(200,200,20));
back.setPosition(new Vector3(0,0,-55));
back.setFixed(true);
Body front = new Body( "front", new Box(200,200,20));
front.setPosition(new Vector3(0,0,-7));
front.setFixed(true);
Body left = new Body( "left", new Box(20,200,200));
left.setPosition(new Vector3(-35,0,0));
left.setFixed(true);
Body right = new Body( "right", new Box(20,200,200));
right.setPosition(new Vector3(10,0,0));
right.setFixed(true);
// create a box
Box boxgeometry = new Box(2,2,2);
Body box = new Body( "box", boxgeometry );
box.setPosition(new Vector3(-10,-11,-25));
// add all to scene
scene.addBody(floor);
scene.addBody(back);
scene.addBody(front);
scene.addBody(left);
scene.addBody(right);
scene.addBody(box);
// put gravity on box
scene.addForce( new GravityForce(box));
tv.setText("Performing time steps on jinngine\n");
long time = System.currentTimeMillis();
for (int i=0;i<1000; i++) {
scene.tick();
}
tv.append("done, 1000 time steps in " + (System.currentTimeMillis()-
time) + " milli seconds \n" );