Java port of Bullet

guiramos
Posts: 11
Joined: Fri Dec 18, 2009 7:19 pm

Re: Java port of Bullet

Post by guiramos » Wed Feb 22, 2012 6:07 pm

Hey guys...
Back to action...

I am studying forces because I need to create a automated flying object like a quadricopter.
He need to receive an external forces and react correctly to then.

So let's begin with a easy context.

With a given cube with a 1Kg of weight how can I implement a force to make him actualy fly?

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Java port of Bullet

Post by xexuxjy » Wed Feb 29, 2012 8:44 am

If anyones still having problems getting this to run in eclipse due to instrumentation errors I've created a simple eclispe project that has an automatic instrumenter build step so you can build and run it in eclipse without any further messing around. I've put it here for now :

http://code.google.com/p/bullet-xna/dow ... p&can=2&q=

Any questions/problems please let me know.

nico3000
Posts: 1
Joined: Sun Dec 30, 2012 1:46 pm

Re: Java port of Bullet

Post by nico3000 » Sun Dec 30, 2012 1:54 pm

Hi,

I don't manage to use JBullet in my NetBeans project. I created a new Ant Library, added dist/jbullet.jar, lib/vecmath/vecmath.jar and lib/jstackalloc/jstackalloc.jar to the classpath and added it to my Porject (Java Application), but everytime I run the project I get

Code: Select all

Exception in thread "main" java.lang.Error: not instrumented
	at cz.advel.stack.Stack.alloc(Stack.java:122)
	at com.bulletphysics.linearmath.Transform.mul(Transform.java:105)
	at com.bulletphysics.linearmath.DefaultMotionState.getWorldTransform(DefaultMotionState.java:74)
	at com.bulletphysics.dynamics.RigidBody.setupRigidBody(RigidBody.java:147)
	at com.bulletphysics.dynamics.RigidBody.<init>(RigidBody.java:111)
	at main.PhysicsLayer.init(PhysicsLayer.java:78)
	at main.GameApp.init(GameApp.java:51)
	at main.Main.main(Main.java:12)
Java Result: 1
I also tried to open and use the JBullet NetBeans project contained in the zip file within my Project. But I get the same result. What am I doing wrong?

(I use http://jbullet.advel.cz/download/jbullet-20101010.zip)

Edit: Strange... I deleted the nbproject folder from the contents of the the zip file and now it works.

deepthought
Posts: 3
Joined: Mon Apr 29, 2013 6:26 pm

Re: Java port of Bullet

Post by deepthought » Mon Apr 29, 2013 6:31 pm

@jezek2:you should port the soft-body stuff

laadams85
Posts: 18
Joined: Wed May 22, 2013 1:45 pm

Re: Java port of Bullet

Post by laadams85 » Wed May 22, 2013 2:02 pm

I've been working on my own 2D port of bullet physics in java, mostly shamelessly taking from the work of jezek to get a working implementation. I have run into an interesting case where the physics solver is adding a fictitious torque. I have a small box/square landing on a larger box/square. It looks like the smaller box is bouncing and rotating off of the larger box. I have tried this with both my implementation and jezek's with similar results. Where can I look for some way to solve this problem. It seems to me that I need to add additional contact points into the manifold, but I'm not sure where. Any ideas would be appreciated.

Test Code:

Code: Select all

    public static void main(String[] args) {
        CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
        CollisionDispatcher dispatcher = new CollisionDispatcher(
                collisionConfiguration);
        Vector3f worldAabbMin = new Vector3f(-10000, -10000, -10000);
        Vector3f worldAabbMax = new Vector3f(10000, 10000, 10000);
        int maxProxies = 1024;
        BroadphaseInterface overlappingPairCache = new DbvtBroadphase();
        SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();
        DiscreteDynamicsWorld dynamicsWorld = new DiscreteDynamicsWorld(
                dispatcher, overlappingPairCache, solver,
                collisionConfiguration);

        dynamicsWorld.setGravity(new Vector3f(0, -10, 0));
        CollisionShape groundShape = new BoxShape(new Vector3f(50.f, 50.f, 50.f));
        ObjectArrayList<CollisionShape> collisionShapes = new ObjectArrayList<CollisionShape>();
        collisionShapes.add(groundShape);
        Transform groundTransform = new Transform();
        groundTransform.setIdentity();
        groundTransform.origin.set(new Vector3f(0.f, -56.f, 0.f));
        {
            float mass = 0f;
            boolean isDynamic = (mass != 0f);
            Vector3f localInertia = new Vector3f(0, 0, 0);
            if (isDynamic) {
                groundShape.calculateLocalInertia(mass, localInertia);
            }
            DefaultMotionState myMotionState = new DefaultMotionState(groundTransform);
            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
                    mass, myMotionState, groundShape, localInertia);
            RigidBody body = new RigidBody(rbInfo);


            dynamicsWorld.addRigidBody(body);
        }
        {        
            CollisionShape colShape = new BoxShape(new Vector3f(5,5,5));
            collisionShapes.add(colShape);
            Transform startTransform = new Transform();
            startTransform.setIdentity();
            float mass = 1f;
            boolean isDynamic = (mass != 0f);
            Vector3f localInertia = new Vector3f(0, 0, 0);
            if (isDynamic) {
                colShape.calculateLocalInertia(mass, localInertia);
            }
            startTransform.origin.set(new Vector3f(25, 140, 0));
            DefaultMotionState myMotionState = new DefaultMotionState(startTransform);
            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
                    mass, myMotionState, colShape, localInertia);
            RigidBody body = new RigidBody(rbInfo);
            dynamicsWorld.addRigidBody(body);
        }
        for (int i = 0; i < 2000; i++) {
            dynamicsWorld.stepSimulation(1.f / 60.f, 10);
            CollisionObject obj = dynamicsWorld.getCollisionObjectArray().getQuick(1);
            RigidBody body = RigidBody.upcast(obj);
            Transform trans = new Transform();
            body.getMotionState().getWorldTransform(trans);
            System.out.printf("%d world pos = %f,%f,%f\n", i, trans.origin.x, trans.origin.y, trans.origin.z);
        }
    }
