Skip to content

Commit

Permalink
Desktop-M3G側のインターフェースの変更に伴うアップデート
Browse files Browse the repository at this point in the history
  • Loading branch information
Ueda.A.Takashi authored and Ueda.A.Takashi committed Nov 24, 2011
1 parent b295e77 commit dd530d8
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 50 deletions.
11 changes: 11 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@




2011/xx/xx
- remove dependecy for libpng and libjpeg.
- you don't need these library any more!


2011/05/17 ver 0.3.3
- first release
21 changes: 13 additions & 8 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,32 @@ Brief description
-------------------------------------------

= What is the Java-M3G? =
Java-M3G is a java bindings for Desktop-M3G (Which implements M3G 1.1(JSR184) API).
Java-M3G is a java binding for Desktop-M3G (Which implements M3G 1.1(JSR184) API).
It is distributed under MIT license.

= Requirement =
- OpenGL 1.5 or higher (for Linux)
- OpenGL ES 1.1 or higher (for Android)
- libz
- Desktop-M3G (libm3g.so)
- libz (*1)
- Desktop-M3G (*2)

(*1) You need only libz.
Current version of Java-M3G(and Desktop-M3G) doesn't need libpng an libjpeg yet.
(*2) Desktop-M3G is another project.
But binary package of Java-M3G also contains this.
So, you can use Java-M3G very easy and quick.

= Java-M3G =
Java-M3G consits of 3 components.
- java-m3g.jar := Java bindings for Desktop-M3G
- libjava-m3g.so := jni(C++) library which inteconnects Java side and C++ side.
- libm3g.so := Desktop-M3G which implements M3G-1.1(JSR 184) API.

- java-m3g.jar := Java binding for Desktop-M3G
- libjava-m3g.so := jni(C++) library which inteconnects Java side and C++ side
- libm3g.so := Desktop-M3G which implements M3G-1.1(JSR 184) API

-------------------------------------------
Make & Install
-------------------------------------------

- see README.linux for Linux
- see README.linux for Linux
- see README.android for Android


Expand Down
30 changes: 18 additions & 12 deletions README.linux
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ Make & Install
Compile C++ native libary first.
1. cd ${Java-M3G}/jni/build/linux/Debug
2. cmake -DCMAKE_BUILD_TYPE=Debug ../../..
- will generate libjava-m3g.so
- will generate Makefile
3. make
- will generate libjava-m3g.so
4. make install
- will install Java-M3G to ${Java-M3G}/bin.

= java-m3g.jar =
You need Eclipse for compiling java-m3g.jar.
1. import all projects from ${Java-M3G}/build/linux
- 「import」-->「Existing Projects into Workspace」-->「Select root directory」
- You can find Java-M3G, Sample-00-JOGL, Smaple-01-Simple, etc., ...
- 「Import」-->「General」-->「Existing Projects into Workspace」-->「Select root directory」
Select ${Java-M3G}/build/linux as root directory.
You can find Java-M3G project and other sample projects (Sample-00-JOGL, Smaple-01-Simple, etc., ...).
Import all of them.
2. open (or double click) java-m3g.jardesc at java-M3G project
- will export java-m3g.jar
- will export java-m3g.jar


-------------------------------------------
Expand All @@ -54,36 +57,39 @@ How to use Java-M3G
= Copy Java-M3G =
You need to copy 3 components (java-m3g.jar, libjava-m3g.so and libm3g.so) to your project.
You can find them here.
- ${Java-M3G}/Java-M3G/bin/java-m3g.jar
- ${Java-M3G}/build/linux/Java-M3G/bin/java-m3g.jar
- ${Java-M3G}/jni/bin/lib/linux/libjava-m3g.so
- ${Java-M3G}/jni/bin/lib/linux/libm3g.so
Copy to your ${YourFavorite} directory.
Copy them to your ${YourFavorite} directory.

