Open erichlof opened 10 years ago
Thank's yes terrain this would be the top. Saharan think of it for next release of OimoPhysics. For the moment no triangle shape but is possible for sure. I try to add this but if someone finds an idea I take
Hi, that's great that Saharan wants to add it. I just might put an issue on his original repo and maybe I can help get the process started.
As for doing it on your own, there are numerous ray-triangle intersection tests out there (Three.js already has one in place). I'm pretty sure we could get a sphere to work, using the sphere's old center position as one end of a line segment and it's current position as the other end of the line segment. But the box is more difficult because of numerous edges and possible orientations. I don't really know how to do that.
A good place to look for ideas on terrain shape is here: https://github.com/bartdeboer/JigLibJS2/blob/master/geometry/JTerrain.js
and here for sphere-terrain collision code: https://github.com/bartdeboer/JigLibJS2/blob/master/collision/CollDetectSphereTerrain.js
and box-terrain code: https://github.com/bartdeboer/JigLibJS2/blob/master/collision/CollDetectBoxTerrain.js
EDIT: just found this triangle class: might be helpful https://github.com/bartdeboer/JigLibJS2/blob/master/geometry/JTriangle.js
JigLibJS2 is also a good physics library, but unfortunately it is not in active development, both original and ports. There are some bugs in this engine I think but I don't know how to fix them.
Anyway, thanks for the info. I will contact Saharan and see what's happening with his terrain implementation. I have starred your repo and I look forward to what's coming next with Oimo!
Thanks!
hum i think test sphere terrain for the moment oimo can manage 1000 dynamique sphere i hop more when fixed
also add particule can be cool
sphere terrain demo added :)
@lo-th , Thank you so much for implementing this! It works great across all of my very different devices - old Windows XP desktop, 'newer' Windows 7 laptop, and even my Samsung Galaxy smartphone!
How did you end up implementing this? How does the internal terrain collision algorithm work? Are you using object (falling boxes' or balls')ray-triangle intersect test for each triangle of the terrain, or falling object's bounding sphere/ bounding box vs. terrain bounding sphere for each triangle of the terrain?
Regardless, this is a great addition to the already awesome Oimo engine - Thanks again! :)
thank's, i use sphere collision, each vertex of terrain mesh have one sphere. box take many more calculation. is limited 64*64 sphere is good. Triangle can be the best option but i have to make some research about.
@lo-th Hello, I've looked at your sphere terrain demo, but i didn't understand the concept... Could you make a wiki page, or add some useful comments in tour code? I've made the same thing, but without physics (here) and i would like to add physics to it. Could you please help me (just give me a few explainations if you don't have much time😉) and give me a sort of "example code" ? Excuse me, this issue is very old😃... Thanks...
Hi @lo-th First, thank you for putting in the effort to port this awesome physics engine! I will definitely be using this as my go-to physics engine for Three.js games.
I have some ideas for games that require terrain-shape support. I would like to put in a feature request to add a terrain class. Do you know this engine well enough to add it yourself, or, if not, do you think the original author would be able to add it?
I guess what would be needed is a simple 2-d array of vertex points that form a grid in the x-z plane. The number of width (x) and depth (z) would be supplied by the developer. Then, for each point a height value (y) is given by the developer. This is where my knowledge gets thin. I'm supposing a series of triangles would have to be made, storing a normal for each triangle. Then, somehow every triangle would have to be tested against all spheres and/or boxes in the scene (using the existing sphere-plane and box-plane routines?) Then the intersection point would have to be tested to be inside the triangle. Finally, an impulse is added to the sphere/box like it would be for a plane, or floor (which is already a part of this engine).
Please let me know what you are willing/able to do with this request. I could try to do one myself, but I don't see any point-in-triangle routines in the library as of yet.
Again, thanks for this wonderful project! :) -Erich