Results:

Code: Select all

0 world pos = 25.000000,139.991669,0.000000
1 world pos = 25.000000,139.983337,0.000000
2 world pos = 25.000000,139.972229,0.000000
3 world pos = 25.000000,139.958344,0.000000
4 world pos = 25.000000,139.941681,0.000000
5 world pos = 25.000000,139.922241,0.000000
6 world pos = 25.000000,139.900024,0.000000
7 world pos = 25.000000,139.875031,0.000000
8 world pos = 25.000000,139.847260,0.000000
9 world pos = 25.000000,139.816711,0.000000
10 world pos = 25.000000,139.783371,0.000000
11 world pos = 25.000000,139.747253,0.000000
12 world pos = 25.000000,139.708359,0.000000
13 world pos = 25.000000,139.666687,0.000000
14 world pos = 25.000000,139.622238,0.000000
15 world pos = 25.000000,139.575012,0.000000
16 world pos = 25.000000,139.525009,0.000000
17 world pos = 25.000000,139.472229,0.000000
18 world pos = 25.000000,139.416672,0.000000
19 world pos = 25.000000,139.358337,0.000000
20 world pos = 25.000000,139.297226,0.000000
21 world pos = 25.000000,139.233337,0.000000
22 world pos = 25.000000,139.166672,0.000000
23 world pos = 25.000000,139.097229,0.000000
24 world pos = 25.000000,139.025009,0.000000
25 world pos = 25.000000,138.950012,0.000000
26 world pos = 25.000000,138.872238,0.000000
27 world pos = 25.000000,138.791687,0.000000
28 world pos = 25.000000,138.708359,0.000000
29 world pos = 25.000000,138.622253,0.000000
30 world pos = 25.000000,138.533371,0.000000
31 world pos = 25.000000,138.441711,0.000000
32 world pos = 25.000000,138.347260,0.000000
33 world pos = 25.000000,138.250031,0.000000
34 world pos = 25.000000,138.150024,0.000000
35 world pos = 25.000000,138.047241,0.000000
36 world pos = 25.000000,137.941681,0.000000
37 world pos = 25.000000,137.833344,0.000000
38 world pos = 25.000000,137.722229,0.000000
39 world pos = 25.000000,137.608337,0.000000
40 world pos = 25.000000,137.491669,0.000000
41 world pos = 25.000000,137.372223,0.000000
42 world pos = 25.000000,137.250000,0.000000
43 world pos = 25.000000,137.125000,0.000000
44 world pos = 25.000000,136.997223,0.000000
45 world pos = 25.000000,136.866669,0.000000
46 world pos = 25.000000,136.733337,0.000000
47 world pos = 25.000000,136.597229,0.000000
48 world pos = 25.000000,136.458344,0.000000
49 world pos = 25.000000,136.316681,0.000000
50 world pos = 25.000000,136.172241,0.000000
51 world pos = 25.000000,136.025024,0.000000
52 world pos = 25.000000,135.875031,0.000000
53 world pos = 25.000000,135.722260,0.000000
54 world pos = 25.000000,135.566711,0.000000
55 world pos = 25.000000,135.408371,0.000000
56 world pos = 25.000000,135.247253,0.000000
57 world pos = 25.000000,135.083359,0.000000
58 world pos = 25.000000,134.916687,0.000000
59 world pos = 25.000000,134.747238,0.000000
60 world pos = 25.000000,134.575012,0.000000
61 world pos = 25.000000,134.400009,0.000000
62 world pos = 25.000000,134.222229,0.000000
63 world pos = 25.000000,134.041672,0.000000
64 world pos = 25.000000,133.858337,0.000000
65 world pos = 25.000000,133.672226,0.000000
66 world pos = 25.000000,133.483337,0.000000
67 world pos = 25.000000,133.291672,0.000000
68 world pos = 25.000000,133.097229,0.000000
69 world pos = 25.000000,132.900009,0.000000
70 world pos = 25.000000,132.700012,0.000000
71 world pos = 25.000000,132.497238,0.000000
72 world pos = 25.000000,132.291687,0.000000
73 world pos = 25.000000,132.083359,0.000000
74 world pos = 25.000000,131.872253,0.000000
75 world pos = 25.000000,131.658371,0.000000
76 world pos = 25.000000,131.441711,0.000000
77 world pos = 25.000000,131.222260,0.000000
78 world pos = 25.000000,131.000031,0.000000
79 world pos = 25.000000,130.775024,0.000000
80 world pos = 25.000000,130.547241,0.000000
81 world pos = 25.000000,130.316681,0.000000
82 world pos = 25.000000,130.083344,0.000000
83 world pos = 25.000000,129.847229,0.000000
84 world pos = 25.000000,129.608337,0.000000
85 world pos = 25.000000,129.366669,0.000000
86 world pos = 25.000000,129.122223,0.000000
87 world pos = 25.000000,128.875000,0.000000
88 world pos = 25.000000,128.625000,0.000000
89 world pos = 25.000000,128.372223,0.000000
90 world pos = 25.000000,128.116669,0.000000
91 world pos = 25.000000,127.858337,0.000000
92 world pos = 25.000000,127.597229,0.000000
93 world pos = 25.000000,127.333344,0.000000
94 world pos = 25.000000,127.066673,0.000000
95 world pos = 25.000000,126.797226,0.000000
96 world pos = 25.000000,126.525002,0.000000
97 world pos = 25.000000,126.250000,0.000000
98 world pos = 25.000000,125.972221,0.000000
99 world pos = 25.000000,125.691666,0.000000
100 world pos = 25.000000,125.408333,0.000000
101 world pos = 25.000000,125.122223,0.000000
102 world pos = 25.000000,124.833336,0.000000
103 world pos = 25.000000,124.541672,0.000000
104 world pos = 25.000000,124.247231,0.000000
105 world pos = 25.000000,123.950005,0.000000
106 world pos = 25.000000,123.650002,0.000000
107 world pos = 25.000000,123.347221,0.000000
108 world pos = 25.000000,123.041664,0.000000
109 world pos = 25.000000,122.733330,0.000000
110 world pos = 25.000000,122.422218,0.000000
111 world pos = 25.000000,122.108330,0.000000
112 world pos = 25.000000,121.791664,0.000000
113 world pos = 25.000000,121.472221,0.000000
114 world pos = 25.000000,121.150002,0.000000
115 world pos = 25.000000,120.825005,0.000000
116 world pos = 25.000000,120.497231,0.000000
117 world pos = 25.000000,120.166672,0.000000
118 world pos = 25.000000,119.833336,0.000000
119 world pos = 25.000000,119.497223,0.000000
120 world pos = 25.000000,119.158333,0.000000
121 world pos = 25.000000,118.816666,0.000000
122 world pos = 25.000000,118.472221,0.000000
123 world pos = 25.000000,118.125000,0.000000
124 world pos = 25.000000,117.775002,0.000000
125 world pos = 25.000000,117.422226,0.000000
126 world pos = 25.000000,117.066673,0.000000
127 world pos = 25.000000,116.708344,0.000000
128 world pos = 25.000000,116.347229,0.000000
129 world pos = 25.000000,115.983337,0.000000
130 world pos = 25.000000,115.616669,0.000000
131 world pos = 25.000000,115.247223,0.000000
132 world pos = 25.000000,114.875000,0.000000
133 world pos = 25.000000,114.500000,0.000000
134 world pos = 25.000000,114.122223,0.000000
135 world pos = 25.000000,113.741669,0.000000
136 world pos = 25.000000,113.358337,0.000000
137 world pos = 25.000000,112.972229,0.000000
138 world pos = 25.000000,112.583344,0.000000
139 world pos = 25.000000,112.191681,0.000000
140 world pos = 25.000000,111.797234,0.000000
141 world pos = 25.000000,111.400009,0.000000
142 world pos = 25.000000,111.000008,0.000000
143 world pos = 25.000000,110.597229,0.000000
144 world pos = 25.000000,110.191673,0.000000
145 world pos = 25.000000,109.783340,0.000000
146 world pos = 25.000000,109.372231,0.000000
147 world pos = 25.000000,108.958344,0.000000
148 world pos = 25.000000,108.541679,0.000000
149 world pos = 25.000000,108.122238,0.000000
150 world pos = 25.000000,107.700020,0.000000
151 world pos = 25.000000,107.275017,0.000000
152 world pos = 25.000000,106.847237,0.000000
153 world pos = 25.000000,106.416679,0.000000
154 world pos = 25.000000,105.983345,0.000000
155 world pos = 25.000000,105.547234,0.000000
156 world pos = 25.000000,105.108345,0.000000
157 world pos = 25.000000,104.666679,0.000000
158 world pos = 25.000000,104.222237,0.000000
159 world pos = 25.000000,103.775017,0.000000
160 world pos = 25.000000,103.325020,0.000000
161 world pos = 25.000000,102.872246,0.000000
162 world pos = 25.000000,102.416687,0.000000
163 world pos = 25.000000,101.958351,0.000000
164 world pos = 25.000000,101.497238,0.000000
165 world pos = 25.000000,101.033348,0.000000
166 world pos = 25.000000,100.566681,0.000000
167 world pos = 25.000000,100.097237,0.000000
168 world pos = 25.000000,99.625015,0.000000
169 world pos = 25.000000,99.150017,0.000000
170 world pos = 25.000000,98.672241,0.000000
171 world pos = 25.000000,98.191689,0.000000
172 world pos = 25.000000,97.708359,0.000000
173 world pos = 25.000000,97.222252,0.000000
174 world pos = 25.000000,96.733360,0.000000
175 world pos = 25.000000,96.241692,0.000000
176 world pos = 25.000000,95.747246,0.000000
177 world pos = 25.000000,95.250023,0.000000
178 world pos = 25.000000,94.750023,0.000000
179 world pos = 25.000000,94.247246,0.000000
180 world pos = 25.000000,93.741692,0.000000
181 world pos = 25.000000,93.233360,0.000000
182 world pos = 25.000000,92.722252,0.000000
183 world pos = 25.000000,92.208366,0.000000
184 world pos = 25.000000,91.691704,0.000000
185 world pos = 25.000000,91.172256,0.000000
186 world pos = 25.000000,90.650032,0.000000
187 world pos = 25.000000,90.125031,0.000000
188 world pos = 25.000000,89.597252,0.000000
189 world pos = 25.000000,89.066696,0.000000
190 world pos = 25.000000,88.533363,0.000000
191 world pos = 25.000000,87.997253,0.000000
192 world pos = 25.000000,87.458366,0.000000
193 world pos = 25.000000,86.916702,0.000000
194 world pos = 25.000000,86.372261,0.000000
195 world pos = 25.000000,85.825043,0.000000
196 world pos = 25.000000,85.275040,0.000000
197 world pos = 25.000000,84.722260,0.000000
198 world pos = 25.000000,84.166702,0.000000
199 world pos = 25.000000,83.608368,0.000000
200 world pos = 25.000000,83.047256,0.000000
201 world pos = 25.000000,82.483368,0.000000
202 world pos = 25.000000,81.916702,0.000000
203 world pos = 25.000000,81.347260,0.000000
204 world pos = 25.000000,80.775040,0.000000
205 world pos = 25.000000,80.200043,0.000000
206 world pos = 25.000000,79.622269,0.000000
207 world pos = 25.000000,79.041710,0.000000
208 world pos = 25.000000,78.458374,0.000000
209 world pos = 25.000000,77.872261,0.000000
210 world pos = 25.000000,77.283371,0.000000
211 world pos = 25.000000,76.691704,0.000000
212 world pos = 25.000000,76.097260,0.000000
213 world pos = 25.000000,75.500038,0.000000
214 world pos = 25.000000,74.900040,0.000000
215 world pos = 25.000000,74.297264,0.000000
216 world pos = 25.000000,73.691711,0.000000
217 world pos = 25.000000,73.083382,0.000000
218 world pos = 25.000000,72.472267,0.000000
219 world pos = 25.000000,71.858376,0.000000
220 world pos = 25.000000,71.241707,0.000000
221 world pos = 25.000000,70.622261,0.000000
222 world pos = 25.000000,70.000038,0.000000
223 world pos = 25.000000,69.375038,0.000000
224 world pos = 25.000000,68.747261,0.000000
225 world pos = 25.000000,68.116707,0.000000
226 world pos = 25.000000,67.483376,0.000000
227 world pos = 25.000000,66.847267,0.000000
228 world pos = 25.000000,66.208382,0.000000
229 world pos = 25.000000,65.566711,0.000000
230 world pos = 25.000000,64.922264,0.000000
231 world pos = 25.000000,64.275040,0.000000
232 world pos = 25.000000,63.625038,0.000000
233 world pos = 25.000000,62.972260,0.000000
234 world pos = 25.000000,62.316704,0.000000
235 world pos = 25.000000,61.658371,0.000000
236 world pos = 25.000000,60.997261,0.000000
237 world pos = 25.000000,60.333370,0.000000
238 world pos = 25.000000,59.666702,0.000000
239 world pos = 25.000000,58.997257,0.000000
240 world pos = 25.000000,58.325035,0.000000
241 world pos = 25.000000,57.650036,0.000000
242 world pos = 25.000000,56.972260,0.000000
243 world pos = 25.000000,56.291702,0.000000
244 world pos = 25.000000,55.608368,0.000000
245 world pos = 25.000000,54.922256,0.000000
246 world pos = 25.000000,54.233368,0.000000
247 world pos = 25.000000,53.541702,0.000000
248 world pos = 25.000000,52.847256,0.000000
249 world pos = 25.000000,52.150032,0.000000
250 world pos = 25.000000,51.450031,0.000000
251 world pos = 25.000000,50.747253,0.000000
252 world pos = 25.000000,50.041698,0.000000
253 world pos = 25.000000,49.333366,0.000000
254 world pos = 25.000000,48.622253,0.000000
255 world pos = 25.000000,47.908363,0.000000
256 world pos = 25.000000,47.191696,0.000000
257 world pos = 25.000000,46.472252,0.000000
258 world pos = 25.000000,45.750031,0.000000
259 world pos = 25.000000,45.025028,0.000000
260 world pos = 25.000000,44.297249,0.000000
261 world pos = 25.000000,43.566692,0.000000
262 world pos = 25.000000,42.833359,0.000000
263 world pos = 25.000000,42.097248,0.000000
264 world pos = 25.000000,41.358360,0.000000
265 world pos = 25.000000,40.616692,0.000000
266 world pos = 25.000000,39.872246,0.000000
267 world pos = 25.000000,39.125023,0.000000
268 world pos = 25.000000,38.375023,0.000000
269 world pos = 25.000000,37.622246,0.000000
270 world pos = 25.000000,36.866688,0.000000
271 world pos = 25.000000,36.108353,0.000000
272 world pos = 25.000000,35.347240,0.000000
273 world pos = 25.000000,34.583351,0.000000
274 world pos = 25.000000,33.816685,0.000000
275 world pos = 25.000000,33.047237,0.000000
276 world pos = 25.000000,32.275013,0.000000
277 world pos = 25.000000,31.500011,0.000000
278 world pos = 25.000000,30.722233,0.000000
279 world pos = 25.000000,29.941677,0.000000
280 world pos = 25.000000,29.158342,0.000000
281 world pos = 25.000000,28.372231,0.000000
282 world pos = 25.000000,27.583340,0.000000
283 world pos = 25.000000,26.791672,0.000000
284 world pos = 25.000000,25.997227,0.000000
285 world pos = 25.000000,25.200003,0.000000
286 world pos = 25.000000,24.400002,0.000000
287 world pos = 25.000000,23.597223,0.000000
288 world pos = 25.000000,22.791666,0.000000
289 world pos = 25.000000,21.983332,0.000000
290 world pos = 25.000000,21.172218,0.000000
291 world pos = 25.000000,20.358328,0.000000
292 world pos = 25.000000,19.541660,0.000000
293 world pos = 25.000000,18.722214,0.000000
294 world pos = 25.000000,17.899990,0.000000
295 world pos = 25.000000,17.074989,0.000000
296 world pos = 25.000000,16.247210,0.000000
297 world pos = 25.000000,15.416653,0.000000
298 world pos = 25.000000,14.583318,0.000000
299 world pos = 25.000000,13.747205,0.000000
300 world pos = 25.000000,12.908315,0.000000
301 world pos = 25.000000,12.066647,0.000000
302 world pos = 25.000000,11.222200,0.000000
303 world pos = 25.000000,10.374976,0.000000
304 world pos = 25.000000,9.524975,0.000000
305 world pos = 25.000000,8.672195,0.000000
306 world pos = 25.000000,7.816638,0.000000
307 world pos = 25.000000,6.958303,0.000000
308 world pos = 25.000000,6.097190,0.000000
309 world pos = 25.000000,5.233299,0.000000
310 world pos = 25.000000,4.366631,0.000000
311 world pos = 25.000000,3.497185,0.000000
312 world pos = 25.000000,2.624961,0.000000
313 world pos = 25.000000,1.749959,0.000000
314 world pos = 25.000000,0.872179,0.000000
315 world pos = 25.000000,-0.008378,0.000000
316 world pos = 25.000000,-0.891714,0.000000
317 world pos = 25.000000,-1.777827,0.000000
318 world pos = 25.253389,-1.737478,0.000030
319 world pos = 25.361975,-1.442513,0.047405
320 world pos = 25.504345,-1.150326,0.094568
321 world pos = 25.646715,-0.860917,0.141731
322 world pos = 25.789085,-0.574285,0.188894
323 world pos = 25.931456,-0.290431,0.236057
324 world pos = 26.073826,-0.009355,0.283220
325 world pos = 26.216196,0.268943,0.330383
326 world pos = 26.358566,0.544464,0.377546
327 world pos = 26.500937,0.817207,0.424710
328 world pos = 26.643307,1.087172,0.471873
329 world pos = 26.785677,1.354359,0.519036
330 world pos = 26.928047,1.618768,0.566199
331 world pos = 27.070417,1.880400,0.613362
332 world pos = 27.212788,2.139254,0.660525
333 world pos = 27.355158,2.395330,0.707688
334 world pos = 27.497528,2.648628,0.754851
335 world pos = 27.639898,2.899149,0.802014
336 world pos = 27.782269,3.146892,0.849177
337 world pos = 27.924639,3.391857,0.896340
338 world pos = 28.067009,3.634044,0.943503
339 world pos = 28.209379,3.873453,0.990666
340 world pos = 28.351749,4.110085,1.037829
341 world pos = 28.494120,4.343939,1.084992
342 world pos = 28.636490,4.575015,1.132155
343 world pos = 28.778860,4.803313,1.179318
344 world pos = 28.921230,5.028834,1.226481
345 world pos = 29.063601,5.251576,1.273644
346 world pos = 29.205971,5.471541,1.320807
347 world pos = 29.348341,5.688728,1.367970
348 world pos = 29.490711,5.903138,1.415133
349 world pos = 29.633081,6.114769,1.462296
350 world pos = 29.775452,6.323623,1.509459
351 world pos = 29.917822,6.529699,1.556622
352 world pos = 30.060192,6.732997,1.603785
353 world pos = 30.202562,6.933518,1.650948
354 world pos = 30.344933,7.131260,1.698111
355 world pos = 30.487303,7.326225,1.745274
356 world pos = 30.629673,7.518413,1.792437
357 world pos = 30.772043,7.707822,1.839600
358 world pos = 30.914413,7.894454,1.886763
359 world pos = 31.056784,8.078307,1.933926
360 world pos = 31.199154,8.259383,1.981089
361 world pos = 31.341524,8.437681,2.028252
362 world pos = 31.483894,8.613201,2.075415
363 world pos = 31.626265,8.785944,2.122578
364 world pos = 31.768635,8.955909,2.169741
365 world pos = 31.911005,9.123096,2.216904
366 world pos = 32.053375,9.287505,2.264067
367 world pos = 32.195747,9.449137,2.311230
368 world pos = 32.338120,9.607990,2.358393
369 world pos = 32.480492,9.764066,2.405556
370 world pos = 32.622864,9.917364,2.452719
371 world pos = 32.765236,10.067884,2.499882
372 world pos = 32.907608,10.215627,2.547045
373 world pos = 33.049980,10.360592,2.594208
374 world pos = 33.192352,10.502779,2.641371
375 world pos = 33.334724,10.642188,2.688534
376 world pos = 33.477097,10.778819,2.735697
377 world pos = 33.619469,10.912673,2.782860
378 world pos = 33.761841,11.043749,2.830023
379 world pos = 33.904213,11.172047,2.877186
380 world pos = 34.046585,11.297567,2.924349
381 world pos = 34.188957,11.420310,2.971512
382 world pos = 34.331329,11.540275,3.018675
383 world pos = 34.473701,11.657461,3.065838
384 world pos = 34.616074,11.771871,3.113001
385 world pos = 34.758446,11.883502,3.160164
386 world pos = 34.900818,11.992355,3.207327
387 world pos = 35.043190,12.098432,3.254490
388 world pos = 35.185562,12.201730,3.301653
389 world pos = 35.327934,12.302250,3.348816
390 world pos = 35.470306,12.399993,3.395979
391 world pos = 35.612679,12.494958,3.443142
392 world pos = 35.755051,12.587145,3.490305
393 world pos = 35.897423,12.676554,3.537468
394 world pos = 36.039795,12.763186,3.584631
395 world pos = 36.182167,12.847039,3.631794
396 world pos = 36.324539,12.928115,3.678957
397 world pos = 36.466911,13.006413,3.726120
398 world pos = 36.609283,13.081934,3.773283
399 world pos = 36.751656,13.154676,3.820446
400 world pos = 36.894028,13.224641,3.867609
401 world pos = 37.036400,13.291828,3.914772
402 world pos = 37.178772,13.356237,3.961935
403 world pos = 37.321144,13.417869,4.009099
404 world pos = 37.463516,13.476723,4.056262
405 world pos = 37.605888,13.532799,4.103425
406 world pos = 37.748260,13.586097,4.150588
407 world pos = 37.890633,13.636617,4.197751
408 world pos = 38.033005,13.684360,4.244914
409 world pos = 38.175377,13.729324,4.292077
410 world pos = 38.317749,13.771511,4.339240
411 world pos = 38.460121,13.810921,4.386403
412 world pos = 38.602493,13.847552,4.433566
413 world pos = 38.744865,13.881406,4.480729
414 world pos = 38.887238,13.912481,4.527892
415 world pos = 39.029610,13.940780,4.575055
416 world pos = 39.171982,13.966300,4.622218
417 world pos = 39.314354,13.989042,4.669381
418 world pos = 39.456726,14.009007,4.716544
419 world pos = 39.599098,14.026195,4.763707
420 world pos = 39.741470,14.040604,4.810870
421 world pos = 39.883842,14.052235,4.858033
422 world pos = 40.026215,14.061089,4.905196
423 world pos = 40.168587,14.067164,4.952359
424 world pos = 40.310959,14.070462,4.999522
425 world pos = 40.453331,14.070983,5.046685
426 world pos = 40.595703,14.068726,5.093848
427 world pos = 40.738075,14.063690,5.141011
428 world pos = 40.880447,14.055878,5.188174
429 world pos = 41.022820,14.045287,5.235337
430 world pos = 41.165192,14.031919,5.282500
431 world pos = 41.307564,14.015772,5.329663
432 world pos = 41.449936,13.996848,5.376826
433 world pos = 41.592308,13.975146,5.423989
434 world pos = 41.734680,13.950666,5.471152
435 world pos = 41.877052,13.923409,5.518315
436 world pos = 42.019424,13.893374,5.565478
437 world pos = 42.161797,13.860561,5.612641
438 world pos = 42.304169,13.824970,5.659804
439 world pos = 42.446541,13.786602,5.706967
440 world pos = 42.588913,13.745456,5.754130
441 world pos = 42.731285,13.701531,5.801293
442 world pos = 42.873657,13.654830,5.848456
443 world pos = 43.016029,13.605350,5.895619
444 world pos = 43.158401,13.553093,5.942782
445 world pos = 43.300774,13.498057,5.989945
446 world pos = 43.443146,13.440245,6.037108
447 world pos = 43.585518,13.379654,6.084271
448 world pos = 43.727890,13.316285,6.131434
449 world pos = 43.870262,13.250139,6.178597
450 world pos = 44.012634,13.181215,6.225760
451 world pos = 44.155006,13.109513,6.272923
452 world pos = 44.297379,13.035033,6.320086
453 world pos = 44.439751,12.957776,6.367249
454 world pos = 44.582123,12.877741,6.414412
455 world pos = 44.724495,12.794928,6.461575
456 world pos = 44.866867,12.709337,6.508738
457 world pos = 45.009239,12.620969,6.555901
458 world pos = 45.151611,12.529822,6.603064
459 world pos = 45.293983,12.435898,6.650227
460 world pos = 45.436356,12.339196,6.697390
461 world pos = 45.578728,12.239717,6.744553
462 world pos = 45.721100,12.137459,6.791716
463 world pos = 45.863472,12.032424,6.838879
464 world pos = 46.005844,11.924611,6.886042
465 world pos = 46.148216,11.814020,6.933205
466 world pos = 46.290588,11.700652,6.980368
467 world pos = 46.432961,11.584506,7.027531
468 world pos = 46.575333,11.465582,7.074694
469 world pos = 46.717705,11.343880,7.121857
470 world pos = 46.860077,11.219400,7.169020
471 world pos = 47.002449,11.092143,7.216183
472 world pos = 47.144821,10.962108,7.263346
473 world pos = 47.287193,10.829295,7.310509
474 world pos = 47.429565,10.693705,7.357672
475 world pos = 47.571938,10.555336,7.404835
476 world pos = 47.714310,10.414189,7.451998
477 world pos = 47.856682,10.270266,7.499161
478 world pos = 47.999054,10.123564,7.546324
479 world pos = 48.141426,9.974084,7.593487
480 world pos = 48.283798,9.821827,7.640650
481 world pos = 48.426170,9.666792,7.687813
482 world pos = 48.568542,9.508979,7.734976
483 world pos = 48.710915,9.348388,7.782139
484 world pos = 48.853287,9.185019,7.829302
485 world pos = 48.995659,9.018873,7.876465
486 world pos = 49.138031,8.849949,7.923628
487 world pos = 49.280403,8.678247,7.970791
488 world pos = 49.422775,8.503768,8.017955
489 world pos = 49.565147,8.326510,8.065118
490 world pos = 49.707520,8.146475,8.112281
491 world pos = 49.849892,7.963662,8.159444
492 world pos = 49.992264,7.778071,8.206607
493 world pos = 50.134636,7.589702,8.253770
494 world pos = 50.277008,7.398556,8.300933
495 world pos = 50.419380,7.204632,8.348096
496 world pos = 50.561752,7.007930,8.395259
497 world pos = 50.704124,6.808450,8.442422
498 world pos = 50.846497,6.606193,8.489585
499 world pos = 50.988869,6.401157,8.536748
500 world pos = 51.131241,6.193344,8.583911
You can see that the x and y positions are increasing and they shouldn't, x should stay around 25.00 and y should converge on -1.0.

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Java port of Bullet

