Search the Community
Showing results for tags 'intersect'.
-
Hello, I'm developing my first application with pixi.js 4 and I have a problem with collision between sprites. In my case I use textures with irregular shapes and logically I'm able to intercept collision between rectangular sprites (using Bump library). I need instead to check collision between irregular shapes as attached example. Is there a way to create an impostor shape attached to sprite in order to have this result? Thanks for now and sorry for my bad english. Vittorio
-
Hello, Raycast TerrainMap and get MixMap %'s? CONTEXT: Raycast over a Terrain Map... and determine the type of terrain (floor, rock, grass, etc) where the Ray Intersects mesh. Looking at Mixed-Map-Materials and Facet-Data... QUESTION: is there a way, to get the MixMap through a Raycast Intersection? Or any suggestions on detecting floor, rock, grass... thx. Kind regards, UPDATE: using this playground, stepping into raycast... http://www.babylonjs-playground.com/#7CPS7 Found: results[0].pickedMesh, pickedPoint, collisionGroup, looking around... : ) .subMeshes.materialIndex?... DEMO-TEST: fork Multi-Map playground and add the touch raycast. : ) Worked perfectly - Clickable Multi Map playground (debugger on cast): https://www.babylonjs-playground.com/#E6OZX#7 looking around... AbstactMesh.collisionGroup? faceId? UPDATE: idea of how to do this, need to get the mixmap.png rgb at the location of the getTextureCoordinates()...greatest intensity wins. And... looks like Context2D can do that... (perhaps) https://www.babylonjs-playground.com/#1UCP5L#5
-
The 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.
- 2 replies
-
- center of mass
- concave
-
(and 3 more)
Tagged with:
-
Hi, I'm starting with Phaser + Isometric plugin and is pretty cool. I think it has what I need for now, but now I'm stuck with some tests... I'm trying to detect when a srpite is hidden by another sprite in the isometric map. Something similar to? https://phaser.io/examples/v2/sprites/overlap-without-physics I tried with intersects without results, I think this is because colliding avoid intersections. I tried also with overlap, but I have results only when collides, and I want to know it without colliding. Scene A: Blue cube is not colliding but has a hidden part because of isometric ordering. That is what I need to detect. Scene B: Blue cube is not hidden on any part, so I don't mind... Any ideas? Thank you all in advance!
-
I am new to babylon and am creating a space game based on gravity and mesh intersection. Basically, my game states are being managing and determined based on if a ship mesh is intersecting with a destination or obstacle mesh. Looks something like this: scene.registerBeforeRender(function() { if (ship.canvasObject.intersectsMesh(canvasObjects[0].canvasObject, true)) { ship.material.emissiveColor = new BABYLON.Color3(0, 1, 0); PubSub.publish('COLLISION EVENT', 'collided') } for(var i = 1; i < canvasObjects.length; i ++){ if (ship.canvasObject.intersectsMesh(canvasObjects.canvasObject, true)) { ship.material.emissiveColor = new BABYLON.Color3(1, 0, 0); PubSub.publish('COLLISION EVENT', 'collided with other stuffs') } } Where ship is a prototype. When the page loads, it says that the meshes are already intersecting once, then they stop intersecting, and then they intersect again. The positions of each are (-20, 1, -20) and (25, 1, 25). I feel like there's something simple-ish here that I'm missing and I've gone through all the docs but can't figure it out. Any help appreciated!
-
For my project I form a model from a number of meshes (which may not be adjoining) by assigning them the same parent and forming a bounding container around them. I then check to see if two different models are in contact by first using intersectsMesh on the two bounding containers and if true checking to see if any of the meshes from model A are in contact with any of the meshes from model B and only in this case putting contact of models to be true. Would this be possible be merging the meshes to form a model instead and if so would it be any more efficient.. A playground example is here http://www.babylonjs-playground.com/#1XNAP4#1 When box1, box2 and box3 are merged into box and cube1, cube2 and cube3 into cube it appears I lose access to the original meshes. What I would like to do is when cube intersects with box I want to check if boxes 1, 2 or 3 are in contact with any of cubes 1, 2 or 3. In the case of cube.position = new BABYLON.Vector3(-9, 3, 0);I need a function that returns false and in the case of cube.position = new BABYLON.Vector3(-12, 3, 0);the function should return true.
-
I am using the Actions Manager and am trying to use the OnIntersectionEnterTrigger on a (child) mesh that has a parent, but seems to be firing on the parent mesh? Is this the right behavior? The mesh I would like for it to fire on is smaller than the overall parent mesh. Thanks.
-
Hello. Is it possible? I need to check if one cube touches a side (face) of another cube (it should be exactly its side/polygon, not just a single point). Off-topic: What's "isInFrustrum(frustumPlanes)"?
- 2 replies
-
- intersect
- intersects
-
(and 4 more)
Tagged with: