Numa Posted February 17, 2017 Share Posted February 17, 2017 Hi there, After loading my mesh I apply a translation/rotation to the verts so I need to recompute the normals if I want the lighting to be accurate. However it causes the normals to not be smoothed, am I doing it wrong? BABYLON.Mesh.prototype.recomputeNormals = function () { var normals = []; var positions = this.getVerticesData(BABYLON.VertexBuffer.PositionKind); normals = this.getVerticesData(BABYLON.VertexBuffer.NormalKind); BABYLON.VertexData.ComputeNormals(positions, this.getIndices(), normals); this.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals); } before recomputing the normals: After: thanks! Quote Link to comment Share on other sites More sharing options...
JohnK Posted February 17, 2017 Share Posted February 17, 2017 Do you need to translate/rotate individual vertices rather than the mesh? Quote Link to comment Share on other sites More sharing options...
Numa Posted February 18, 2017 Author Share Posted February 18, 2017 Yes I think I do. I move submeshes around in my application based on external data and it's all contingent on each submesh having its origin at the center of its bounding box. However when I load a model, all submeshes have their origin at the center of the model (0, 0, 0) so I move the verts so that the center of the bounding box is 0,0,0, then I translate the mesh back to where it was. I use object.bakeTransformIntoVertices(); Is there a better way to achieve that? I'm not sure why I would lose the smoothing after recalculating, I move the whole thing at once, verts have the same relative positions. Quote Link to comment Share on other sites More sharing options...
adam Posted February 18, 2017 Share Posted February 18, 2017 It looks like you might need to change the pivot point of your mesh. Try using mesh.setPivotPoint: https://github.com/BabylonJS/Babylon.js/blob/88931762d8200d6d74a7bbbc4e49673994ed6b82/src/Mesh/babylon.abstractMesh.ts#L1555 Quote Link to comment Share on other sites More sharing options...
Numa Posted February 18, 2017 Author Share Posted February 18, 2017 I just realized the problem is not at all what I thought it was, I will make a new post. Sorry about that, feel free to delete! Quote Link to comment Share on other sites More sharing options...
adam Posted February 18, 2017 Share Posted February 18, 2017 For those of you following, this issue continues here: Numa 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.