Post by xexuxjy » Thu May 23, 2013 10:01 am

Have you tried doing the same thing in the standard c++ bullet library to see if it also behaves oddly? I did a port to c#/xna and comparing the outputs between 'the same' demo on the c++ and c# versions was often very helpful at tracking stuff down.

laadams85
Posts: 18
Joined: Wed May 22, 2013 1:45 pm

Re: Java port of Bullet

Post by laadams85 » Thu May 23, 2013 12:12 pm

That's next on my things to do, I have to get a compiler first. I anybody else could test it, it's a pretty simple test just 2 boxes, that'd be great.

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Java port of Bullet

Post by xexuxjy » Thu May 23, 2013 1:56 pm

If i get chance I'll have a play tonight and see if I can get the c++ version output for comparison.

laadams85
Posts: 18
Joined: Wed May 22, 2013 1:45 pm

Re: Java port of Bullet

Post by laadams85 » Thu May 23, 2013 8:02 pm

I'm getting a slightly better result by creating a more full manifold, but the small box is still jumpy. My guess is that the over penetration is too large and is creating a large impulse.

laadams85
Posts: 18
Joined: Wed May 22, 2013 1:45 pm

Re: Java port of Bullet

Post by laadams85 » Thu May 30, 2013 1:22 pm

I was able to get much better results by porting over the latest bullet version of the sequential impulse solver. I still get some bounce but no more fictitious torques. I'll continue to work on eliminating the extra bounce.

