JackFalcon Posted October 26, 2017 Share Posted October 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted October 26, 2017 Author Share Posted October 26, 2017 SOLVED: https://www.babylonjs-playground.com/#PGIYP3 Solution involves some pixel-trickery (with Canvas2D): - pick - pickResult.getTextureCoordinates() - MixMap.png initialized into Canvas2D to calculate the RGB at coordinate - calculate coordinate = RGB By evaluating the RGB it can be determined what surface we are on. Anyone know a better way? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 26, 2017 Share Posted October 26, 2017 This is how I would have done it JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted November 7, 2017 Author Share Posted November 7, 2017 Thank you @Deltakosh the solution is cool! For others googlers, here is the way to get (inferrred) rgb meta data from mix map pixel luminosity! if (pickInfo.hit) { let uv = pickInfo.getTextureCoordinates(); let pixel = getImageDataPixelAtUV(impactImageData, uv.x, uv.y); //THIS PIXEL gives you color of the Point on the MixMap, so greatest of RGB numbers is the material on the map. } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.