jinngine and android

24 views
Skip to first unread message

leto

unread,
Aug 2, 2010, 11:49:00 AM8/2/10
to jinngine
Hello,

I was wondering if it was possible to use Jinngine with Android.
If so, I would appreciate some sample code.

Thanks

mo

unread,
Aug 2, 2010, 12:09:57 PM8/2/10
to jinngine
Hi :)

I don't own any Android device, so I haven't had a possibility to try
using Jinngine with Android. It should be possible though. The only
external dependency is the quickhull3d.jar file. If you don't want to
use convex hulls, you can even do without it. But I don't know
anything about Android at this point, so...

But I'm really interested in hearing about any experiences you have/
will have on the subject. Assuming its a game you want to do, it
should be fairly simple to use the transforms calculated by Jinngine
in what ever visualization interface you are running there. What kind
of application are you working on?

leto

unread,
Aug 3, 2010, 11:04:45 AM8/3/10
to jinngine
Thanks for your response.
Actually, I'm trying to learn android and 3D and rendering too. So I
am a little bit confused on how to handle them together.
For my learning, I am trying to roll a die.
I want to use android.opengl.GLSurfaceView.
As Jinngine is not a rendering tool, I am trying to use openGL ES as
the rendering tool with jinngine as the physics engine to handle
transformation.
Any suggestion would be appreciated.
I'll let you know if I can figure something out.

leto

unread,
Aug 4, 2010, 9:32:42 AM8/4/10
to jinngine
I don't own any android device either. But the android SDK gives you
an opportunity to test things thanks to its device emulator ;)

Victor Sergienko

unread,
Aug 7, 2010, 4:20:24 PM8/7/10
to jinngine
Hi.
I was looking for an engine for a simple game and ran into Jinngine.
Sadly, Android OpenGL ES uses only float variables, not double.
It might be a stopper.

mo

unread,
Aug 7, 2010, 4:56:09 PM8/7/10
to jinngine
Is it the OpenGL interface that's float only, or is it the whole
Android platform? If its only the OpenGL, transforms etc, it should
not be a big problem. Actually I think jinngine can run with floats
instead of doubles, but there might be an issue with the GJK
implementation. But I think if you stick to polygon and sphere-swept
shapes (where smooth support maps can be avoided), GJK will behave
reasonably well with single precision.

Interesting. Please let os know if you get jinngine running in your
Android app!

Victor Sergienko

unread,
Aug 8, 2010, 4:14:37 AM8/8/10
to jinngine
It is OpenGL ES standard, for every mobile platform out there. For
Java, that means Android and Java ME.
I didn't get to the specifications, but I believe things are that way.

I didn't wish to fork the whole source tree just to replace "double"
with "float", but looks like that's the only way. Anyway, I don't
think there is any other engine that would fit better, so will try to
go with it.
Will try moving to a single precision.

mo

unread,
Aug 8, 2010, 4:37:15 AM8/8/10
to jinngine
Don't know if you seen this, but take a look at

http://developer.android.com/guide/practices/design/performance.html#avoidfloat

As I said, I never tried anything on Android, so I know practically
nothing about it. But from the above it seems that doubles are
supported, and even preferred over float? Pretty confusing. Did you
try to simply throw a jinngine as it is onto your device, and just use
it without visualization just for testing?

Victor Sergienko

unread,
Aug 8, 2010, 1:11:03 PM8/8/10
to jinngine
That's true, but still, I believe, OpenGL ES was designed for use in
J2ME, with a minimal memory and CPU.
There was a time that it even recommended using fixed-point
arithmetics.
Now we have to deal with it %)

I'll try it.

On Aug 8, 11:37 am, mo <mor...@silcowitz.dk> wrote:
> Don't know if you seen this, but take a look at
>
> http://developer.android.com/guide/practices/design/performance.html
>

mo

unread,
Aug 8, 2010, 1:51:40 PM8/8/10
to jinngine
Okay, sounds exciting, let us know how it goes :)

I suspect a lot of stuff can be optimized in Jinngine in relation to
Android. Actually, Jinngine has not really been optimized in a
detailed way, only on design and algorithmic levels. Regarding OpenGL
ES using floats, my understanding is that graphics hardware is only
just moving to support doubles in place of floats. For a long period,
the precision offered by floats has been adequate for rendering,
processing textures, screen space techniques, etc. But I guess as the
desire to perform more and more advanced computations on GPU hardware,
the need for better numerical accuracy grows...

I tried working with both Jogl and Lwjgl, and if I remember correctly,
I converted my double transforms into float before feeding them into
OpenGL, and that worked fine.

I'm starting to feel a certain need to get my self a HTC Phone really
soon :)

leto

unread,
Aug 9, 2010, 3:25:10 PM8/9/10
to jinngine
Android Dev Guide says : "Android currently supports OpenGL ES 1.0,
which corresponds to OpenGL 1.3. So, if the application you have in
mind is possible with OpenGL 1.3 on a desktop system, it should be
possible on Android."

mo

unread,
Aug 10, 2010, 4:16:25 AM8/10/10
to jinngine
FYI, I installed the Android SDK, and got an example up and running
using

http://developer.android.com/guide/tutorials/hello-world.html

I then simply imported the jinngine package, made some configuration
and performed some time-steps. My Android/Jinngine app worked fine in
the emulated SDK phone.

So it is definitely possible to make it run without any trouble. But
sure, now we need to find out how it plays along with various stuff
like OpenGL ES, and how the performance and memory usage is in
practice....

leto

unread,
Aug 10, 2010, 9:31:15 AM8/10/10
to jinngine
Great ! Could it be possible to get the source code of your Android/
Jinngine app ?
It will definitely accelerate my understanding regarding how to
combine them.

mo

unread,
Aug 12, 2010, 3:23:10 AM8/12/10
to jinngine
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" );

leto

unread,
Aug 17, 2010, 8:49:04 AM8/17/10
to jinngine
Thanks mo.
However it doesn't help that much ;)
But, I am currently learning the concepts and will get back to you as
soon as possible.
Reply all
Reply to author
Forward
0 new messages