laadams85
Posts: 18
Joined: Wed May 22, 2013 1:45 pm

Re: Java port of Bullet

Post by laadams85 » Fri May 31, 2013 4:02 pm

If I use a ConvexHullShape instead of a box, I get similar results from the original bullet_physics library. I get a little bit of bounce and the box starts moving to the right. So apart from the sequential impulse solve in JBullet being out of date is also doesn't implement the BoxBoxAlgorithm, which the c++ library does which gives better performance. At some point the ConvexConvexAlgorithm needs to do culling so that the results of it and the BoxBoxAlgorithm are essentially equal.

liyixinhua
Posts: 3
Joined: Thu Jun 27, 2013 6:04 pm

Re: Java port of Bullet

Post by liyixinhua » Thu Jun 27, 2013 6:50 pm

Hi,
I am new to jBullet and I am trying to run the demos. But I get the following error:Exception in thread "main" java.lang.UnsatisfiedLinkError: jbullet\jbullet-20101010\lib\lwjgl\win32\lwjgl.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform.
The problem is that I use windows 64bit. Does anyone know how to solve this?
Solve: I downloaded the old version of lwjgl(version 2.2.2) and it works.
Thanks anyway.

Xenos
Posts: 3
Joined: Tue Nov 27, 2012 5:54 am

