Jump to content

Apply some color or different texture to tube part that is out of boundary.


Brijesh
 Share

Recommended Posts

Hi everyone,

I create a tube mesh, and i update this tube mesh after some interval, i apply some diffuse texture and color to tube.

Now i have some boundary, when i update a tube and some portion of tube is out of that boundary than i want to differentiate that portion of tube by applying some different texture or change color of only that portion of a tube. Is it possible when i use only one tube ?? Can i apply some color or texture to some part of tube different than other part??

I attach here one image for visually clear my issue.

tubeImg.png.3464bed71bb47b11f413157902722f93.png

As shown in image i create one tube, and circle is show boundary when some portion of tube is out of boundary i want to change its color or apply some different texture to that portion of tube.

Please, help me to come out from this one.

 

 

Link to comment
Share on other sites

The tube is simply a ribbon-based geometry and, although it seems the class documentation is not up to date for now (coming soon), the ribbon vertex colors can be updated at any time (when set as updatable) with the new "colors" parameter : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.meshBuilder.ts#L131

BTW, this is the same for UVs (texturing) : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.meshBuilder.ts#L130

For now, this parameter isn't yet ported to the tube constructor, but it's planned to be (again something more in my endless to-do list)

Link to comment
Share on other sites

Yuh, yuh, yuh.  Good answer, J, but... gruesome.

Sorry to butt-in, but, there's another way, Captain Brijesh.

The fake.  :)  (I love visual trickery, it makes me smile.)

Use a 2nd tube.  The 2nd tube doesn't exist until 1st tube intersects border.  Then start lying.  :)

The 2nd tube (outside-of-border tube) has it's pivotMatrix/origin set to the border (at intersect point).  Its size and rotation matches the 1st tube, but 2nd.scaling will determine how far the 2nd tube will "protrude" outside-of the border (the 2nd tube's length).  Increasing the scaling will make the 2nd tube increase protrusion... because its origin is set to range border.

In the example picture, the green tube is the 2nd (duh) and its origin/pivot is set fully left, where green tube meets border.  Scale green tube to increase protrusion amount.  Origin will stay in-position at border (left side of green tube).

Cheating.  Just one function...  var faketube = generateFakeProtrudedTube(tubeToExtend, whichDirectionAndMagnitude);  :)  Devious, we are.  heh. 

"Purists" are gagging and shaking their heads in disapproval, at this point. :D

There might be one other cheat... depending upon what is needed.  A spotlight/shadowMap.  The "circle" might be a spotlight-circle, or its inverted shadowMap, or something similar.  You won't be able to get a different TEXTURE for inside/outside, but you can surely get the material COLORS to change (when any part of the tube exits the spotlight circle). 

Our lights have arrays to determine WHICH mesh are affected/not by that light, which could be useful.  The question might be... CAN our shadowGenerators generate other-than-black shadows/s-maps?  Can we have yellow shadows, or other colors that actually increase the brightness of mesh material... when a shadow is cast-upon it?  (in-shade mesh are actually brighter, not darker).  :)  Demented ideas from Wingy... ignore at will.

Link to comment
Share on other sites

  • 2 weeks later...

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