Physics example

Started by Thomas., March 10, 2012, 10:29:28 PM

Previous topic - Next topic

AeroShark333

Quote from: aleks1283 on April 25, 2021, 08:04:05 PM
Quote from: Thomas. on February 23, 2013, 02:28:42 PM
Sources in first post was updated. Zip contains optimized jBullet lib (thanks EgonOlsen for tips! ;)), adjusted vecmath lib and sources of PhysicsTest app. On my SGS3 physics calculations of 9 boxes take about 37ms with original libs and 29ms with optimized ones. It is almost 30% speed up, it is not much for my app, but maybe it can help to someone.
Hello Thomas,give please link of source code jpct-ae+jbullet,link in top not work.

I believe the Dropbox links have died since the post is from years ago.
I once experimented with jBullet too... but the performance was too poor for my likings I believe.
Though, I might still have the jBullet version that was originally posted here somewhere on my computer.
I can try to look for it if you're really interested...

Otherwise, maybe this will help:
https://www.jpct.net/forum2/index.php?topic=1509.0


EgonOlsen

This should be the code Thomas. released back then: https://jpct.de/download/example/PhysicsTest.zip

Please note: I've just zipped my project directory. It might contain a lot of unneeded stuff and was created for an Android-SDK from ages ago. That said, it still compiled, uploaded and worked fine for me.

aleks1283

Thanks. Is there an alternative to jbullet but not slow?

AeroShark333

Quote from: aleks1283 on April 28, 2021, 12:26:45 AM
Thanks. Is there an alternative to jbullet but not slow?
I believe there's jMonkeyEngine... (which can work without jPCT as well..)
But I'm not sure how well it works together with jPCT.

An alternative is probably to decompile jBullet and optimize it somehow... (making it multithreaded or something..?)

aleks1283

Well, if I understand correctly, threads do not add speed on devices, but only transfer work to the background.

AeroShark333

Quote from: aleks1283 on April 28, 2021, 08:25:23 AM
Well, if I understand correctly, threads do not add speed on devices, but only transfer work to the background.
I'm not entirely sure about this...
I believe you could off-load some heavy physics calculations on a seperate thread than the GL-thread.
When heavy calculations are done in the GL-thread, you might suffer from lower FPS due to reduced draw(...) call rates.
I think this might especially give speed boosts on multi-core processor devices (nearly all devices nowadays) which would handle multithreading better.
Though, making sure the threads are synced and working well together might be more complex...
jPCT(-AE)/OpenGL(ES) isn't entirely multi-thread friendly as far as I know.

Maybe @EgonOlsen knows more about this...

EgonOlsen

The "old" purpose of multiple threads is indeed to do slow IO operations in the background. But nowadays, given that all processors have multiple cores/threads (the machine I'm writing this on can handle 24 threads in parallel, for example), it also very common to use multiple threads for calculations.
That said, it's not easy to use multiple threads for physics, because the result of one thread's calculation can have an impact on the other. Imagine 8 boxes colliding with each other. If you calculate each box in it's own thread, the outcome of one would depend on the collisions of all the others, which is almost impossible to synchronize properly.
jPCT(-AE) itself isn't thread safe (but you could do calculations on independant objects or tasks in multiple threads) and neither is OpenGL(ES). If you want to use multi-threading in one way or the other, you have to make sure that the tasks that are processed by the different threads are independant (for example: One thread for physics, one for sound, one for path finding...).

aleks1283


aleks1283

Hello Egon and Everybody.)
Is it possible to use standard jpct-ae functions to somehow cover two different objects with common skin or clothing? I want to apply this to physical modeling with sutavas .

EgonOlsen

I'm not sure what you mean by "cover with clothing"!?

aleks1283

Well, there is a model of a person, let's say, made up of cylinders. And at the junctions of these cylinders, you can see that these are separate cylinders. Is it possible to cover the human figure with some kind of mesh so that the person becomes like a single figure but with moving arms and legsneck ...?
Smooth transition between.


aleks1283

So that the mesh stretches when moving parts of the human body

aleks1283

and apply a texture to the mesh

AeroShark333

I believe you would want the 'joints' to appear smoothly visually?

I guess you could try this: https://github.com/raftAtGit/Bones
(see also: https://www.jpct.net/forum2/index.php/board,10.0.html)

I am not entirely sure how it works but I believe you'd need one complete mesh of the person (including arms, legs, etc.)
And somehow define the body parts using the library

EgonOlsen

I see. There's no functionality that does this automatically. You have to model it that or come up with some algorithm to do it (which won't be trivial...).