Jump to content

Terrain - RayCast - Facet Data - MixMap?


JackFalcon
 Share

Recommended Posts

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

 

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

  • 2 weeks later...

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.
        }

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...