Re: Java port of Bullet

Post by Xenos » Tue Jul 23, 2013 7:59 am

Hello,
I am currently trying to understand JBullet's collision detection.
From my current view, bullet engine should already be using the collision detection to apply forces between bodies when a collision happens.
I assume there should be some collision-event-caller where I can add (subscribe) some custom listener (event handler).
So, if I want to add some event (e.g print a note to the screen) at the collision moment, I can just add a 'listener' to that object.
But I really have no idea which object is which (for collision event).

Please correct me if I'm wrong on those assumptions.
People say JBullet can be used to detect collision, but how should I utilize it?
Can someone provide a simple collision detection example?
I have this simple code (I modified the example a bit) :

Code: Select all

package Main_Pkg;

import com.bulletphysics.collision.broadphase.AxisSweep3;
import com.bulletphysics.collision.dispatch.CollisionConfiguration;
import com.bulletphysics.collision.dispatch.CollisionDispatcher;
import com.bulletphysics.collision.dispatch.CollisionObject;
import com.bulletphysics.collision.dispatch.DefaultCollisionConfiguration;
import com.bulletphysics.collision.shapes.BoxShape;
import com.bulletphysics.collision.shapes.CollisionShape;
import com.bulletphysics.collision.shapes.SphereShape;
import com.bulletphysics.dynamics.DiscreteDynamicsWorld;
import com.bulletphysics.dynamics.RigidBody;
import com.bulletphysics.dynamics.RigidBodyConstructionInfo;
import com.bulletphysics.dynamics.constraintsolver.SequentialImpulseConstraintSolver;
import com.bulletphysics.linearmath.DefaultMotionState;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.util.ObjectArrayList;
import java.util.Timer;
import java.util.TimerTask;
import javax.vecmath.Vector3f;

