Search the Community
Showing results for tags 'concave'.
Found 2 results
Containing Bubbles - Now with Added Concave Collisions
JohnK posted a topic in Demos and ProjectsJust having a play around with sps, wanted to see if I could come up with a simple collision system from scratch. Only designed to work with spheres. http://www.babylonjs-playground.com/#1C2HFL http://www.babylonjs-playground.com/#1C2HFL#1 less segments http://www.babylonjs-playground.com/#1C2HFL#2 Have a play around with number of particles, size of particles and max speed. Max speed should be less than radius, too big and the particles escape.
Intersecting Concave Meshes and Their Physics
JohnK posted a topic in Demos and ProjectsThe title might look impressive but there is a long way to go yet. I am playing around with the idea of colliding meshes that have concave parts to them and then reacting based on some physics that will use BabylonJS rather than a Physics Engine. "Why?" you may say - because it gives me something to do that I am interested in. So how far have I got? Not very far but have two things that appear to be working. I say appear as my testing is limited to two shapes which I have intersected in a couple of positions and it looks like it works. Be concerned be very concerned. The code makes extensive use of Jerome's work on facetData. 1. Finding the approximate points of impact of two meshes. http://www.babylonjs-playground.com/#XEJLM 2. Finding the center of mass of a mesh. (EDIT - Scroll down topic for playground version, following Jerome's advice) Demo http://grideasy.github.io/Babylon/com.html Code https://github.com/grideasy/grideasy.github.io/tree/master/Babylon Finding the approximate points of impact of two meshes. The basis to this is Find the overlap of the two meshes, one being the hitter and the other the hittee Split the overlap into 8 octants and recursively check each octant recursively as below until the octant is too small. Check if the hitter has any has any facets inside the current octant using the mid point of the overlap area to find the closest facet to it. If there is such a one project this onto the hittee (if such a projection exists). See if the two facets are close enough for impact, if so return the facet position from the hitter and the projected point from the hittee. If no two points are close enough split the current octant into 8 more octants and recursively repeat 2, 3, 4 and 5. If octants get too small and no hitter and hittee facets close enough return null. Finding the center of mass of a mesh. At some stage if the collision idea develops for more complex shapes the center of mass of the shape will be needed. In order to complete the code I had to add to Jerome's code within BJS version 2.6 itself and hence the code is in github not in the playground. As well as being able to get facetPositions and facetNormals I have added the capability to get facetAreas. To see these additions search for JK or facetAreas within the Babylon26JK.js code from the link given above. Warning Notes for Both Projects For speed the first two facets close enough are taken so may not actually be the best two facets to use. In calculating the center of mass for a mesh the mesh is assumed to be hollow and is based on the area of each facet, the density of each facet is assumed to be the same for all facets. I have not yet though about how to do it for a solid mesh (not that meshes are ever solid but perhaps calculations could be done as if they were solid). My coding is not particularly efficient and there are probably much better ways of achieving what I have done so far in terms of structure and use of existing BJS code but I am enjoying myself and if other want to join in make improvements then the more the merrier.