質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Linux Mint

Linux Mintは、使いやすいLinuxシステムの提供を目的としたLinuxディストリビューションです。UbuntuとDebianをベースにしており、Ubuntuのリポジトリを共有しています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Eclipse

Eclipseは、IBM社で開発された統合開発環境のひとつです。2001年11月にオープンソース化されました。 たくさんのプラグインがあり自由に機能を追加をすることができるため、開発ツールにおける共通プラットフォームとして位置づけられています。 Eclipse自体は、Javaで実装されています。

Q&A

解決済

1回答

1841閲覧

Eclipse上でのJBulletのデモが実行できない。

K_Cpamp

総合スコア6

Linux Mint

Linux Mintは、使いやすいLinuxシステムの提供を目的としたLinuxディストリビューションです。UbuntuとDebianをベースにしており、Ubuntuのリポジトリを共有しています。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Eclipse

Eclipseは、IBM社で開発された統合開発環境のひとつです。2001年11月にオープンソース化されました。 たくさんのプラグインがあり自由に機能を追加をすることができるため、開発ツールにおける共通プラットフォームとして位置づけられています。 Eclipse自体は、Javaで実装されています。

0グッド

0クリップ

投稿2018/01/03 09:12

編集2018/01/03 14:26

###前提・実現したいこと
物理エンジンBulletのJava版、JBulletをEclipse上で使えるようにしたい。
本家のBulletのデモはEclipse上ではないが実行できた。(関係ないかもしれないが…)

###発生している問題・エラーメッセージ
1.Eclipseで新規プロジェクトを生成。
2.Jbulletのjarをライブラリに追加を行い、デモがあったので実行。
3.しかしエラーを返してきた。

ここを参考にインストールを行った。
https://www.ntu.edu.sg/home/ehchua/programming/game/BulletPhysics_JBullet.html

Select "Native Library
はLinuxOSなのでwin32ではなくlinuxを通している.

Using jStackAllocはやれていない。これが原因の可能性あり。
自分のAntの知識,xmlの知識が乏しく申し訳ないです。

Exception in thread "main" java.lang.Error: not instrumented at cz.advel.stack.Stack.alloc(Stack.java:110) at com.bulletphysics.collision.broadphase.AxisSweep3Internal.<init>(AxisSweep3Internal.java:90) at com.bulletphysics.collision.broadphase.AxisSweep3.<init>(AxisSweep3.java:52) at com.bulletphysics.collision.broadphase.AxisSweep3.<init>(AxisSweep3.java:48) at com.bulletphysics.demos.helloworld.HelloWorld.main(HelloWorld.java:70)

###コード(stack.java)

stack.class

