###前提・実現したいこと
物理エンジン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)
回答1件
あなたの回答
tips
プレビュー