How to implement path deformation in babylonjs

My translator gives this exactly:

this is
The first image is based on the path and the deformation
The second image is the text according to the deformation of the path
The third image loads the distortion of the model

3 are the effect

Thank you for your patience

Anyone done FFD boxes in 3DsMax?

For those who are FFD noobs, FFD boxes are like putting the model into a cardboard box. Then you can stretch and smash the cardboard, and the model will somewhat follow the box-shape.

The 3rd pictureā€¦ the green cork screwā€¦ could be ā€œbentā€ that wayā€¦ with an FFD box with MANY linear subdivisionsā€¦ surrounding the cork screw. (3dsMax allows you to set ANY number of sections/slices on FFD boxes)

The model itselfā€¦ must ALSO have many subdivisionsā€¦ in order to get a smooth bend.

FFD boxesā€¦ and also the 3dsMax pathDeform that DataAngel is showing to us in his first pictureā€¦ are vertices ā€œpullersā€ and ā€œpushersā€. Positional vert warper. I think they COULD BE similar to our ā€œweightedVerticesā€.

But, doesnā€™t BJS require a skeleton/bones armatureā€¦ before a model can use weightedVertices? I think so.

Does it NEED to? Can we activate weighted verticesā€¦ based upon a path? The model would still need high subdivisionsā€¦ to bend along smooth curves. But instead of attaching weightedVerts to bones, can we, instead, attached them to a path (path points)?

If the path has many steps/pointsā€¦ each step could be used as a push/pull attachment-pointā€¦ for weightedVerts of the model.

Anyway, Iā€™m shooting in the darkā€¦ because I know SO LITTLE about weightedVerticesā€¦ but I know a little bit about 3dMax FFD boxes, which are a type of deform. I used them to make curvy aero-dynamic cowlings for snowmobile models. I also used them to make fishing lure models. Theyā€™re fun!

Just possibly, thereā€™s a whole new world aheadā€¦ for BJS weightedVertices. (or maybe not) :slight_smile:

This is correct but we could think about a dynamic way of adding skin info to a mesh. But this will require some work and this is definitely not available out of the box

1 Like

@dataangel After talking to @PatrickRyan it sounds like using node animations and skinning might be the easiest way to do this.

If you can setup your mesh with node/skinning animation see: Babylon.js Documentation . You can then place it on a surface by picking the surface with a ray (scene.pickWithRay) and then update the bone position and orient with the collided normal.

Hopefully this makes sense and translates well :crossed_fingers:

Hi tDev. I forgot about the collision.

So, itā€™s obvious, that the cork screw drank all the booze in the bottle, and passed-out laying against the bottle.

The ray-picking you speak-ofā€¦ is for real-time path-plot determination? The model ā€œsensesā€ whatever it needs to contour its path-toā€¦ and the path bendsā€¦ based upon massive ā€œdistance measuringā€ operations?

Wow! HARD! I was ONLY thinking that the programmer manually-plotted the path. I was NOT thinking about model determining its needed bendsā€¦ from sensor arraysā€¦ real time. OMG!

Javascript, look out! TrevorDev and PatRyanā€¦ are out to HURT you. RUN! :slight_smile:

3 Likes

ē­‰å¾…你们ēš„å„½ę¶ˆęÆ

dataangel: ā€œWaiting for your good newsā€

wingnut: ęŗåø¦é£Ÿē‰©å’Œę°“怂åÆčƒ½ę¼«é•æēš„ē­‰å¾…ć€‚éžåøø困难ēš„čæ‡ēØ‹ć€‚ä¹Ÿč®ø超å‡ŗäŗ†ę”†ęž¶ēš„čŒƒå›“怂

Eng: Carry food and water. Possible long wait. Very difficult process. Perhaps beyond scope of framework.

(Sorry, but truthful. Wingnut gives whiskey and hug. Stay tuned for more comments, maybe.)

ē¬¬äø€å¼ å›¾ēš„ę•ˆęžœ
https://www.babylonjs-playground.com/#RF9W9#570
ē¬¬äŗŒå¼ å›¾å’Œē¬¬äø‰å¼ å›¾ęˆ‘实åœØęƒ³äøå‡ŗ实ēŽ°ēš„ę–¹ę³•

1 Like

From Google Translate
The effect of the first picture
https://www.babylonjs-playground.com/#RF9W9#570
The second picture and the third picture, I really canā€™t think of the way to achieve it.

My Interpretation (?)
I have achieved the effect I need for the first picture.

I really canā€™t think of a way to:

  1. make text follow a path,
  2. bend a mesh by distorting an line through the mesh so that it follows a given path
1 Like

My congratulations on solving your first problem. Very well done.

ē„č“ŗä½ č§£å†³ē¬¬äø€äøŖé—®é¢˜ć€‚ 做得å¤Ŗ儽äŗ†ć€‚

I thinkā€¦ meshWriter fonts COULD be told to position and rotate (orient), based-upon a curvy path.

https://www.babylonjs-playground.com/#XWVXN9#63 (no curved paths there, just a demo of meshWriter fonts)

BUT, the flat surfaces of the font-shapesā€¦ with NOT bend (warp/morph) to match the spline curve.

Hereā€™s another PG, and a bad attempt at ā€œorientingā€ meshWriter fontsā€¦ around a circle. https://www.babylonjs-playground.com/#XWVXN9#69

Text on a rotating wheelā€¦ is a yet-to-be-adopted way of reading text in a 3D scene. Essentially, it is a curved text scrollerā€¦ but it has brakes and throttleā€¦ to set scroll-speed (read speed). Or, should we say ā€œroll speedā€ in the case of text-on-a-wheel. :slight_smile: When reading text in 3D, it is often not plausible to have an entire paragraph of high-polycount font-meshā€¦ on-screen at the same time. Often, text is flown-into and out-of the sceneā€¦ at an adjustable reading-rate.

