Jump to content

ribbon mesh ... second version


jerome
 Share

Recommended Posts

Hi back guys !!

 

I worked a little to improve my ribbon mesh (still a draft)

 

Now, the call function signature is this one :

createRibbon(mesh, [paths], close, offset, scene);

easy, isn't it ?

 

  • mesh : the blank mesh you want to be ribbonized or mumified :)
  • [paths] : an array populated with paths. What is a path ? it's an array of successive Vector3. It is for example the discrete representation of a math curve ... or anything else you want.
  • close : boolean, if true the first and last ribbon drawn will be joined by an extra face
  • offset : not implemented yet, I'll tell you later
  • scene : the current scene

Let's start with a simple example.

I want to create p paths. Each path will be a curve along an exponential function :

    // my math function    var populatePath = function(path, p) {     for (var  i = 0; i < 40; i++) {      path.push( new BABYLON.Vector3(i-20, Math.cos(p / 3) * 3 * Math.exp(-(i-p-8)*(i-p-8) / 60) , p) );     }    };

Heeuuu, too much maths for me,  so don't tell, show please : http://www.babylonjs-playground.com/#1QD8LM

Each line is a path along a this exp function, right.

 

Ok, now let's mumify these lines :

    // mesh    var meshExp = new BABYLON.Mesh("meshExp", scene);    meshExp.material = mat;    createRibbon(meshExp, paths, false, null, scene);

what ? just a line of code ?

yes, sir : http://www.babylonjs-playground.com/#1QD8LM#1

 

but, you may prefer to see the full material, nope ?

http://www.babylonjs-playground.com/#1QD8LM#2

 

I hope I can code other examples more impressive than this very simple one.

For now the uv is not computed, so applying textures will probably be strange

Link to comment
Share on other sites

jerome, I'm no scripter or mathematician but I find something fascinating about your creations. I look at every example you post.

 

My favourites are in one of your earlier posts - the helical and Möbius ribbons. Be nice to bend the helical one - make it like a Christmas streamer/decoration.

 

Don't know why I find them fascinating :unsure: - I'm not sure I will ever use this kind of code, but keep making them :)

 

cheers, gryff :)

Link to comment
Share on other sites

thank you very much, gryff :)

 

I know Blender can produce highly detailed and rich meshes but we sometimes need computed meshes to represent incoming data for example. I really need them because I intend to code monitoring tools (network activity, server business, user activity, etc).

 

So here another simple example with some cubic bezier curves :

strange shape here : http://www.babylonjs-playground.com/#1QD8LM#3

 

then mumified : http://www.babylonjs-playground.com/#1QD8LM#4 :lol:

 

hope I could make tubes, helix, moebius (from a lone path, it's my challenge) in the coming days !

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