Jump to content

baked rotations on mesh building


jerome
 Share

Recommended Posts

Hi,

 

Since it is now quite easy to extend the CreateXXX() methods with the options parameter, I would introduce the ability to rotate a mesh at construction time.

 

DK added to the box width, length, depth. This gives the good old BJS box the capicity to become any cuboid, right ?

Actually this is quite the same than to bake the scale transformation into the mesh, although the mesh can still be scaled in the world then.

 

Imagine the same with the rotation. If we could bake a rotation at construction time, the mesh would be built rotated in its local space once for all. The world rotation transformation would sitll be possible then obviously in the world.

 

This feature would help to separate built-in rotations (local space and could be NOT upgradable) from World rotations.

 

So I'm looking for a pertinent english term to give to this feature. I think something with the world rotation would be confusing. Rotation should maybe be kept for World transformations only.

 

"turn" ?

var box = BABYLON.Mesh.CreateBox("box", {turnX: Math.PI, turnY: 0, turnZ : 0}, scene);

NOTE : As for scale-like (witdth, height, depth) parameters which can be applied to a box, a sphere, a plane, a torus, etc, this rotation-like parameter type would be appliable to any mesh built with CreateXXX()

 

Any suggestion please ?

Link to comment
Share on other sites

I don't speak about world transformations here but about the ability to build a once for all pre-rotated mesh in its local space.

Exactly like the width, length, depth set a kind of baked scale to the mesh.

 

Example : if we know a box should be inclined for 45° on the z local axis because it is the way it must be for ever in the world. However this box is immutable, it won't ever change.

 

Solution 1 : we apply a rotation (or quaternion) as usual, this means we compute a rotation matrix, then we ask the GPU to apply this matrix to the box vertices. Maybe not convinient when parenting, etc.

 

Solution 2 : we rotate the box once, we bake it into vertices, so we re-build the mesh, rotated in its own local space.

 

So why not to do this #2 at mesh creation once when computing its geometry ?

Link to comment
Share on other sites

hmmm... you guys are fun.  So, let's see, being able to set ANY dims for a box at creation time, eliminates scaling... in some ways.  Scaling always suffered from unpreventable hand-me-down scaling to children.  That's one thing.

 

Hmm...

 

We COULD allow an options object... or... a vertexData object in it's place.  Then add some rotate methods onto the vertexData objects.   Bakery fresh VD!  :o   errr... hmm.  I guess that would equate-to createCustomMesh(name, vertexDataObj, scene);

 

I'm outside my league, here.  It seems that Jerome is so far gone... that he's come back around on the back-side.  :)  Fun!  He's the Julia Child of our geometry kitchens, and he's cookin'-up some rather exotic dishes.

 

Jerome... there comes a time... when a guy might ask himself... "How many extra lines in the options object == one line of JS to do a rotation?"  I think it's a plausibility thing.  :)  You... want to add "the power", and that's cool.  It's another option... another way to create. 

 

But... yeah, you know... stuff.

 

What if... you made the BJS HLI ?  High-level interpreter.  Create your own script language... for geometry plotting.  huh?   jMeshScript!  :)  Activate it in any BJS scene, for a small overhead price.   Yeah!   errr...

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