public class Test {

    static DiscreteDynamicsWorld dynamicsWorld;
    static CollisionShape groundShape;
    ObjectArrayList<CollisionShape> collisionShapes;

    public Test() {
        
        
        CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();

        CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);

        Vector3f worldAabbMin = new Vector3f(-10000, -10000, -10000);
        Vector3f worldAabbMax = new Vector3f(10000, 10000, 10000);
        int maxProxies = 1024;
        AxisSweep3 overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax, maxProxies);
        
        SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();

        dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);

        dynamicsWorld.setGravity(new Vector3f(0, -10, 0));

        groundShape = new BoxShape(new Vector3f(500.f, 50.f, 500.f));

        collisionShapes = new ObjectArrayList<CollisionShape>();

        collisionShapes.add(groundShape);

        Transform groundTransform = new Transform();
        groundTransform.setIdentity();
        groundTransform.origin.set(new Vector3f(0.f, -50.f, 0.f));

        {
            //Ground
            float mass = 0f;

            boolean isDynamic = (mass != 0f);

            Vector3f localInertia = new Vector3f(0, 0, 0);
            if (isDynamic) {
                    groundShape.calculateLocalInertia(mass, localInertia);
            }

            DefaultMotionState myMotionState = new DefaultMotionState(groundTransform);
            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
                            mass, myMotionState, groundShape, localInertia);
            RigidBody body = new RigidBody(rbInfo);

            dynamicsWorld.addRigidBody(body);
        }
        
        
        {
            //Body 1
            Vector3f box_dim = new Vector3f(10f, 10f, 10f);
            CollisionShape colShape = new BoxShape(box_dim);
            collisionShapes.add(colShape);

            Transform startTransform = new Transform();
            startTransform.setIdentity();

            float mass = 100;

            boolean isDynamic = (mass != 0f);

            Vector3f localInertia = new Vector3f(0, 0, 0);
            if (isDynamic) {
                    colShape.calculateLocalInertia(mass, localInertia);
            }

            startTransform.origin.set(new Vector3f(0, 200, 0));

            DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
            RigidBody body = new RigidBody(rbInfo);
            
            dynamicsWorld.addRigidBody(body);
            
            
            Vector3f force = new Vector3f(0, 700000, 0);
            Vector3f relative_pos = new Vector3f(0, 0, 0);
            body.applyForce(force, relative_pos);
        }
        
        {
            //Body 2
            CollisionShape colShape = new SphereShape(20);
            collisionShapes.add(colShape);

            // Create Dynamic Objects
            Transform startTransform = new Transform();
            startTransform.setIdentity();

            float mass = 100;

            // rigidbody is dynamic if and only if mass is non zero,
            // otherwise static
            boolean isDynamic = (mass != 0f);

            Vector3f localInertia = new Vector3f(0, 0, 0);
            if (isDynamic) {
                    colShape.calculateLocalInertia(mass, localInertia);
            }

            startTransform.origin.set(new Vector3f(0, 400, 0));

            // using motionstate is recommended, it provides
            // interpolation capabilities, and only synchronizes
            // 'active' objects
            DefaultMotionState myMotionState = new DefaultMotionState(startTransform);

            RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
            RigidBody body = new RigidBody(rbInfo);
            
            dynamicsWorld.addRigidBody(body);
        }
    }
    
    public void update_10ms() {
        Test.dynamicsWorld.stepSimulation(0.01f, 0);
        CollisionObject obj = dynamicsWorld.getCollisionObjectArray().getQuick(2);
        RigidBody body = RigidBody.upcast(obj);
        /*******Draw each body*******/
    }
    
    
    public static void main(String[] args) {
        final Test test_obj = new Test();
        
        Timer updater = new Timer();
        updater.schedule(new TimerTask() {
            @Override
            public void run() {
                test_obj.update_10ms();
            }
        }, 0, 10);
    }
}
That code have two dynamic bodies. Body 1 (a box) is located at y=200 with initial 'push' upward. Body 2 (a sphere) is located at y = 400. Those two bodies will collide each other mid air and then fall (and hit each other again at ground).
Can someone modify that code to make a simple example?
(Just use println to notify when an object hits another object or hits the ground.)

I've looked around and found no example code for the java port.

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Java port of Bullet

Post by xexuxjy » Tue Jul 23, 2013 10:14 pm

I think what you need to use is the BulletGlobals.gContactAddedCallback . You can extend the ContactAddedCallback class and get a notification of when a contact point is added to a maniforld (which is really whats happening when a collision occurs).

Whiteclaws
Posts: 1
Joined: Wed Sep 25, 2013 1:17 am

Setting the Position of a Collision Object

Post by Whiteclaws » Wed Sep 25, 2013 1:22 am

Hello there , fine gentlemens of knowledge and experience !

Newbie here , I'm looking to find a way to set the position (x,y,z) of a CollisionObject , that is by default , 0,0,0 , Any help is appreciated !

Have a nice day ! :wink:

Post Reply