Author Topic: Physics example  (Read 37572 times)

Offline AeroShark333

  • float
  • ****
  • Posts: 319
    • View Profile
Re: Physics example
« Reply #15 on: April 25, 2021, 08:56:16 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


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Physics example
« Reply #16 on: April 26, 2021, 01:57:47 pm »
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.

Offline aleks1283

  • byte
  • *
  • Posts: 49
    • View Profile
Re: Physics example
« Reply #17 on: April 28, 2021, 12:26:45 am »
Thanks. Is there an alternative to jbullet but not slow?

Offline AeroShark333

  • float
  • ****
  • Posts: 319
    • View Profile
Re: Physics example
« Reply #18 on: April 28, 2021, 12:36:57 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..?)

Offline aleks1283

  • byte
  • *
  • Posts: 49
    • View Profile
Re: Physics example
« Reply #19 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.

Offline AeroShark333

  • float
  • ****
  • Posts: 319
    • View Profile
Re: Physics example
« Reply #20 on: April 30, 2021, 06:27:54 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...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Physics example
« Reply #21 on: May 01, 2021, 01:08:13 pm »
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...).

Offline aleks1283

  • byte
  • *
  • Posts: 49
    • View Profile
Re: Physics example
« Reply #22 on: May 13, 2021, 06:39:08 am »
Thanks Egon :)

Offline aleks1283

  • byte
  • *
  • Posts: 49
    • View Profile
Re: Physics example
« Reply #23 on: May 21, 2021, 02:14:13 pm »
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 .

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Physics example
« Reply #24 on: May 21, 2021, 02:55:12 pm »
I'm not sure what you mean by "cover with clothing"!?

Offline aleks1283

  • byte
  • *
  • Posts: 49
    • View Profile
Re: Physics example
« Reply #25 on: May 21, 2021, 06:15:50 pm »
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.


Offline aleks1283

  • byte
  • *
  • Posts: 49
    • View Profile
Re: Physics example
« Reply #26 on: May 21, 2021, 10:10:26 pm »
So that the mesh stretches when moving parts of the human body

Offline aleks1283

  • byte
  • *
  • Posts: 49
    • View Profile
Re: Physics example
« Reply #27 on: May 21, 2021, 10:33:00 pm »
and apply a texture to the mesh

Offline AeroShark333

  • float
  • ****
  • Posts: 319
    • View Profile
Re: Physics example
« Reply #28 on: May 22, 2021, 12:12:17 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Physics example
« Reply #29 on: May 22, 2021, 12:52:29 pm »
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...).