Odejava: how to use (for beginners)

I have started this thread for Odejava beginners. If you have any questions on how to get started with Odejava then post your message here.

In here you can ask e.g. how to create various objects, create fixed enviromental objects (e.g. racing track with ramps), or how to attach an box into a sphere with a joint (e.g. car chassis with 2-axis joint on wheels) and so on.

Currently best source for getting started with Odejava is package net.java.dev.odejava.test. Simplest scenario is OdeHelloWorld.java.

Binding odejava’s objects into 3d renderer is simple. Check e.g. package net.java.dev.odejava.jme.test. There is a BoxApp.java class that constantly reads translation and rotation information for each object from OdeBox.java class and updates this information to jME objects before rendering the scene.

http://odejava.dev.java.net has a package called odejava-0.1.1-full.zip, all sources included.

I’ll be adding few simpler demos later showing how to implement a specific physic setup with odejava. Something as simple as getting started tutorials with Xith3d. E.g. how to create simple objects, static objects, how to use various joints, how to apply forces to an object and finally how to bind ode objects to your 3d library (xith3d, jme, openmind etc.). What do you think, these are pretty simple but might help the understanding of Odejava at first glance, how important is this?

In the meantime you can ask your question here (or by writing email to me).

Please suggest demos than should be added to the getting started section or other ideas that you might have. Java API itself is ready but there’s always room for making it better.

PS. New package and CVS will be released in a couple days.

an Ode getting started guide for Xith3D would be very good indeed.

How is ode at handling terrain? I currently generate terrain using a random fractal generator (essentially just making quads) and I am woundering how hard it would be to integrate it with ode and a vehicle.

Thanks,

Will.

Terrain is added to Odejava 0.2 along with nicer API also.

Terrain is basically defined by heights and length. If you want to check how it is implemented then see ode/contrib/TerrainAndCone/readme.txt

I am sure it works with Odejava also but rendering the terrain needs to be done. it would be excellent if you can write an Xith3d routine that draws the terrain, see ode/contrib/TerrainAndCone/readme.txt and see the method dsDrawTerrain. Should not be too complicated, the routine just draws filled triangles with couple lines of code. I try to concentrate on releasing the new version, contact me if you need help with this one!

Trying to release version 0.2 this weekend.

Here’s how you create terrain on Odejava 0.2.


int terrainNodes = 4;
float[] heights = new float[terrainNodes* terrainNodes];
float length = 4f;
float height = 0.5f;
int numNodesPerSide = 4;
for (int i=0;i<terrainNodes* terrainNodes;i++)
heights[i] = height * (float) Math.random();
GeometryTerrain terrain = new GeometryTerrain(space, heights, length, numNodesPerSide);

Please write to me if anyone wishes to create Xith3d routine that renders this terrain. I think this is pretty easy for anyone that is familiar with 3d.

In practise the routine below needs to be made with Java.


void dsDrawTerrain(int x,int y,float vLength,float vNodeLength,int nNumNodesPerSide,float *pHeights)
{
float A[3],B[3],C[3],D[3];
float R[12];
memset(R,0,sizeof®);
R[0] = 1.f;
R[5] = 1.f;
R[10] = 1.f;
float pos[3];
pos[0] = pos[1] = pos[2] = 0.f;
float vx,vy;
vx = vLength * x;
vy = vLength * y;

    int i;
    for (i=0;i<nNumNodesPerSide;i++)
    {
            for (int j=0;j<nNumNodesPerSide;j++)
            {
                    A[0] = i * vNodeLength + vx;
                    A[1] = j * vNodeLength + vy;
                    A[2] = GetHeight(i,j,nNumNodesPerSide,pHeights);
                    B[0] = (i+1) * vNodeLength + vx;
                    B[1] = j * vNodeLength + vy;
                    B[2] = GetHeight(i+1,j,nNumNodesPerSide,pHeights);
                    C[0] = i * vNodeLength + vx;
                    C[1] = (j+1) * vNodeLength + vy;
                    C[2] = GetHeight(i,j+1,nNumNodesPerSide,pHeights);
                    D[0] = (i+1) * vNodeLength + vx;
                    D[1] = (j+1) * vNodeLength + vy;
                    D[2] = GetHeight(i+1,j+1,nNumNodesPerSide,pHeights);
                    dsDrawTriangle(pos,R,C,A,B,1);
                    dsDrawTriangle(pos,R,D,C,B,1);
            }
    }

}

In the Xith3D forum, there is a thread about building odejava on Mac OS X.

Thanks for the tip, I’m busy gettin odejava 0.2 out and setting up the CVS. Low level API is now fully supported through ODE C API, high level API is almost finished after this is done I’ll release 0.2.

PS. It supports TriMesh and also some contrib sections like Terrain, Cone and Cylinder.

Just incase anyone else is following this thread (Jani has already been emailed the code) - the Xith3D method to build the terrain from a heightmap is finished - I’m releasing the code along side some other handy modular 3D related stuff in a small library named “Enviro3D (e3d.jar)”. I’ll bung it in the xith-tk projects cvs in due course.

Also included will be a random fractal terrain generator which I ported from C.

Will.

Hope you get to try odejava.org.geom.GeomTriMesh also :slight_smile:

Terrain works nicely on Odejava 0.2 but rendering has still some issues, surely William can fix them.

I’m really looking forward to the next ODE release and the Xith3D terrain stuff sounds very interesting, too. :slight_smile: Please don’t keep these things to yourselves. Get them out, soon. ;D

update: I think I’ve fixed the terrain problemo.

The new high-level ode objects are most convenient. It’ll be good when its in CVS (hopefully this will be soon) :slight_smile:

Will.

Odejava 0.2 is going to CVS now… It should be there in half an hour or so.

It’s been more than two years, but GeomCone support is still missing. Am I overlooking something? Is it even in the native library ?

Damn I read this entire thread before I found out it was from 2003 :smiley:

;D ;D

Some documentation at least was created in that time :slight_smile:

http://www.java-gaming.org/forums/index.php?topic=12150.0

Will.

In the most recent documentation it says that the terrain call has been disabled. Is this actually the case? If so does anyone know why?

In case I can’t use the preprogrammed terrain generator, what is an appropriate size for the triangles in a GeomTriMesh that is serving for the terrain. My current count takes to long to run through and I run into timing issues with other threads starting their shit before I am ready for that to happen.

BTW I am doing fractal terrain based on the Diamond-Star method, if that helps find a solution.

Thanx for any help you can give me.

I also implemented fractal based terrain, and used GeomTriMesh’s. The Terrain thing was a patch to ODE that was not commented or documented and didn’t work. GeomTriMesh is a more generic case, but should work well for terrain.

Will.

I had bad experiences on this one… Objects falling through the terrain, and other bugs like that…

William Denniss,
Could you post a link to the source code for your terrain. I seem to have everything working but it just won’t pick up the collision with the surface. The exact same code works with the GeomPlain terrain, pretty well but I just can’t make it go for that third dimension.