Jump to content

Project UV from Plane to Mesh, or like process.


Pryme8
 Share

Recommended Posts

https://www.babylonjs-playground.com/#NAG06Y#5

Ok, so I have my star shape which has all the vertices labeled, as you can see its UV is all sorts of messy.
What I am trying to do is figure out a simple way to get its UV to match the plane that is the "same size".

I know I can do it mathematically by the points points position in relation to the stars size and manually update the uv buffer.  Just wondering if anyone has a quick and easy trick otherwise.

I was thinking of writing up a "project UV plane"  function, where you pass in a mesh, a plane and a vector3 to signify the projection direction.
So like if the projection axis was Vector3(0,0,1) it would fire rays in this direction (and its inverse) from each of the target meshes vertices and check for a hit on the plane if it hits the plane update that points UV to match the raypicked point's uv.  Is this gibberish or anyone savvy?
 

Link to comment
Share on other sites

Never mind got it... Unless someone else already has a more robust method.

https://www.babylonjs-playground.com/#NAG06Y#6
https://www.babylonjs-playground.com/#NAG06Y#8 <- Non flat projection.

https://www.babylonjs-playground.com/#NAG06Y#18 <- one with skipTo and stopAt for vertices ID in case you only want to project a section of a mesh.

Link to comment
Share on other sites

I was kinda thinking about making this a 
BABYLON.Mesh.projectMeshUV method or something.

Could see others having a use for this, but I'm not sure if I have the time to debug and dev it to a full method... so Ill hold off and maybe write a snippet instead. 

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