1 2/* 3 * JStackAlloc (c) 2008 Martin Dvorak <jezek2@advel.cz> 4 * 5 * This software is provided 'as-is', without any express or implied warranty. 6 * In no event will the authors be held liable for any damages arising from 7 * the use of this software. 8 * 9 * Permission is granted to anyone to use this software for any purpose, 10 * including commercial applications, and to alter it and redistribute it 11 * freely, subject to the following restrictions: 12 * 13 * 1. The origin of this software must not be misrepresented; you must not 14 * claim that you wrote the original software. If you use this software 15 * in a product, an acknowledgment in the product documentation would be 16 * appreciated but is not required. 17 * 2. Altered source versions must be plainly marked as such, and must not be 18 * misrepresented as being the original software. 19 * 3. This notice may not be removed or altered from any source distribution. 20 */ 21 22package cz.advel.stack; 23 24import cz.advel.stack.instrument.InstrumentationTask; 25import java.lang.ref.WeakReference; 26import java.util.ArrayList; 27import java.util.Iterator; 28import java.util.List; 29 30/** 31 * Support for stack allocation of "value" objects. The only requirements for "value" 32 * objects is that they must have public zero argument constructor and <code>set</code> 33 * method with one argument of the same type (or superclass) which copies data from 34 * given instance.<p> 35 * 36 * <b>Example usage:</b> 37 * <pre> 38 * public static Vector3f average(Vector3f v1, Vector3f v2, Vector3f out) { 39 * out.add(v1, v2); 40 * out.scale(0.5f); 41 * return out; 42 * } 43 * 44 * public static void test() { 45 * Vector3f v1 = Stack.alloc(Vector3f.class); 46 * v1.set(0f, 1f, 2f); 47 * 48 * Vector3f v2 = Stack.alloc(v1); 49 * v2.x = 10f; 50 * 51 * Vector3f avg = average(v1, v2, Stack.alloc(Vector3f.class)); 52 * } 53 * </pre> 54 * which is transformed into something like the following code. The actual 55 * generated code has mangled names for unique type identification and can have 56 * other minor differences. 57 * <pre> 58 * public static void test() { 59 * $Stack stack = $Stack.get(); 60 * stack.pushVector3f(); 61 * try { 62 * Vector3f v1 = stack.getVector3f(); 63 * v1.set(0f, 1f, 2f); 64 * 65 * Vector3f v2 = stack.getVector3f(v1); 66 * v2.x = 10f; 67 * 68 * Vector3f avg = average(v1, v2, stack.getVector3f()); 69 * } 70 * finally { 71 * stack.popVector3f(); 72 * } 73 * } 74 * </pre> 75 * 76 * <b>Rules:</b> 77 * <ul> 78 * <li>classes needs to be instrumented by provided InstrumentationTask for ANT, otherwise 79 * error is throwed in runtime</li> 80 * <li>stack is pushed only once per method, do not use stack allocation in loops</li> 81 * <li>returning of stack allocated objects is not supported, use output parameter instead (like in the 82 * example)</li> 83 * <li>working with stack is thread-safe, the data are separate for each thread</li> 84 * <li>combining different libraries works fine, each must have their stack stored 85 * in different package, so you'll just end up with multiple stacks in final application, 86 * which is fine, because the values are used between them without problem 87 * <li>when creating and destroying threads you must be aware that the implementation 88 * uses ThreadLocal to persist stack instances between method calls, it's advisable 89 * to call <code>cleanCurrentThread</code> method on thread just before destroying 90 * </li> 91 * </ul> 92 * 93 * @author jezek2 94 */ 95public class Stack { 96 97 private static List<WeakReference<ThreadLocal>> threadLocalList = new ArrayList<WeakReference<ThreadLocal>>(); 98 99 private Stack() { 100 } 101 102 /** 103 * Returns stack allocated object.<p> 104 * 105 * Requires instrumentation of your classes in order to work. 106 * 107 * @param cls class type, must be compile-time constant 108 * @return stack allocated instance of given class 109 */ 110 public static <T> T alloc(Class<T> cls) { 111 throw new Error("not instrumented"); 112 } 113 114 /** 115 * Returns stack allocated object with copied value from given parameter.<p> 116 * 117 * Requires instrumentation of your classes in order to work. 118 * 119 * @param obj object to copy on stack, the type must be statically known 120 * @return stack allocated instance with copied data 121 */ 122 public static <T> T alloc(T obj) { 123 throw new Error("not instrumented"); 124 } 125 126 /** 127 * Used internally. 128 */ 129 public static synchronized void internalRegisterThreadLocal(ThreadLocal local) { 130 threadLocalList.add(new WeakReference<ThreadLocal>(local)); 131 } 132 133 /** 134 * Removes all cached stack instances for current thread. 135 */ 136 public static synchronized void cleanCurrentThread() { 137 for (Iterator<WeakReference<ThreadLocal>> it = threadLocalList.iterator(); it.hasNext(); ) { 138 WeakReference<ThreadLocal> ref = it.next(); 139 ThreadLocal local = ref.get(); 140 if (local != null) { 141 local.remove(); 142 } 143 else { 144 it.remove(); 145 } 146 } 147 } 148 149 /** 150 * Removes all cached stack instances for current thread in current library.<p> 151 * 152 * Requires instrumentation of your classes in order to work. 153 * 154 * @see InstrumentationTask#setIsolated(boolean) 155 */ 156 public static void libraryCleanCurrentThread() { 157 throw new Error("not instrumented"); 158 } 159 160} 161 162``` 163###試した解決方法 1641.上記のように 165 166ここを参考にインストールを行った。 167[https://www.ntu.edu.sg/home/ehchua/programming/game/BulletPhysics_JBullet.html](https://www.ntu.edu.sg/home/ehchua/programming/game/BulletPhysics_JBullet.html) 168 169Using jStackAllocはやれていない。これが原因の可能性あり。 170自分のAntの知識,xmlの知識が乏しく申し訳ありません。 171 1722.自分と全く同じ状況に陥った方のブログあったのでそこを参考にした。 173 174[https://ameblo.jp/guojia/theme-10051299279.html](https://ameblo.jp/guojia/theme-10051299279.html) 175 176如何せん、lwjglの画面表示されずコンソールにこれ表示された。 177``` 178world pos = 2.000000,9.991667,0.000000 179world pos = 0.000000,-56.000000,0.000000 180world pos = 2.000000,9.983334,0.000000 181world pos = 0.000000,-56.000000,0.000000 182world pos = 2.000000,9.972222,0.000000 183world pos = 0.000000,-56.000000,0.000000 184 185以下略 186``` 187 188 189 190###今回制作したプロジェクト 191[jbullet-Dropbox](https://www.dropbox.com/sh/pm6o0cjfcl4ltlq/AABmSM9uaAh3GfKjyY_L1kbea?dl=0) 192 193###補足情報(言語/FW/ツール等のバージョンなど) 194より詳細な情報 195cat /etc/os-release 196NAME="Linux Mint" 197VERSION="18.1 (Serena)" 198ID=linuxmint 199ID_LIKE=ubuntu 200 20132bit版のMintを使っています。 202 203 204Eclipse Java EE IDE for Web Developers. 205 206Version: Oxygen.1a Release (4.7.1a) 207 208java -version 209openjdk version "1.8.0_131" 210 211jbullet jbullet-20101010.zipから解凍してプロジェクトに投下した。 212 213###更新 214SSD(外付けHDDとかはない)上にはwindowsとかはのっていません。mintオンリーです。(2018/1/3 21:10)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/01/03 11:28

ゲストOSでホストOSにインストールしたものを利用しようとしている?
退会済みユーザー

退会済みユーザー

2018/01/03 11:29

ちなみにコードをアップするなら github がおすすめです。
K_Cpamp

2018/01/03 12:19 編集

依頼ありがとうございます。SSD(外付けHDDとかはない)上にはwindowsとかはのっていません。mintオンリーです。
K_Cpamp

2018/01/03 12:07

githubはアカウント登録したまま放置してます(笑)。頑張って勉強します。
guest

回答1

0

自己解決

自己解決をしたため報告させていただきます。

###解決方法

1.上記の"試した解決方法"の "2" の方法と同じように行う。
2.ant.jar(どこのタイミングでダウンロードしたか忘れました。)をダウンロードしてきてパスを通す。
3.今回は"com/bulletphysics/demos/helloworld/HelloWorld.java"を実行せず、"/com/bulletphysics/demos/vehicle/VehicleDemo.java"を実行した。

###結果
実行結果

###原因とその考察
今回の失敗の原因は、安直に"HelloWorld.java"をデモに使ったことでした。
"HelloWorld.java"をよく読んで見ると実行結果を表示させる"lwjgl"を使っていないことが判明した。なので他にもデモがあったのでそれを実行することにより上記の通り結果が表示され解決に至った。今回例のブログのコピペだったのでどうしてエラーの解決になったのか理解していないためこの後コードを読み理解していきたいと思います。

###最後に
今回始めてのteratailの質問でした。自己解決に至った時に自分の質問を読み直してみると実現してほしいことが書かれていましたが、具体的に何をしてほしいのか書かれておらず、自分から見てですが解答がしづらく若干丸投げ感があるように思えました。もう少し質問内容を吟味してから投稿するよう心がけたいと思います。最後になりましたが今回この質問を解決を試みた方々に感謝申し上げます。ありがとうございました。

投稿2018/01/04 04:19

編集2018/01/07 03:25
K_Cpamp

総合スコア6

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問