-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terrain support? #5
Comments
Thank's yes terrain this would be the top. |
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: and box-terrain code: EDIT: just found this triangle class: might be helpful 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 also add particule can be cool |
sphere terrain demo added :) |
@lo-th , 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... |
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
The text was updated successfully, but these errors were encountered: