Jump to content

Flipping a mesh?


Recommended Posts

Hi Josh, good to hear from you.  Have you got a moment to tell us more about what you're trying to do?  Most folk flip a mesh with a .rotation property... but you are obviously working with bones or something unique.  Are you looking to transform all the vertex positions to perform the flip?  Is there blender-made animation on the bones? (thx)

Link to comment
Share on other sites

Sorry, but when I say "flip", I don't mean rotate - I mean like mirroring it. 

Basically I have an arm... a left arm, as a matter a fact. I'm needing to flip the arm to turn it into a right arm! :)


I tried scaling it like (0,-1,0), and it almost works, but the mesh looks strange... so that doesn't work. And ye, it's animated via blender.

Link to comment
Share on other sites

After having scaled at -1, if you can get/instantiate the vertexData relative to your mesh, you can then use this :




With BACKSIDE orientation value parameter, this fonction will reorder your indices and invert the normals the right way.

Link to comment
Share on other sites

  • 3 weeks later...

Ok, so I've been trying to get this working, to no avail. :/


I've tried many different variations, and it still don't work. Here's what I got working:




And here's the code:

                var vertices = _this.mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);                var indices = _this.mesh.getIndices();                var normals = _this.mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind)                var vertexData = BABYLON.VertexData._ComputeSides(BABYLON.Mesh.BACKSIDE,                    vertices,                    indices,                    normals                    );                _this.mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind,vertices);                _this.mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals);                _this.mesh.setIndices(indices)                //Re add them                var vertices = _this.mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);                var indices = _this.mesh.getIndices();                var normals = _this.mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind)                BABYLON.VertexData.ComputeNormals(vertices,indices,normals);


Link to comment
Share on other sites

I guess you should re-compute sides just after the computeNormals, but it's not necessary imo because normals are already set and before re-adding them to the mesh

ComputeSides needs a uvs parameter also (give the original mesh uvs array - what you should do - or just an empty array for testing ... well, it's required only for DOUBLESIDE indeed)


something like :

var vertices = _this.mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);var indices = _this.mesh.getIndices();var normals = _this.mesh.getVerticesData(BABYLON.VertexBuffer.NormalKind)var uvs = [];BABYLON.VertexData.ComputeNormals(vertices,indices,normals);var vertexData = BABYLON.VertexData._ComputeSides(BABYLON.Mesh.BACKSIDE,vertices,indices,normals,uvs);_this.mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind,vertices);_this.mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals);_this.mesh.setIndices(indices);

it just looks like an order problem

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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...