Thatā€™s future stuff. I was lucky enough to live a life in the future, before I started THIS life, so I have seen some future stuff. (You donā€™t really BELIEVE that, do you?) :slight_smile:

@JohnK - you made the sine-wave PG? (itā€™s nice, btw). Would you (or anyone) consider trying a playground versionā€¦ to make meshWriter SPS-based fontsā€¦ follow (orient-to) a curvy path? Start with the above-mentioned PGā€™s that I did, perhaps?

I also have a need to make sentences follow a path thru a sceneā€¦ for making it nicer to get kids to (learn to) read. I want to make a nice forest scene where user can sit on a stump, and watch/read sentences that come into view along a forest path, and then leave again. A bit like nature-watching, only we do sentence-watching. :slight_smile:

Perhapsā€¦ we need an optionā€¦ allow z-rotation true/false. This would determine if the fonts ALWAYS were perfectly upright, or whether they z-rot when climbing/descending path ā€œhillsā€. Keep in mind that a meshWriter font/word/sentenceā€¦ has a natural orientationā€¦ of laying flat on its back, on the ground. See me ā€œtip-upā€ the fonts from their natural orientationā€¦ in the #63 playground.

All kids/people read at different speeds, so a throttle and brake button nearbyā€¦ would be handy scrolling-speed controls. Here is another mesh-oriented-to-path demo. https://www.babylonjs-playground.com/#92EYG#30

It has problems with some box ā€œflip-overā€ at a certain point in the path. Also, the path-start and path-end do not perfectly align/meet, so there is some odd wiggle, there. All in all, this is the type of ā€œorient mesh to pathā€ that I am speaking-of (usable with meshWriter fonts), and again, @dataangelā€¦ it does not ā€œbendā€ the font-shapes. It can ONLY ā€œorientā€ the flat-faced fonts ALONG a curved path.

[shrug]. Just sharing what I know. Perhaps someone can ā€œrun with itā€ to make it all more useful, and possibly get a work-around solution to picture #2. Thanks everyone. Sorry for the long post.

No that was @dataangel 's own work.

1 Like

https://www.babylonjs-playground.com/#BWZWXP

This playground shows 2D text following a path.

ę­¤ē¤ŗä¾‹ę˜¾ē¤ŗč·Æ径后ēš„2Dę–‡ęœ¬

5 Likes

:slight_smile: Sneaky. No thickness, though. Picture #2 fonts have z-depth. But you DO have bends on the fonts themselves. Cool. Dynamic Textureā€¦ sureā€¦ good idea.

Can anyone tellā€¦ if the ā€œmā€ in ā€œPath Deformā€ (picture #2) is bent/curved? It sort of LOOKS bent/curved, but I canā€™t tell for sure. The other fonts donā€™t look bent at all.

I think that is an orientation-path-follow (un-bent fonts), and not a morph-path-follow (bent fonts).

Wingnut makes-up terminology, because heā€™s clueless to the CORRECT terminology, if there IS any. :slight_smile:

Thanks, though, JohnK. Nice demo. Wibbly Wobbly Words. heh. Alright!

1 Like

good idea.

Update to @Wingnut 's playground for vertical letters https://www.babylonjs-playground.com/#XWVXN9#71

3 Likes

Wicked 2D bendy text, JohnK!

I believe that having the letters follow a not-straight path is not ā€œouta this worldā€. Making individual letters curvy is, at a minimum, outa my world.

To the former point: I go to some effort to make each glyph (letter) its own mesh; there is a matching array for glyph positions. The last step, when creating an SPS, positions each letter. See code snippet nearby ā€“ the last few lines: positionParticle. This could potentially be made more complex than it is now. Now, it just does basic kerning.

Not obvious to me is how the curve is communicated into MeshWriter. The other alternative, as you have already discovered, is to position individual particles after the fact.

Hope this adds some value.

//  ~  -  =  ~  -  =  ~  -  =  ~  -  =  ~  -  =  ~  -  =  ~  -  =
// MakeSPS turns the output of constructLetterPolygons into an SPS
// with the whole string, with appropriate offsets
function makeSPS(scene,meshesAndBoxes,material){
  var meshes                 = meshesAndBoxes[0],
      lettersOrigins         = meshesAndBoxes[2],sps,spsMesh;
  if(meshes.length){
    sps                      = new BABYLON.SolidParticleSystem("sps"+"test",scene, { } );
    meshes.forEach(function(mesh,ix){
      sps.addShape(mesh, 1, {positionFunction: makePositionParticle(lettersOrigins[ix])});
      mesh.dispose()
    });
    spsMesh                  = sps.buildMesh();
    spsMesh.material         = material;
    sps.setParticles()
  }
  return [sps,spsMesh];

  function makePositionParticle(letterOrigins){
    return function positionParticle(particle,ix,s){
      particle.position.x    = letterOrigins[0]+letterOrigins[1];
      particle.position.z    = letterOrigins[2]
    }
  }
};

Thx @TheLeftover! (Heā€™s the author of MeshWriter, for those who donā€™t know). @jerome is the author of Solid Particle System (SPS), which MeshWriter uses to get some of its display-work done.

In MY ā€œsuper-pathā€ hopes and dreams, rotation and scale are just as pertinent as position.

I want to get long-winded and wander off-topic, so join me here for the long versionā€¦ and some ā€œheavyā€ path conversations, if wanted.

Hi guys, a big thank you for the trail blazing on this. I am hoping to a develop a stock ticker element (single line, scrolling, updatable text) and am wondering whether this implementation would be a good place to start from or if there are other jumping off points that might be a better foundation. Any advice from the participants in this thread would be really appreciated,
Fergal