2009年3月21日

Source code for Java3D Collada1.4.1 Loader

After I answered Mariano's comment I got another work and was a bit busy so it got so late to upload my source code here. This source code is originally from j3d-incubator project so every rights should follow their policy except some codes that I wrote entirely new. My codes are published under GPL for now. I'd love to marge my code to incubator project when I get time.

Sorry for this inconvenience.

You can download source code here.

2009年1月26日

Java3D model loader for Google SketchUp

I'm trying to implement a Java3D model loader for Collada 1.4.1 format.
There's an implementation on j3d-incubator project however it doesn't seem that is supporting many functions so that I checked out from their repository and tried implementing additional functions.
When I get some result, I'd like to submit my codes.

For the first step, I tried loading models that were made with Google SketchUp (it's using Collada format) 
As you know, there is a lot of great models on 3D Warehouse and it must be very helpful if you can load them into your java 3d application.

I made a very simple applet to try loading them.
(I sincerely ask you guys to accept my personal signature that is needed to access local files by the applet)


It hasn't been supporting a lot of functions however it is able to load geometry, basic materials (such as diffuse or ambient colours) and simple textures.
Please be careful loading a large file, it might require a huge amount of memory space.

You can also download jar binary archive.
Here's a code fragment to try it. Please refer Java3D object loader usage that you can find on several web sites. 
loader.KmzLoader l = new loader.KmzLoader();
Scene s = l.load(new URL(path));
BranchGroup bg = s.getSceneGraph();
You may also need to adjust camera location or things.
I found out if the model is too large Java3D is not able to handle z buffer orders so then you need to use Transform group to scale it smaller. 
If someone has information on this problem and solution please let me know.

Hope you can enjoy it. :)
When you find bugs or have any requirements, I'd be grateful if you leave messages here.

2009年1月22日

Compiling Collada 1.5 schema by JAXB

I had a problem compiling Collada 1.5 schema by JAXB so I write problems and the way I solved it.

What you need to prepare is
  1. Download Collada 1.5.0 Schema (if the extension is "txt", the change it to "xsd")
  2. Download latest JAXB (currently 2.1.9 is the latest)
  3. Open and place them as you need. (also set a path for Java and others)
First, I tried the command "xjc collada_schema_1_5.xsd" and got the following errors.

[ERROR] Property "Source" is already defined. Use <jaxb:property> to resolve this conflict.
line 8785 of file:/Users/shiva/TMP/collada/collada_schema_1_5.xsd
...

This problem is occurred by name collision it seemed and I found a solution here
"simpleMode.xml" helped to avoid the first problem. (and it worked well for collada 1.4 schema)
The Command was 

"xjc collada_schema_1_5.xsd -extension simpleMode.xml"
(make sure the path to "simpleMode.xml")

When I tried it, "xjc" died of OutOfMemory error however I could not find a way to enlarge memory space for "xjc" command.
So that I needed to call "xjc" from "java" command as follows.

"java -Xmx1024m -jar jaxb-xjc.jar collada_schema_1_5.xsd -extension simpleMode.xsd"

This worked enough and I could get java classes for the schema.

2008年6月25日

64-bit Mac OSXではSWTがサポートされていないんだね、、、

以前公開したプラグインがMacで動かせないとの報告をいただいていたのですが、
今日Mac Bookを入手したのでいろいろ調べてみたところ
どうやら原因はSWTがサポートされていないということらしい。


困ったなぁ。

2008年6月3日

NyARToolkit Eclipse Plugin 更新

リフレクションでネイティブライブラリのロードを実現するように更新しました。

あと、NyARToolkit Eclipse Plugin 解説をA虎@さんのNyARToolkit wikiに執筆中です。
今までマニュアル皆無でごめんなさい。

Sourceforgeからダウンロードしてくださった方々。
私の説明不足だったのですが、上がっているのはソースコードでプラグインとしてインストールできる形のものではありません。
インストールはEclipseの更新マネージャを使って
http://www.ylab.ai.kyutech.ac.jp/~shiva/nativecapable/update
からお願いします。

P.S.
Macで試された方から新規プロジェクト生成ウィザードがの開始できないという報告をいただいています。近日中にMacを手に入れてやってみる予定です。しばしお待ちくださいm(_ _)m

2008年5月27日

Appletからネイティブライブラリをロードする(リフレクション編)

以前、NyARToolkitをApplet化するときに、かなり複雑なことをしてネイティブライブラリをロードしていました。
が、リフレクション使えばもっと簡単に出来そうなことに今更ながら気が付きました。

URL url = NativeLoadTest.class.getResource("jogl_awt.dll");
File file = new File(url.toURI());

ClassLoader cl = Thread.currentThread().getContextClassLoader();

Field f = ClassLoader.class.getDeclaredField("usr_paths");
f.setAccessible(true);
String[] paths = (String[]) f.get(cl);

String[] paths2 = new String[paths.length + 1];
System.arraycopy(paths, 0, paths2, 0, paths.length);
paths2[paths2.length - 1] = file.getParentFile().getAbsolutePath();

f.set(cl, paths2);
f.setAccessible(false);

System.loadLibrary("jogl_awt");
まだAppletでは試していませんが、これならかなり簡単。
もちろんセキュリティーは無視するとして。
ClassLoaderの実装依存(フィールド名が変わったらダメ)なのが問題点ですが、今更変わるものでもないでしょう。
ということで、近々NativeCapableフレームワーク更新します。


SunがApplet Launcherというものを公開しているのを最近知りました。
Java Web StartのApplet適用っていう感じです。
Sunが署名しているため、安心して使うことが出来ます。
メジャーなネイティブライブラリ(JOGLやJava3Dなど)を使う場合はこれを使うのがよさそうです。
(ライブラリ側で対応しておかないといけないのが難点ですが)

時間があれば使ってみて感想を書きたいと思います。

2008年5月21日

Sourceforge.jpのSVNをEclipseから使う

ちょっと面倒くさいので、参考リンクをメモ。
どっちもSourceforgeJPにきちんと書いてあるんだけどね。