joshcamas Posted March 28, 2015 Share Posted March 28, 2015 Hey guys! I'm wondering... is it possible to horizontally or vertically flip a mesh and armature? Thanks! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 30, 2015 Share Posted March 30, 2015 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) Quote Link to comment Share on other sites More sharing options...
joshcamas Posted March 30, 2015 Author Share Posted March 30, 2015 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 30, 2015 Share Posted March 30, 2015 Scaling by -1 is fine but normal will have to be inverted then (or you have to use a double sided mesh or disable backFaceCulling) Quote Link to comment Share on other sites More sharing options...
joshcamas Posted March 30, 2015 Author Share Posted March 30, 2015 Disabling BackFaceCulling works like a charm!! Will this make things slower by any chance? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 30, 2015 Share Posted March 30, 2015 A little bit because back face are sent to the pixel shader Quote Link to comment Share on other sites More sharing options...
joshcamas Posted March 31, 2015 Author Share Posted March 31, 2015 "normal will have to be inverted then"How is this done? I tried simply multiplying all the normals by -1, but this didn't quite work. Quote Link to comment Share on other sites More sharing options...
jerome Posted April 1, 2015 Share Posted April 1, 2015 After having scaled at -1, if you can get/instantiate the vertexData relative to your mesh, you can then use this :https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Mesh/babylon.mesh.vertexData.ts#L1167 With BACKSIDE orientation value parameter, this fonction will reorder your indices and invert the normals the right way. joshcamas 1 Quote Link to comment Share on other sites More sharing options...
joshcamas Posted April 1, 2015 Author Share Posted April 1, 2015 oooooooooooooooooo!!!! Thank you so much!!! Super cool! Quote Link to comment Share on other sites More sharing options...
joshcamas Posted April 18, 2015 Author Share Posted April 18, 2015 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: http://i.imgur.com/VctI3Pe.png 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);Thanks! Quote Link to comment Share on other sites More sharing options...
jerome Posted April 19, 2015 Share Posted April 19, 2015 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 meshComputeSides 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 Quote Link to comment Share on other sites More sharing options...
joshcamas Posted April 19, 2015 Author Share Posted April 19, 2015 Dowsn't seem to work! :C Also, looks like uv's aren't touched, wouldn't that delete uv's? http://i.imgur.com/jww14KU.png Quote Link to comment Share on other sites More sharing options...
jerome Posted April 20, 2015 Share Posted April 20, 2015 No, for BACKSIDE, it doesn't modify uvsare you sure you need BACKSIDE ? did you try FRONTSIDE ? I don't know how your flipped mesh is built ... scale -1 ? 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.