= Setup JOGL =
Open your project in Eclipse.
- [Properties] --> [Java Build Path] --> [Libraries] --> [Add External JARs...]
set jar files and native location.
set jar files,
- /usr/share/java/jogl.jar (on my Ubuntu 11.10)
- /usr/share/java/glugen-rt.jar (on my Ubuntu 11.10)
and native library location.
- /usr/lib/jni (on my Ubuntu 11.10)
Don't forget to set native library location.
They need native libraries (libjogl.so, libgugen-rt.so).
Actually they need their proper native libraries (libjogl.so, libgugen-rt.so).

= Setup Java-M3G =
Open your project in Eclipse.
- [Properties] --> [Java Build Path] --> [Libraries] --> [Add External JARs...]
set jar files and native library location.
- ${YourFavorite}/java-m3g.jar
- ${YourFavorite}/
set jar files,
- ${YourFavorite}/java-m3g.jar (any where you choiced)
and native library location.
- ${YourFavorite}/ (any where you choiced)
Don't forget to set native library location.
They need native libraries (libm3g.so, libjava-m3g.so).
Also Java-M3G need their 2 native libraries (libm3g.so, libjava-m3g.so).

-------------------------------------------
Test & Samples
-------------------------------------------

= UnitTest =
You can find UnitTest project on eclipse.
But it's broken.

