Brijesh Posted July 18, 2017 Share Posted July 18, 2017 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. 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. Quote Link to comment Share on other sites More sharing options...
jerome Posted July 18, 2017 Share Posted July 18, 2017 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) Brijesh 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 19, 2017 Share Posted July 19, 2017 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. 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. Brijesh 1 Quote Link to comment Share on other sites More sharing options...
Brijesh Posted August 1, 2017 Author Share Posted August 1, 2017 Thanks @jerome and @Wingnut Finally i create a custom mesh using the vertex point and apply different color to vertex data point and i can able to solve my issue. Wingnut and GameMonetize 2 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.