= Samples =
You can find about 15 sample projects on eclipse.
Expand Down
16 changes: 8 additions & 8 deletions jni/src/java-Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ JNIEXPORT void JNICALL Java_org_karlsland_m3g_Mesh_jni_1initialize__Lorg_karlsla
(JNIEnv* env, jobject thiz, jobject vertices, jobjectArray submeshes, jobjectArray appearances)
{
//cout << "Java-Mesh: initialize1 is called.\n";
VertexBuffer* vbuf = (VertexBuffer*)getNativePointer (env, vertices);
int len = env->GetArrayLength (submeshes);
IndexBuffer** ibufs = new IndexBuffer* [len];
for (int i = 0; i < len; i++) {
VertexBuffer* vbuf = (VertexBuffer*)getNativePointer (env, vertices);
int ibufs_len = env->GetArrayLength (submeshes);
IndexBuffer** ibufs = new IndexBuffer* [ibufs_len];
for (int i = 0; i < ibufs_len; i++) {
ibufs[i] = (IndexBuffer*)getNativePointer (env, env->GetObjectArrayElement(submeshes, i));
}
len = env->GetArrayLength (appearances);
Appearance** apps = new Appearance* [len];
for (int i = 0; i < len; i++) {
int apps_len = env->GetArrayLength (appearances);
Appearance** apps = new Appearance* [apps_len];
for (int i = 0; i < apps_len; i++) {
apps[i] = (Appearance*)getNativePointer (env, env->GetObjectArrayElement(appearances, i));
}
Mesh* mesh = NULL;
__TRY__;
mesh = new Mesh (vbuf, len, ibufs, apps);
mesh = new Mesh (vbuf, ibufs_len, ibufs, apps_len, apps);
__CATCH__;
if (env->ExceptionOccurred ()) {
return;
Expand Down
14 changes: 7 additions & 7 deletions jni/src/java-MorphingMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ JNIEXPORT void JNICALL Java_org_karlsland_m3g_MorphingMesh_jni_1initialize__Lorg
for (int i = 0; i < tars_len; i++) {
tars[i] = (VertexBuffer*)getNativePointer (env, env->GetObjectArrayElement(targets, i));
}
int len = env->GetArrayLength (submeshes);
IndexBuffer** ibufs = new IndexBuffer* [len];
for (int i = 0; i < len; i++) {
int ibufs_len = env->GetArrayLength (submeshes);
IndexBuffer** ibufs = new IndexBuffer* [ibufs_len];
for (int i = 0; i < ibufs_len; i++) {
ibufs[i] = (IndexBuffer*)getNativePointer (env, env->GetObjectArrayElement(submeshes, i));
}
len = env->GetArrayLength (appearances);
Appearance** apps = new Appearance* [len];
for (int i = 0; i < len; i++) {
int apps_len = env->GetArrayLength (appearances);
Appearance** apps = new Appearance* [apps_len];
for (int i = 0; i < apps_len; i++) {
apps[i] = (Appearance*)getNativePointer (env, env->GetObjectArrayElement(appearances, i));
}
MorphingMesh* mesh = NULL;
__TRY__;
mesh = new MorphingMesh (vbuf, tars_len, tars, len, ibufs, apps);
mesh = new MorphingMesh (vbuf, tars_len, tars, ibufs_len, ibufs, apps_len, apps);
__CATCH__;
if (env->ExceptionOccurred ()) {
return;
Expand Down
18 changes: 9 additions & 9 deletions jni/src/java-SkinnedMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ JNIEXPORT void JNICALL Java_org_karlsland_m3g_SkinnedMesh_jni_1initialize__Lorg_
(JNIEnv* env, jobject thiz, jobject vertices, jobjectArray submeshes, jobjectArray appearances, jobject skeleton)
{
//cout << "Java-SkinnedMesh: initialize1 is caleld.\n";
VertexBuffer* vbuf = (VertexBuffer*)getNativePointer (env, vertices);
Group* skel = (Group*) getNativePointer (env, skeleton);
int ibuf_len = env->GetArrayLength (submeshes);
int app_len = env->GetArrayLength (appearances);
IndexBuffer** ibufs = new IndexBuffer* [ibuf_len];
Appearance** apps = new Appearance* [app_len];
for (int i = 0; i < ibuf_len; i++) {
VertexBuffer* vbuf = (VertexBuffer*)getNativePointer (env, vertices);
int ibufs_len = env->GetArrayLength (submeshes);
IndexBuffer** ibufs = new IndexBuffer* [ibufs_len];
for (int i = 0; i < ibufs_len; i++) {
ibufs[i] = (IndexBuffer*)getNativePointer (env, env->GetObjectArrayElement(submeshes, i));
}
for (int i = 0; i < app_len; i++) {
int apps_len = env->GetArrayLength (appearances);
Appearance** apps = new Appearance* [apps_len];
for (int i = 0; i < apps_len; i++) {
apps[i] = (Appearance*)getNativePointer (env, env->GetObjectArrayElement(appearances, i));
}
Group* skel = (Group*)getNativePointer (env, skeleton);

SkinnedMesh* mesh = NULL;
__TRY__;
mesh = new SkinnedMesh (vbuf, ibuf_len, ibufs, apps, skel);
mesh = new SkinnedMesh (vbuf, ibufs_len, ibufs, apps_len, apps, skel);
__CATCH__;
if (env->ExceptionOccurred ()) {
return;
Expand Down
13 changes: 7 additions & 6 deletions jni/src/java-TriangleStripArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ JNIEXPORT void JNICALL Java_org_karlsland_m3g_TriangleStripArray_jni_1initialize
(JNIEnv* env, jobject thiz, jintArray indices, jintArray stripLengths)
{
//cout << "Java-TriangleStripArray: initilize1 is called.\n";
int* indcs = env->GetIntArrayElements (indices, 0);
int length = env->GetArrayLength (stripLengths);
int* strip_lengths = env->GetIntArrayElements (stripLengths, 0);
int inds_len = env->GetArrayLength (indices);
int* inds = env->GetIntArrayElements (indices, 0);
int lengths_len = env->GetArrayLength (stripLengths);
int* lengths = env->GetIntArrayElements (stripLengths, 0);
TriangleStripArray* tris = NULL;
__TRY__;
tris = new TriangleStripArray (indcs, length, strip_lengths);
tris = new TriangleStripArray (inds_len, inds, lengths_len, lengths);
__CATCH__;
if (env->ExceptionOccurred ()) {
return;
}
env->ReleaseIntArrayElements (indices, indcs, 0);
env->ReleaseIntArrayElements (stripLengths, strip_lengths, 0);
env->ReleaseIntArrayElements (indices, inds, 0);
env->ReleaseIntArrayElements (stripLengths, lengths, 0);
setNativePointer (env, thiz, tris);
bindJavaReference (env, thiz, tris);
}
Expand Down

0 comments on commit dd530d8

Please sign in to comment.